Bug 1274265 - browser_broadcastchannel.js should not expose content promises to the rest of the test, r=jhao

This commit is contained in:
Andrea Marchesini 2016-06-15 11:51:44 +01:00
Родитель 2d1e6d62c8
Коммит 7c172bb734
1 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -34,16 +34,17 @@ add_task(function* test() {
let channelName = "contextualidentity-broadcastchannel";
// reflect the received message on title
let receiveMsg = ContentTask.spawn(receiver.browser, channelName,
function (name) {
return new content.window.wrappedJSObject.Promise(resolve => {
content.window.bc = new content.window.BroadcastChannel(name);
content.window.bc.onmessage = function (e) {
content.document.title += e.data;
resolve();
}
});
yield ContentTask.spawn(receiver.browser, channelName,
function (name) {
content.window.testPromise = new content.window.Promise(resolve => {
content.window.bc = new content.window.BroadcastChannel(name);
content.window.bc.onmessage = function (e) {
content.document.title += e.data;
resolve();
}
});
}
);
let sender1 = yield* openTabInUserContext(URI, 1);
let sender2 = yield* openTabInUserContext(URI, 2);
@ -63,7 +64,11 @@ add_task(function* test() {
}
// make sure we have received a message
yield receiveMsg;
yield ContentTask.spawn(receiver.browser, channelName,
function* (name) {
yield content.window.testPromise.then(function() {});
}
);
// Since sender1 sends before sender2, if the title is exactly
// sender2's message, sender1's message must've been blocked