Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 49558b9

Browse files
terrylucascommit-bot@chromium.org
authored andcommitted
Fixed MessageChannel receiveing messages on ports.
Removed pkg browser from tests. Fixes dart-lang/sdk#26351 Fixes dart-lang/sdk#32631 R=kevmoo@google.com Change-Id: Ib0ef5f933d38b2f748cca1f82de8bcf01702df4d Reviewed-on: https://dart-review.googlesource.com/48742 Reviewed-by: Kevin Moore <kevmoo@google.com> Commit-Queue: Terry Lucas <terry@google.com>
1 parent e150bf6 commit 49558b9

File tree

7 files changed

+85
-6
lines changed

7 files changed

+85
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
* `dart:collection`
1010
* Removed `Maps` class. Extend `MapBase` or mix in `MapMixin` instead to
1111
provide map method implementations for a class.
12+
* `dart:html`
13+
* Removed deprecated `query` and `queryAll` use `querySelector` and `queryAllSelector`.
14+
* Removed experimental `Document` method `getCSSCanvasContext` and property
15+
`supportsCssCanvasContext`.
16+
* Removed obsolete `Element` property `xtag` no longer supported in browsers.
17+
* Exposed `ServiceWorker` class.
18+
* Added constructor to `MessageChannel` and `MessagePort` `addEventListener` automatically calls
19+
`start` method to receive queued messages.
1220
* `dart:io`
1321
* Added `IOOverrides.socketConnect`.
1422

sdk/lib/html/dart2js/html_dart2js.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26923,15 +26923,27 @@ class MessageEvent extends Event {
2692326923
void _initMessageEvent_1(typeArg, canBubbleArg, cancelableArg, dataArg,
2692426924
originArg, lastEventIdArg, sourceArg, List<MessagePort> portsArg) native;
2692526925
}
26926-
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
26926+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2692726927
// for details. All rights reserved. Use of this source code is governed by a
2692826928
// BSD-style license that can be found in the LICENSE file.
2692926929

26930-
@DocsEditable()
26930+
// WARNING: Do not edit - generated code.
26931+
2693126932
@DomName('MessagePort')
2693226933
@Unstable()
2693326934
@Native("MessagePort")
2693426935
class MessagePort extends EventTarget {
26936+
void addEventListener(String type, EventListener listener,
26937+
[bool useCapture]) {
26938+
// Messages posted to ports are initially paused, allowing listeners to be
26939+
// setup, start() needs to be explicitly invoked to begin handling messages.
26940+
if (type == 'message') {
26941+
start();
26942+
}
26943+
26944+
super.addEventListener(type, listener, useCapture);
26945+
}
26946+
2693526947
// To suppress missing implicit constructor warnings.
2693626948
factory MessagePort._() {
2693726949
throw new UnsupportedError("Not supported");
@@ -26983,6 +26995,7 @@ class MessagePort extends EventTarget {
2698326995
@DocsEditable()
2698426996
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
2698526997
}
26998+
2698626999
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2698727000
// for details. All rights reserved. Use of this source code is governed by a
2698827001
// BSD-style license that can be found in the LICENSE file.

tests/html/custom/element_upgrade_test.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,5 @@ <h1> Running element_upgrade_test </h1>
4545

4646
<script type="text/javascript"
4747
src="/root_dart/tools/testing/dart/test_controller.js"></script>
48-
<script type="text/javascript"
49-
src="/packages/browser/interop.js"></script>
5048
%TEST_SCRIPTS%
5149
</body>

tests/lib_2/html/custom/element_upgrade_test.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,5 @@ <h1> Running element_upgrade_test </h1>
4545

4646
<script type="text/javascript"
4747
src="/root_dart/tools/testing/dart/test_controller.js"></script>
48-
<script type="text/javascript"
49-
src="/packages/browser/interop.js"></script>
5048
%TEST_SCRIPTS%
5149
</body>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
import 'dart:html';
7+
8+
import 'package:expect/minitest.dart';
9+
10+
main() async {
11+
var gotOnMessage = false;
12+
var gotEventListener = false;
13+
14+
Completer completer = new Completer();
15+
16+
var channel = new MessageChannel();
17+
channel.port1.postMessage("Tickle me.");
18+
19+
channel.port2.onMessage.listen((MessageEvent e) {
20+
expect(e.data, "Tickle me.");
21+
gotOnMessage = true;
22+
});
23+
24+
channel.port2.addEventListener("message", (message) {
25+
var msg = message as MessageEvent;
26+
expect(msg.data, "Tickle me.");
27+
gotEventListener = true;
28+
completer.complete();
29+
});
30+
31+
// Wait for the event listener.
32+
await completer.future;
33+
34+
// Make sure both fired.
35+
expect(gotOnMessage, true);
36+
expect(gotEventListener, true);
37+
}

tests/lib_2/lib_2_dart2js.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ html/localstorage_test: RuntimeError
289289
html/location_test: RuntimeError
290290
html/media_stream_test: RuntimeError
291291
html/mediasource_test: RuntimeError
292+
html/message_channel_test: RuntimeError
292293
html/messageevent_test: RuntimeError
293294
html/mirrors_js_typed_interop_test: RuntimeError
294295
html/mouse_event_test: RuntimeError
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// WARNING: Do not edit - generated code.
6+
7+
part of $LIBRARYNAME;
8+
9+
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
10+
11+
void addEventListener(String type, EventListener listener,
12+
[bool useCapture]) {
13+
// Messages posted to ports are initially paused, allowing listeners to be
14+
// setup, start() needs to be explicitly invoked to begin handling messages.
15+
if (type == 'message') {
16+
start();
17+
}
18+
19+
super.addEventListener(type, listener, useCapture);
20+
}
21+
22+
$!MEMBERS
23+
}
24+

0 commit comments

Comments
 (0)