Bug 1513878 - Part 3: Add getActor test for WindowGlobalParent/WindowGlobalChild. r=nika

Depends on D16845

Differential Revision: https://phabricator.services.mozilla.com/D16846

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Dai 2019-01-28 19:01:40 +00:00
Родитель 7b1dd6aef8
Коммит f2524a5b86
10 изменённых файлов: 128 добавлений и 24 удалений

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

@ -8,3 +8,4 @@ support-files =
skip-if = !e10 # This is an e10s only probe.
[browser_remote_navigation_delay_telemetry.js]
skip-if = !e10s # This is an e10s only probe.
[browser_JSWindowActor.js]

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

@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const URL = "about:blank";
add_task(function test_registerWindowActor() {
let windowActorOptions = {
parent: {
moduleURI: "resource://testing-common/TestParent.jsm",
},
child: {
moduleURI: "resource://testing-common/TestChild.jsm",
},
};
ok(ChromeUtils, "Should be able to get the ChromeUtils interface");
ChromeUtils.registerWindowActor("Test", windowActorOptions);
SimpleTest.doesThrow(() =>
ChromeUtils.registerWindowActor("Test", windowActorOptions),
"Should throw if register has duplicate name.");
});
add_task(async function() {
await BrowserTestUtils.withNewTab({gBrowser, url: URL},
async function(browser) {
let parent = browser.browsingContext.currentWindowGlobal;
isnot(parent, null, "WindowGlobalParent should have value.");
let actorParent = parent.getActor("Test");
is(actorParent.show(), "TestParent", "actor show should have vaule.");
is(actorParent.manager, parent, "manager should match WindowGlobalParent.");
await ContentTask.spawn(
browser, {}, async function() {
let child = content.window.getWindowGlobalChild();
isnot(child, null, "WindowGlobalChild should have value.");
is(child.isInProcess, false, "Actor should be loaded in the content process.");
let actorChild = child.getActor("Test");
is(actorChild.show(), "TestChild", "actor show should have vaule.");
is(actorChild.manager, child, "manager should match WindowGlobalChild.");
});
});
});

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

@ -5,3 +5,4 @@ support-files =
[test_process_error.xul]
skip-if = !crashreporter
[test_JSWindowActor.xul]

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

@ -0,0 +1,42 @@
<?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="Test JSWindowActor"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
let windowActorOptions = {
parent: {
moduleURI: "resource://testing-common/TestParent.jsm",
},
child: {
moduleURI: "resource://testing-common/TestChild.jsm",
},
};
// Test in-process getActor function
ChromeUtils.registerWindowActor("Test", windowActorOptions);
let parent = this.window.docShell.browsingContext.currentWindowGlobal;
isnot(parent, null, "WindowGlobalParent should have value.");
let actorParent = parent.getActor("Test");
is(actorParent.show(), "TestParent", "actor show should have vaule.");
is(actorParent.manager, parent, "manager should match WindowGlobalParent.");
let child = this.window.getWindowGlobalChild();
is(child.isInProcess, true, "Actor should be in-process.");
let actorChild = child.getActor("Test");
is(actorChild.show(), "TestChild", "actor show should have vaule.");
is(actorChild.manager, child, "manager should match WindowGlobalChild.");
ok(parent.childActor===child, "Actor should be the same.");
ok(parent.childActor.getActor("Test")===child.getActor("Test"), "GetActor should be the same.");
]]></script>
</window>

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

@ -1,23 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(function test_registerWindowActor() {
let windowActorOptions = {
parent: {
moduleURI: "resource:///actors/TestParent.jsm",
},
child: {
moduleURI: "resource:///actors/TestChild.jsm",
},
};
Assert.ok(ChromeUtils, "Should be able to get the ChromeUtils interface");
ChromeUtils.registerWindowActor("Test", windowActorOptions);
Assert.ok(true);
Assert.throws(() =>
ChromeUtils.registerWindowActor("Test", windowActorOptions),
/NotSupportedError/,
"Should throw if register duplicate name.");
});

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

@ -1,2 +1 @@
[test_registerWindowActor.js]
[test_sharedMap.js]

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

@ -0,0 +1,17 @@
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["TestChild"];
class TestChild extends JSWindowActorChild {
constructor() {
super();
}
show() {
return "TestChild";
}
}

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

@ -0,0 +1,17 @@
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["TestParent"];
class TestParent extends JSWindowActorParent {
constructor() {
super();
}
show() {
return "TestParent";
}
}

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

@ -10,6 +10,11 @@ with Files('**'):
with Files('Finder*.jsm'):
BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
TESTING_JS_MODULES += [
'TestChild.jsm',
'TestParent.jsm',
]
FINAL_TARGET_FILES.actors += [
'AudioPlaybackChild.jsm',
'AutoplayChild.jsm',

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

@ -306,6 +306,8 @@ module.exports = {
"InstallTriggerImpl": false,
"IntersectionObserver": false,
"IntersectionObserverEntry": false,
"JSWindowActorChild": false,
"JSWindowActorParent": false,
"KeyEvent": false,
"KeyboardEvent": false,
"KeyframeEffect": false,