mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset cb3179f8ea2b (bug 1079563) for bc memory leak test failures
This commit is contained in:
parent
a3f909e240
commit
326fc44773
@ -5,6 +5,7 @@
|
||||
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/WebChannel.jsm");
|
||||
|
||||
@ -36,45 +37,47 @@ function run_test() {
|
||||
/**
|
||||
* Test channel listening
|
||||
*/
|
||||
add_task(function test_web_channel_listen() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let channel = new WebChannel(VALID_WEB_CHANNEL_ID, VALID_WEB_CHANNEL_ORIGIN, {
|
||||
broker: MockWebChannelBroker
|
||||
});
|
||||
let delivered = 0;
|
||||
do_check_eq(channel.id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_eq(channel.origin.spec, VALID_WEB_CHANNEL_ORIGIN.spec);
|
||||
do_check_eq(channel._deliverCallback, null);
|
||||
|
||||
channel.listen(function(id, message, target) {
|
||||
do_check_eq(id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_true(message);
|
||||
do_check_true(message.command);
|
||||
do_check_true(target.sender);
|
||||
delivered++;
|
||||
// 2 messages should be delivered
|
||||
if (delivered === 2) {
|
||||
channel.stopListening();
|
||||
do_check_eq(channel._deliverCallback, null);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
// send two messages
|
||||
channel.deliver({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "one"
|
||||
}
|
||||
}, { sender: true });
|
||||
|
||||
channel.deliver({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "two"
|
||||
}
|
||||
}, { sender: true });
|
||||
add_test(function test_web_channel_listen() {
|
||||
let channel = new WebChannel(VALID_WEB_CHANNEL_ID, VALID_WEB_CHANNEL_ORIGIN, {
|
||||
broker: MockWebChannelBroker
|
||||
});
|
||||
let cb = Async.makeSpinningCallback();
|
||||
let delivered = 0;
|
||||
do_check_eq(channel.id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_eq(channel.origin.spec, VALID_WEB_CHANNEL_ORIGIN.spec);
|
||||
do_check_eq(channel._deliverCallback, null);
|
||||
|
||||
channel.listen(function(id, message, target) {
|
||||
do_check_eq(id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_true(message);
|
||||
do_check_true(message.command);
|
||||
do_check_true(target.sender);
|
||||
delivered++;
|
||||
// 2 messages should be delivered
|
||||
if (delivered === 2) {
|
||||
channel.stopListening();
|
||||
do_check_eq(channel._deliverCallback, null);
|
||||
cb();
|
||||
run_next_test();
|
||||
}
|
||||
});
|
||||
|
||||
// send two messages
|
||||
channel.deliver({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "one"
|
||||
}
|
||||
}, { sender: true });
|
||||
|
||||
channel.deliver({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "two"
|
||||
}
|
||||
}, { sender: true });
|
||||
|
||||
cb.wait();
|
||||
});
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://services-common/async.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/WebChannel.jsm");
|
||||
|
||||
@ -51,33 +52,34 @@ add_test(function test_web_channel_broker_channel_map() {
|
||||
/**
|
||||
* Test WebChannelBroker _listener test
|
||||
*/
|
||||
add_task(function test_web_channel_broker_listener() {
|
||||
return new Promise((resolve, reject) => {
|
||||
var channel = new Object({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
origin: VALID_WEB_CHANNEL_ORIGIN,
|
||||
deliver: function(data, sender) {
|
||||
do_check_eq(data.id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_eq(data.message.command, "hello");
|
||||
WebChannelBroker.unregisterChannel(channel);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
WebChannelBroker.registerChannel(channel);
|
||||
|
||||
var mockEvent = {
|
||||
data: {
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "hello"
|
||||
}
|
||||
},
|
||||
principal: {
|
||||
origin: URL_STRING
|
||||
}
|
||||
};
|
||||
|
||||
WebChannelBroker._listener(mockEvent);
|
||||
add_test(function test_web_channel_broker_listener() {
|
||||
let cb = Async.makeSpinningCallback();
|
||||
var channel = new Object({
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
origin: VALID_WEB_CHANNEL_ORIGIN,
|
||||
deliver: function(data, sender) {
|
||||
do_check_eq(data.id, VALID_WEB_CHANNEL_ID);
|
||||
do_check_eq(data.message.command, "hello");
|
||||
WebChannelBroker.unregisterChannel(channel);
|
||||
cb();
|
||||
run_next_test();
|
||||
}
|
||||
});
|
||||
|
||||
WebChannelBroker.registerChannel(channel);
|
||||
|
||||
var mockEvent = {
|
||||
data: {
|
||||
id: VALID_WEB_CHANNEL_ID,
|
||||
message: {
|
||||
command: "hello"
|
||||
}
|
||||
},
|
||||
principal: {
|
||||
origin: URL_STRING
|
||||
}
|
||||
};
|
||||
|
||||
WebChannelBroker._listener(mockEvent);
|
||||
cb.wait();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user