2013-07-11 02:05:39 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
|
|
type="text/css"?>
|
|
|
|
<window title="MessageManager CPOW tests"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
onload="start()">
|
|
|
|
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
|
|
<label value="CPOWs"/>
|
|
|
|
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
var test_state = "remote";
|
|
|
|
var test_node = null;
|
2013-10-01 20:15:06 +04:00
|
|
|
var reentered = false;
|
2014-05-17 03:40:37 +04:00
|
|
|
var savedMM = null;
|
2014-09-13 04:41:19 +04:00
|
|
|
const Cu = Components.utils;
|
2014-05-17 03:40:37 +04:00
|
|
|
|
|
|
|
function info(message) {
|
|
|
|
return opener.wrappedJSObject.info(message);
|
|
|
|
}
|
2013-07-11 02:05:39 +04:00
|
|
|
|
|
|
|
function ok(condition, message) {
|
|
|
|
return opener.wrappedJSObject.ok(condition, message);
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
function is(v1, v2, message) {
|
|
|
|
return opener.wrappedJSObject.is(v1, v2, message);
|
|
|
|
}
|
|
|
|
|
2014-09-13 04:41:19 +04:00
|
|
|
function todo_is(v1, v2, message) {
|
|
|
|
return opener.wrappedJSObject.todo_is(v1, v2, message);
|
|
|
|
}
|
|
|
|
|
2013-08-24 03:04:20 +04:00
|
|
|
// Make sure that an error in this file actually causes the test to fail.
|
2014-09-15 16:17:32 +04:00
|
|
|
var gReceivedErrorProbe = false;
|
2013-08-24 03:04:20 +04:00
|
|
|
window.onerror = function (msg, url, line) {
|
2014-09-15 16:17:32 +04:00
|
|
|
if (/Test Error Probe/.test(msg)) {
|
|
|
|
gReceivedErrorProbe = true;
|
|
|
|
return;
|
|
|
|
}
|
2013-08-24 03:04:20 +04:00
|
|
|
ok(false, "Error while executing: \n" + msg + "\n" + url + ":" + line);
|
|
|
|
};
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
function testCpowMessage(message) {
|
|
|
|
ok(message.json.check == "ok", "correct json");
|
|
|
|
|
2014-05-29 05:05:22 +04:00
|
|
|
ok(!Components.utils.isCrossProcessWrapper(message.json), "not everything is a CPOW");
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
let data = message.objects.data;
|
|
|
|
let document = message.objects.document;
|
2014-05-29 05:05:22 +04:00
|
|
|
if (test_state == "remote") {
|
|
|
|
ok(Components.utils.isCrossProcessWrapper(data), "got a CPOW");
|
|
|
|
ok(Components.utils.isCrossProcessWrapper(document), "got a CPOW");
|
|
|
|
}
|
2013-07-11 02:05:39 +04:00
|
|
|
ok(data.i === 5, "integer property");
|
|
|
|
ok(data.b === true, "boolean property");
|
|
|
|
ok(data.s === "hello", "string property");
|
|
|
|
ok(data.x.i === 10, "nested property");
|
|
|
|
ok(data.f() === 99, "function call");
|
2014-10-31 01:51:39 +03:00
|
|
|
is(Object.getOwnPropertyDescriptor(data, "doesn't exist"), undefined,
|
|
|
|
"getOwnPropertyDescriptor returns undefined for non-existant properties");
|
|
|
|
ok(Object.getOwnPropertyDescriptor(data, "i").value, 5,
|
|
|
|
"getOwnPropertyDescriptor.value works");
|
2014-07-01 04:50:58 +04:00
|
|
|
let obj = new data.ctor();
|
|
|
|
ok(obj.a === 3, "constructor call");
|
2015-06-20 03:33:57 +03:00
|
|
|
is(document.title, "Hello, Kitty", "document node");
|
2014-10-31 01:51:39 +03:00
|
|
|
is(typeof document.cookie, "string", "can get document.cookie");
|
2014-11-15 01:41:59 +03:00
|
|
|
is(typeof document.defaultView.navigator.userAgent, "string", "can get navigator.userAgent");
|
2013-07-11 02:05:39 +04:00
|
|
|
|
2015-06-24 00:34:00 +03:00
|
|
|
// Don't crash.
|
|
|
|
document.defaultView.screen;
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
data.i = 6;
|
|
|
|
data.b = false;
|
|
|
|
data.s = "bye";
|
|
|
|
data.x = null;
|
|
|
|
ok(data.i === 6, "integer property");
|
|
|
|
ok(data.b === false, "boolean property");
|
|
|
|
ok(data.s === "bye", "string property");
|
|
|
|
ok(data.x === null, "nested property");
|
2013-07-17 17:27:49 +04:00
|
|
|
|
|
|
|
let throwing = message.objects.throwing;
|
|
|
|
// Based on the table on:
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
|
|
|
let tests = [
|
|
|
|
() => Object.getOwnPropertyDescriptor(throwing, 'test'),
|
|
|
|
() => Object.getOwnPropertyNames(throwing),
|
|
|
|
() => Object.defineProperty(throwing, 'test', {value: 1}),
|
|
|
|
() => delete throwing.test,
|
|
|
|
() => "test" in throwing,
|
|
|
|
() => Object.prototype.hasOwnProperty.call(throwing, 'test'),
|
|
|
|
() => throwing.test,
|
|
|
|
() => { throwing.test = 1 },
|
|
|
|
// () => { for (let prop in throwing) {} }, Bug 783829
|
|
|
|
() => { for (let prop of throwing) {} },
|
|
|
|
() => Object.keys(throwing),
|
|
|
|
() => Function.prototype.call.call(throwing),
|
|
|
|
() => new throwing,
|
|
|
|
() => Object.preventExtensions(throwing),
|
|
|
|
() => Object.freeze(throwing),
|
|
|
|
() => Object.seal(throwing),
|
|
|
|
]
|
|
|
|
|
|
|
|
for (let test of tests) {
|
|
|
|
let threw = false;
|
|
|
|
try {
|
|
|
|
test()
|
|
|
|
} catch (e) {
|
|
|
|
threw = true;
|
|
|
|
}
|
|
|
|
ok(threw, "proxy operation threw exception");
|
|
|
|
}
|
|
|
|
|
2013-09-30 23:20:51 +04:00
|
|
|
let array = message.objects.array;
|
|
|
|
let i = 1;
|
|
|
|
for (let elt of array) {
|
|
|
|
ok(elt === i, "correct element found");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
ok(i === 4, "array has correct length");
|
|
|
|
|
|
|
|
let j = message.objects.for_json;
|
|
|
|
let str = JSON.stringify(j);
|
|
|
|
let j2 = JSON.parse(str);
|
|
|
|
ok(j2.n === 3, "JSON integer property");
|
|
|
|
ok(j2.a[0] === 1, "JSON array index");
|
|
|
|
ok(j2.a[1] === 2, "JSON array index");
|
|
|
|
ok(j2.a[2] === 3, "JSON array index");
|
|
|
|
ok(j2.s === "hello", "JSON string property");
|
|
|
|
ok(j2.o.x === 10, "JSON object property");
|
2015-02-10 18:29:41 +03:00
|
|
|
|
|
|
|
let with_proto = message.objects.with_proto;
|
|
|
|
let proto = Object.getPrototypeOf(with_proto);
|
|
|
|
ok(proto.data == 42, "Object.getPrototypeOf works on CPOW");
|
|
|
|
|
|
|
|
let with_null_proto = message.objects.with_null_proto;
|
|
|
|
proto = Object.getPrototypeOf(with_null_proto);
|
|
|
|
ok(proto === null, "Object.getPrototypeOf works on CPOW (null proto)");
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function recvAsyncMessage(message) {
|
|
|
|
testCpowMessage(message);
|
2015-06-20 03:33:57 +03:00
|
|
|
savedMM.sendAsyncMessage("cpows:async_done");
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function recvSyncMessage(message) {
|
|
|
|
testCpowMessage(message);
|
|
|
|
}
|
|
|
|
|
2013-10-01 20:15:06 +04:00
|
|
|
function recvRpcMessage(message) {
|
|
|
|
ok(message.json.check == "ok", "correct json");
|
|
|
|
|
|
|
|
let data = message.objects.data;
|
|
|
|
|
|
|
|
// Sanity check.
|
|
|
|
ok(data.i === 5, "integer property");
|
|
|
|
|
|
|
|
// Check that we re-enter.
|
|
|
|
reentered = false;
|
|
|
|
let result = data.reenter();
|
|
|
|
ok(reentered, "re-entered rpc");
|
|
|
|
ok(result == "ok", "got correct result");
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvReenterMessage(message) {
|
|
|
|
ok(message.objects.data.valid === true, "cpows work");
|
|
|
|
reentered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvNestedSyncMessage(message) {
|
|
|
|
message.objects.data.reenter();
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvReenterSyncMessage(message) {
|
|
|
|
ok(false, "should not have received re-entered sync message");
|
|
|
|
}
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
function recvFailMessage(message) {
|
|
|
|
ok(false, message.json.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvDoneMessage(message) {
|
|
|
|
if (test_state == "remote") {
|
|
|
|
test_node.parentNode.removeChild(test_node);
|
|
|
|
run_tests("inprocess");
|
|
|
|
return;
|
|
|
|
}
|
2013-07-17 17:27:49 +04:00
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
function recvParentTest(message) {
|
|
|
|
let func = message.objects.func;
|
|
|
|
let result = func(n => 2*n);
|
|
|
|
ok(result == 20, "result == 20");
|
2014-11-05 04:38:19 +03:00
|
|
|
function f() {
|
|
|
|
return 101;
|
|
|
|
}
|
2014-08-20 23:49:10 +04:00
|
|
|
let obj = {a:1, __exposedProps__: {"a": "r"}};
|
2014-11-05 04:38:19 +03:00
|
|
|
savedMM.sendAsyncMessage("cpows:from_parent", {}, {obj: obj, func: f});
|
2014-05-17 03:40:37 +04:00
|
|
|
}
|
|
|
|
|
2014-09-15 16:17:32 +04:00
|
|
|
// Make sure errors in this file actually hit window.onerror.
|
|
|
|
function recvErrorReportingTest(message) {
|
|
|
|
throw "Test Error Probe";
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
let savedElement = null;
|
|
|
|
function recvDomTest(message) {
|
|
|
|
savedElement = message.objects.element;
|
2015-01-29 22:28:01 +03:00
|
|
|
|
2015-03-11 00:36:01 +03:00
|
|
|
is(savedElement.QueryInterface(Components.interfaces.nsISupports), savedElement,
|
|
|
|
"QI to nsISupports works");
|
|
|
|
is(savedElement.QueryInterface(Components.interfaces.nsIDOMNode), savedElement,
|
|
|
|
"QI to a random (implemented) interface works");
|
|
|
|
|
|
|
|
function testNoInterface(savedElement, i) {
|
|
|
|
try {
|
|
|
|
savedElement.QueryInterface(i);
|
|
|
|
ok(false, "should have thrown an exception");
|
|
|
|
} catch (e) {
|
|
|
|
is(e.result, Components.results.NS_ERROR_NO_INTERFACE, "threw the right exception");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
testNoInterface(savedElement, Components.interfaces.nsIDOMAttr);
|
|
|
|
testNoInterface(savedElement, Components.interfaces.nsIClassInfo);
|
|
|
|
|
2015-01-29 22:28:01 +03:00
|
|
|
// Test to ensure that we don't pass CPOWs to C++-implemented interfaces.
|
|
|
|
// See bug 1072980.
|
|
|
|
if (test_state == "remote") {
|
2015-03-11 00:36:01 +03:00
|
|
|
// This doesn't work because we intercept toString and QueryInterface specially
|
2015-03-06 17:46:00 +03:00
|
|
|
// and don't cache the function pointer.
|
|
|
|
// See bug 1140636.
|
|
|
|
todo_is(savedElement.toString, savedElement.toString, "toString identity works");
|
2015-03-11 00:36:01 +03:00
|
|
|
todo_is(savedElement.QueryInterface, savedElement.QueryInterface, "toString identity works");
|
2015-03-06 17:46:00 +03:00
|
|
|
|
2015-03-27 23:12:37 +03:00
|
|
|
is(Object.prototype.toString.call(savedElement), "[object HTMLDivElement]",
|
|
|
|
"prove that this works (and doesn't leak)");
|
|
|
|
|
|
|
|
is(Object.prototype.toString.call(savedElement), "[object HTMLDivElement]",
|
|
|
|
"prove that this works twice (since we cache it and doesn't leak)");
|
|
|
|
|
2015-03-06 17:46:00 +03:00
|
|
|
// This does work because we create a CPOW for isEqualNode that stays
|
|
|
|
// alive as long as we have a reference to the first CPOW (so as long
|
|
|
|
// as it's detectable).
|
|
|
|
is(savedElement.isEqualNode, savedElement.isEqualNode, "webidl function identity works");
|
|
|
|
|
2015-01-29 22:28:01 +03:00
|
|
|
let walker = Components.classes["@mozilla.org/inspector/deep-tree-walker;1"]
|
|
|
|
.createInstance(Components.interfaces.inIDeepTreeWalker);
|
|
|
|
const SHOW_ELEMENT = Components.interfaces.nsIDOMNodeFilter.SHOW_ELEMENT;
|
|
|
|
walker.showAnonymousContent = true;
|
|
|
|
walker.showSubDocuments = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
walker.init(savedElement, SHOW_ELEMENT);
|
|
|
|
ok(false, "expected exception passing CPOW to C++");
|
|
|
|
} catch (e) {
|
|
|
|
is(e.result, Components.results.NS_ERROR_XPC_CANT_PASS_CPOW_TO_NATIVE,
|
|
|
|
"got exception when passing CPOW to C++");
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 03:40:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function recvDomTestAfterGC(message) {
|
|
|
|
let id;
|
|
|
|
try {
|
|
|
|
id = savedElement.id;
|
|
|
|
} catch (e) {
|
|
|
|
ok(false, "Got exception using DOM element");
|
|
|
|
}
|
|
|
|
is(id, "it_works", "DOM element has expected ID");
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvXrayTest(message) {
|
|
|
|
let element = message.objects.element;
|
|
|
|
is(element.foo, undefined, "DOM element does not expose content properties");
|
|
|
|
}
|
|
|
|
|
2014-10-07 13:29:03 +04:00
|
|
|
function recvSymbolTest(message) {
|
2014-10-16 20:39:38 +04:00
|
|
|
let object = message.objects.object;
|
2014-10-07 13:29:03 +04:00
|
|
|
is(object[Symbol.iterator], Symbol.iterator, "Should use Symbol.iterator");
|
|
|
|
is(Symbol.keyFor(object[Symbol.for("cpow-test")]), "cpow-test", "Symbols aren't registered correctly");
|
2014-10-16 20:39:38 +04:00
|
|
|
let symbols = Object.getOwnPropertySymbols(object);
|
|
|
|
is(symbols.length, 2, "Object should have two symbol keys");
|
|
|
|
let test = undefined;
|
|
|
|
for (let x of message.objects.test) {
|
|
|
|
test = x;
|
|
|
|
}
|
|
|
|
is(test, "a", "for .. of iteration should work");
|
2014-10-07 13:29:03 +04:00
|
|
|
}
|
|
|
|
|
2014-09-13 04:41:19 +04:00
|
|
|
let systemGlobal = this;
|
|
|
|
function recvCompartmentTest(message) {
|
|
|
|
let getUnprivilegedObject = message.objects.getUnprivilegedObject;
|
|
|
|
let testParentObject = message.objects.testParentObject;
|
|
|
|
|
|
|
|
// Make sure that parent->child CPOWs live in the parent's privileged junk scope.
|
|
|
|
let unprivilegedObject = getUnprivilegedObject();
|
|
|
|
is(Cu.getGlobalForObject(getUnprivilegedObject),
|
|
|
|
Cu.getGlobalForObject(unprivilegedObject),
|
|
|
|
"all parent->child CPOWs should live in the same scope");
|
|
|
|
let cpowLocation = Cu.getCompartmentLocation(getUnprivilegedObject);
|
|
|
|
ok(/Privileged Junk/.test(cpowLocation),
|
|
|
|
"parent->child CPOWs should live in the privileged junk scope: " + cpowLocation);
|
|
|
|
|
|
|
|
// Make sure that parent->child CPOWs point through a privileged scope in the child
|
|
|
|
// (the privileged junk scope, but we don't have a good way to test for that
|
|
|
|
// specifically).
|
|
|
|
is(unprivilegedObject.expando, undefined, "parent->child references should get Xrays");
|
2014-09-25 15:13:29 +04:00
|
|
|
is(unprivilegedObject.wrappedJSObject.expando, 42, "parent->child references should get waivable Xrays");
|
2014-09-13 04:41:19 +04:00
|
|
|
|
|
|
|
// Send an object to the child to let it verify invariants in the other direction.
|
|
|
|
function passMe() { return 42; };
|
|
|
|
passMe.expando = 42;
|
|
|
|
let results = testParentObject(passMe);
|
|
|
|
ok(results.length > 0, "Need results");
|
|
|
|
results.forEach((x) => is(x.result, "PASS", x.message));
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:22:16 +04:00
|
|
|
function recvRegExpTest(message) {
|
|
|
|
let regexp = message.objects.regexp;
|
|
|
|
|
|
|
|
// These work generically.
|
|
|
|
is(regexp.toString(), "/myRegExp/g", "toString works right");
|
|
|
|
ok(regexp.test("I like myRegExp to match"), "No false positives");
|
|
|
|
ok(!regexp.test("asdfsdf"), "No false positives");
|
|
|
|
|
|
|
|
// These go over regexp_toShared.
|
|
|
|
is("filler myRegExp filler".search(regexp), 7, "String.prototype.match works right");
|
|
|
|
var shell = /x/;
|
|
|
|
shell.compile(regexp);
|
|
|
|
is(regexp.toString(), shell.toString(), ".compile works right");
|
|
|
|
}
|
|
|
|
|
2014-11-24 02:23:22 +03:00
|
|
|
function recvPostMessageTest(message) {
|
|
|
|
let win = message.objects.win;
|
|
|
|
win.postMessage('nookery', '*');
|
|
|
|
ok(true, "Didn't crash invoking postMessage over CPOW");
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
let savedWilldieObj;
|
2014-08-20 23:49:10 +04:00
|
|
|
let wontDie = {f:2, __exposedProps__: {"f": "r"}};
|
2014-05-17 03:40:37 +04:00
|
|
|
function recvLifetimeTest1(message) {
|
|
|
|
let obj = message.objects.obj;
|
|
|
|
savedWilldieObj = obj.will_die;
|
|
|
|
ok(savedWilldieObj.f == 1, "limited-lifetime CPOW works at first");
|
|
|
|
obj.wont_die = wontDie;
|
|
|
|
obj = null;
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
function recvLifetimeTest2(message) {
|
|
|
|
let threw = false;
|
|
|
|
try {
|
|
|
|
savedWilldieObj.f;
|
|
|
|
} catch (e) {
|
|
|
|
threw = true;
|
|
|
|
}
|
|
|
|
ok(threw, "limited-lifetime CPOW stopped working");
|
|
|
|
wontDie = null;
|
|
|
|
Components.utils.schedulePreciseGC(function() {
|
|
|
|
savedMM.sendAsyncMessage("cpows:lifetime_test_3");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-07-14 00:34:31 +03:00
|
|
|
function recvCancelTest(msg) {
|
|
|
|
let failed = false;
|
|
|
|
try {
|
|
|
|
msg.objects.f();
|
|
|
|
} catch (e if /cross-process JS call failed/.test(String(e))) {
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
ok(failed, "CPOW should fail due to cancelation");
|
|
|
|
msg.target.messageManager.sendAsyncMessage("cpows:cancel_test_done");
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvCancelSyncMessage() {
|
|
|
|
return 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvCancelTest2(msg) {
|
|
|
|
let failed = false;
|
|
|
|
try {
|
|
|
|
msg.objects.f();
|
|
|
|
} catch (e if /cross-process JS call failed/.test(String(e))) {
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
ok(failed, "CPOW should fail due to cancelation");
|
|
|
|
msg.target.messageManager.sendAsyncMessage("cpows:cancel_test2_done");
|
|
|
|
}
|
|
|
|
|
2015-10-24 02:31:54 +03:00
|
|
|
function recvUnsafe(msg) {
|
|
|
|
let failed = false;
|
|
|
|
|
|
|
|
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
|
|
|
|
opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
|
|
|
|
try {
|
|
|
|
msg.objects.f();
|
|
|
|
} catch (e if /unsafe CPOW usage forbidden/.test(String(e))) {
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
|
|
|
|
ok(failed, "CPOW should fail when unsafe");
|
|
|
|
msg.target.messageManager.sendAsyncMessage("cpows:unsafe_done");
|
|
|
|
}
|
|
|
|
|
|
|
|
function recvSafe(msg) {
|
|
|
|
const PREF_UNSAFE_FORBIDDEN = "dom.ipc.cpows.forbid-unsafe-from-browser";
|
|
|
|
opener.wrappedJSObject.SpecialPowers.setBoolPref(PREF_UNSAFE_FORBIDDEN, true);
|
|
|
|
try {
|
|
|
|
msg.objects.f();
|
|
|
|
} catch (e if /unsafe CPOW usage forbidden/.test(String(e))) {
|
|
|
|
ok(false, "cpow failed");
|
|
|
|
}
|
|
|
|
opener.wrappedJSObject.SpecialPowers.clearUserPref(PREF_UNSAFE_FORBIDDEN);
|
|
|
|
msg.target.messageManager.sendAsyncMessage("cpows:safe_done");
|
|
|
|
}
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
function run_tests(type) {
|
2014-05-17 03:40:37 +04:00
|
|
|
info("Running tests: " + type);
|
2013-07-11 02:05:39 +04:00
|
|
|
var node = document.getElementById('cpowbrowser_' + type);
|
|
|
|
|
|
|
|
test_state = type;
|
|
|
|
test_node = node;
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
function recvIsRemote(message) {
|
|
|
|
return type == "remote";
|
|
|
|
}
|
|
|
|
|
2013-07-11 02:05:39 +04:00
|
|
|
var mm = node.messageManager;
|
2014-05-17 03:40:37 +04:00
|
|
|
savedMM = mm;
|
|
|
|
mm.addMessageListener("cpows:is_remote", recvIsRemote);
|
2013-07-11 02:05:39 +04:00
|
|
|
mm.addMessageListener("cpows:async", recvAsyncMessage);
|
|
|
|
mm.addMessageListener("cpows:sync", recvSyncMessage);
|
2013-10-01 20:15:06 +04:00
|
|
|
mm.addMessageListener("cpows:rpc", recvRpcMessage);
|
|
|
|
mm.addMessageListener("cpows:reenter", recvReenterMessage);
|
|
|
|
mm.addMessageListener("cpows:reenter", recvReenterMessage);
|
|
|
|
mm.addMessageListener("cpows:nested_sync", recvNestedSyncMessage);
|
|
|
|
mm.addMessageListener("cpows:reenter_sync", recvReenterSyncMessage);
|
2013-07-11 02:05:39 +04:00
|
|
|
mm.addMessageListener("cpows:done", recvDoneMessage);
|
|
|
|
mm.addMessageListener("cpows:fail", recvFailMessage);
|
2014-05-17 03:40:37 +04:00
|
|
|
mm.addMessageListener("cpows:parent_test", recvParentTest);
|
2014-09-15 16:17:32 +04:00
|
|
|
mm.addMessageListener("cpows:error_reporting_test", recvErrorReportingTest);
|
2014-05-17 03:40:37 +04:00
|
|
|
mm.addMessageListener("cpows:dom_test", recvDomTest);
|
|
|
|
mm.addMessageListener("cpows:dom_test_after_gc", recvDomTestAfterGC);
|
|
|
|
mm.addMessageListener("cpows:xray_test", recvXrayTest);
|
2014-10-16 20:39:38 +04:00
|
|
|
if (typeof Symbol === "function") {
|
|
|
|
mm.addMessageListener("cpows:symbol_test", recvSymbolTest);
|
|
|
|
}
|
2014-09-13 04:41:19 +04:00
|
|
|
mm.addMessageListener("cpows:compartment_test", recvCompartmentTest);
|
2014-10-01 19:22:16 +04:00
|
|
|
mm.addMessageListener("cpows:regexp_test", recvRegExpTest);
|
2014-11-24 02:23:22 +03:00
|
|
|
mm.addMessageListener("cpows:postmessage_test", recvPostMessageTest);
|
2014-05-17 03:40:37 +04:00
|
|
|
mm.addMessageListener("cpows:lifetime_test_1", recvLifetimeTest1);
|
|
|
|
mm.addMessageListener("cpows:lifetime_test_2", recvLifetimeTest2);
|
2015-07-14 00:34:31 +03:00
|
|
|
mm.addMessageListener("cpows:cancel_test", recvCancelTest);
|
|
|
|
mm.addMessageListener("cpows:cancel_sync_message", recvCancelSyncMessage);
|
|
|
|
mm.addMessageListener("cpows:cancel_test2", recvCancelTest2);
|
2015-10-24 02:31:54 +03:00
|
|
|
mm.addMessageListener("cpows:unsafe", recvUnsafe);
|
|
|
|
mm.addMessageListener("cpows:safe", recvSafe);
|
2014-10-25 21:25:22 +04:00
|
|
|
mm.loadFrameScript("chrome://mochitests/content/chrome/dom/base/test/chrome/cpows_child.js", true);
|
2013-07-11 02:05:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function start() {
|
|
|
|
run_tests('remote');
|
|
|
|
}
|
|
|
|
|
|
|
|
function finish() {
|
2014-09-15 16:17:32 +04:00
|
|
|
ok(gReceivedErrorProbe, "Should have reported error probe");
|
2013-07-11 02:05:39 +04:00
|
|
|
opener.setTimeout("done()", 0);
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
]]></script>
|
|
|
|
|
|
|
|
<browser type="content" src="about:blank" id="cpowbrowser_remote" remote="true"/>
|
|
|
|
<browser type="content" src="about:blank" id="cpowbrowser_inprocess"/>
|
|
|
|
</window>
|