mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 13:38:03 +00:00
Fix notification
BUG= R=terry@google.com Review URL: https://codereview.chromium.org//1002953005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44471 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
6d7df7d546
commit
5d2f7f8ae8
|
@ -22684,17 +22684,18 @@ class NodeList extends Interceptor with ListMixin<Node>, ImmutableListMixin<Node
|
|||
@Native("Notification")
|
||||
class Notification extends EventTarget {
|
||||
|
||||
factory Notification(String title, {String titleDir: null, String body: null,
|
||||
String bodyDir: null, String tag: null, String iconUrl: null}) {
|
||||
factory Notification(String title, {String dir: null, String body: null,
|
||||
String lang: null, String tag: null, String icon: null}) {
|
||||
|
||||
var parsedOptions = {};
|
||||
if (titleDir != null) parsedOptions['titleDir'] = titleDir;
|
||||
if (dir != null) parsedOptions['dir'] = dir;
|
||||
if (body != null) parsedOptions['body'] = body;
|
||||
if (bodyDir != null) parsedOptions['bodyDir'] = bodyDir;
|
||||
if (lang != null) parsedOptions['lang'] = lang;
|
||||
if (tag != null) parsedOptions['tag'] = tag;
|
||||
if (iconUrl != null) parsedOptions['iconUrl'] = iconUrl;
|
||||
|
||||
return Notification._factoryNotification(title, parsedOptions);
|
||||
if (icon != null) parsedOptions['icon'] = icon;
|
||||
var nativeOptions;
|
||||
nativeOptions = convertDartToNative_Dictionary(parsedOptions);
|
||||
return Notification._factoryNotification(title, nativeOptions);
|
||||
}
|
||||
// To suppress missing implicit constructor warnings.
|
||||
factory Notification._() { throw new UnsupportedError("Not supported"); }
|
||||
|
@ -22750,6 +22751,9 @@ class Notification extends EventTarget {
|
|||
static Notification _create_1(title, options) => JS('Notification', 'new Notification(#,#)', title, options);
|
||||
static Notification _create_2(title) => JS('Notification', 'new Notification(#)', title);
|
||||
|
||||
/// Checks if this type is supported on the current platform.
|
||||
static bool get supported => JS('bool', '!!(window.Notification)');
|
||||
|
||||
@DomName('Notification.body')
|
||||
@DocsEditable()
|
||||
@Experimental() // untriaged
|
||||
|
|
|
@ -24835,17 +24835,18 @@ class NodeList extends NativeFieldWrapperClass2 with ListMixin<Node>, ImmutableL
|
|||
@Experimental() // experimental
|
||||
class Notification extends EventTarget {
|
||||
|
||||
factory Notification(String title, {String titleDir: null, String body: null,
|
||||
String bodyDir: null, String tag: null, String iconUrl: null}) {
|
||||
factory Notification(String title, {String dir: null, String body: null,
|
||||
String lang: null, String tag: null, String icon: null}) {
|
||||
|
||||
var parsedOptions = {};
|
||||
if (titleDir != null) parsedOptions['titleDir'] = titleDir;
|
||||
if (dir != null) parsedOptions['dir'] = dir;
|
||||
if (body != null) parsedOptions['body'] = body;
|
||||
if (bodyDir != null) parsedOptions['bodyDir'] = bodyDir;
|
||||
if (lang != null) parsedOptions['lang'] = lang;
|
||||
if (tag != null) parsedOptions['tag'] = tag;
|
||||
if (iconUrl != null) parsedOptions['iconUrl'] = iconUrl;
|
||||
|
||||
return Notification._factoryNotification(title, parsedOptions);
|
||||
if (icon != null) parsedOptions['icon'] = icon;
|
||||
var nativeOptions;
|
||||
nativeOptions = parsedOptions;
|
||||
return Notification._factoryNotification(title, nativeOptions);
|
||||
}
|
||||
// To suppress missing implicit constructor warnings.
|
||||
factory Notification._() { throw new UnsupportedError("Not supported"); }
|
||||
|
@ -24899,6 +24900,9 @@ class Notification extends EventTarget {
|
|||
return _blink.BlinkNotification.instance.constructorCallback_1_(title);
|
||||
}
|
||||
|
||||
/// Checks if this type is supported on the current platform.
|
||||
static bool get supported => true;
|
||||
|
||||
@DomName('Notification.body')
|
||||
@DocsEditable()
|
||||
@Experimental() // untriaged
|
||||
|
|
|
@ -123,6 +123,7 @@ deferred_multi_app_htmltest: Skip # Times out on IE. Issue 21537
|
|||
localstorage_test: Pass, RuntimeError # Issue 22166
|
||||
storage_test: Pass, RuntimeError # Issue 22166
|
||||
postmessage_structured_test/more_primitives: Fail # Does not support the MessageEvent constructor.
|
||||
notification_test: Fail # Notification not supported on IE
|
||||
|
||||
[$runtime == ie10 || $runtime == ie11 || ($runtime == chrome && $system == macos)]
|
||||
transition_event_test/functional: Skip # Times out. Issue 22167
|
||||
|
|
49
tests/html/notification_test.dart
Normal file
49
tests/html/notification_test.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library notification_test;
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_individual_config.dart';
|
||||
import 'dart:html';
|
||||
|
||||
main() {
|
||||
useHtmlIndividualConfiguration();
|
||||
|
||||
group('supported_notification', () {
|
||||
test('supported', () {
|
||||
expect(Notification.supported, true);
|
||||
});
|
||||
});
|
||||
|
||||
group('constructors', () {
|
||||
// Test that we create the notification and that the parameters have
|
||||
// the expected values. Note that these won't actually display, because
|
||||
// we haven't asked for permission, which would have to be done
|
||||
// interactively, so can't run on a bot.
|
||||
test('Notification', () {
|
||||
var expectation = Notification.supported ? returnsNormally : throws;
|
||||
expect(() {
|
||||
var allDefaults = new Notification("Hello world");
|
||||
var allSpecified = new Notification("Deluxe notification",
|
||||
dir: "rtl",
|
||||
body: 'All parameters set',
|
||||
icon: 'icon.png',
|
||||
tag: 'tag',
|
||||
lang: 'en_US');
|
||||
expect(allDefaults is Notification, isTrue);
|
||||
expect(allSpecified is Notification, isTrue);
|
||||
expect(allDefaults.title, "Hello world");
|
||||
expect(allSpecified.title, "Deluxe notification");
|
||||
expect(allSpecified.dir, "rtl");
|
||||
expect(allSpecified.body, "All parameters set");
|
||||
var icon = allSpecified.icon;
|
||||
var tail = Uri.parse(icon).pathSegments.last;
|
||||
expect(tail, "icon.png");
|
||||
expect(allSpecified.tag, "tag");
|
||||
expect(allSpecified.lang, "en_US");
|
||||
}, expectation);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -8259,17 +8259,6 @@
|
|||
},
|
||||
"support_level": "experimental"
|
||||
},
|
||||
"NotificationCenter": {
|
||||
"comment": "http://www.w3.org/TR/notifications/#showing-a-notification",
|
||||
"dart_action": "suppress",
|
||||
"members": {
|
||||
"checkPermission": {},
|
||||
"createHTMLNotification": {},
|
||||
"createNotification": {},
|
||||
"requestPermission": {}
|
||||
},
|
||||
"support_level": "deprecated"
|
||||
},
|
||||
"NotificationPermissionCallback": {
|
||||
"comment": "http://www.w3.org/TR/notifications/#notificationpermissioncallback",
|
||||
"members": {
|
||||
|
|
|
@ -409,11 +409,6 @@ interface SVGSVGElement {
|
|||
[DartSuppress] attribute DOMString contentScriptType;
|
||||
};
|
||||
|
||||
[DartSupplemental]
|
||||
interface WorkerGlobalScope {
|
||||
[DartSuppress] readonly attribute NotificationCenter webkitNotifications;
|
||||
};
|
||||
|
||||
[DartSupplemental]
|
||||
interface AudioBuffer {
|
||||
[DartSuppress] attribute float gain;
|
||||
|
|
|
@ -525,7 +525,6 @@ _annotations = monitored.Dict('dartmetadata._annotations', {
|
|||
"@SupportedBrowser(SupportedBrowser.SAFARI)",
|
||||
"@Experimental()",
|
||||
],
|
||||
'NotificationCenter': _webkit_experimental_annotations,
|
||||
'Performance': _performance_annotations,
|
||||
'PopStateEvent': _history_annotations,
|
||||
'RTCIceCandidate': _rtc_annotations,
|
||||
|
|
|
@ -98,7 +98,6 @@ _removed_html_interfaces = [
|
|||
'IDBAny',
|
||||
'MutationEvent',
|
||||
'Notation',
|
||||
'NotificationCenter',
|
||||
'PagePopupController',
|
||||
'RGBColor',
|
||||
'RadioNodeList', # Folded onto NodeList in dart2js.
|
||||
|
@ -163,7 +162,6 @@ convert_to_future_members = monitored.Set(
|
|||
'FontLoader.notifyWhenFontsReady',
|
||||
'MediaStreamTrack.getSources',
|
||||
'Notification.requestPermission',
|
||||
'NotificationCenter.requestPermission',
|
||||
'RTCPeerConnection.setLocalDescription',
|
||||
'RTCPeerConnection.setRemoteDescription',
|
||||
'StorageInfo.requestQuota',
|
||||
|
|
|
@ -421,7 +421,7 @@ js_support_checks = dict({
|
|||
'HTMLTemplateElement': ElemSupportStr('template'),
|
||||
'MediaStreamEvent': "Device.isEventTypeSupported('MediaStreamEvent')",
|
||||
'MediaStreamTrackEvent': "Device.isEventTypeSupported('MediaStreamTrackEvent')",
|
||||
'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')",
|
||||
'Notification': "JS('bool', '!!(window.Notification)')",
|
||||
'Performance': "JS('bool', '!!(window.performance)')",
|
||||
'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || "
|
||||
"window.webkitSpeechRecognition)')",
|
||||
|
|
|
@ -6,17 +6,22 @@ part of $LIBRARYNAME;
|
|||
|
||||
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
||||
|
||||
factory $CLASSNAME(String title, {String titleDir: null, String body: null,
|
||||
String bodyDir: null, String tag: null, String iconUrl: null}) {
|
||||
factory $CLASSNAME(String title, {String dir: null, String body: null,
|
||||
String lang: null, String tag: null, String icon: null}) {
|
||||
|
||||
var parsedOptions = {};
|
||||
if (titleDir != null) parsedOptions['titleDir'] = titleDir;
|
||||
if (dir != null) parsedOptions['dir'] = dir;
|
||||
if (body != null) parsedOptions['body'] = body;
|
||||
if (bodyDir != null) parsedOptions['bodyDir'] = bodyDir;
|
||||
if (lang != null) parsedOptions['lang'] = lang;
|
||||
if (tag != null) parsedOptions['tag'] = tag;
|
||||
if (iconUrl != null) parsedOptions['iconUrl'] = iconUrl;
|
||||
|
||||
return $CLASSNAME._factory$CLASSNAME(title, parsedOptions);
|
||||
if (icon != null) parsedOptions['icon'] = icon;
|
||||
var nativeOptions;
|
||||
$if DART2JS
|
||||
nativeOptions = convertDartToNative_Dictionary(parsedOptions);
|
||||
$else
|
||||
nativeOptions = parsedOptions;
|
||||
$endif
|
||||
return $CLASSNAME._factory$CLASSNAME(title, nativeOptions);
|
||||
}
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue