summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/test_child_docshell.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/ipc/tests/test_child_docshell.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/ipc/tests/test_child_docshell.html')
-rw-r--r--dom/ipc/tests/test_child_docshell.html86
1 files changed, 86 insertions, 0 deletions
diff --git a/dom/ipc/tests/test_child_docshell.html b/dom/ipc/tests/test_child_docshell.html
new file mode 100644
index 000000000..5855569e8
--- /dev/null
+++ b/dom/ipc/tests/test_child_docshell.html
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+-->
+<head>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.addPermission("browser", true, document);
+SpecialPowers.pushPrefEnv({'set':[
+ ["dom.mozBrowserFramesEnabled", true],
+ ["network.disable.ipc.security", true],
+ ["dom.ipc.tabs.disabled", false]
+]}, function () {
+
+ var iframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe');
+ iframe.setAttribute("remote", "true");
+ SpecialPowers.wrap(iframe).mozbrowser = true;
+ document.documentElement.appendChild(iframe);
+
+ var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
+ mm.addMessageListener("chromeEventHandler", function (msg) {
+ msg = SpecialPowers.wrap(msg);
+ var result = msg.json;
+ is(result.processType, SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT,
+ "The frame script is running in a real distinct child process");
+ ok(result.hasCorrectInterface,
+ "docshell.chromeEventHandler has nsIDOMEventTarget interface");
+ });
+
+
+ mm.addMessageListener("DOMWindowCreatedReceived", function (msg) {
+ msg = SpecialPowers.wrap(msg);
+ ok(true, "the chrome event handler looks functional");
+ var result = msg.json;
+ ok(result.stableChromeEventHandler, "docShell.chromeEventHandler is stable");
+ ok(result.iframeHasNewDocShell, "iframe spawns a new docShell");
+ ok(result.iframeHasSameChromeEventHandler, "but iframe has the same chrome event handler");
+ SimpleTest.finish();
+ });
+ // Inject a frame script in the child process:
+ mm.loadFrameScript('data:,new ' + function ContentScriptScope() {
+ var processType = Components.classes["@mozilla.org/xre/runtime;1"]
+ .getService(Components.interfaces.nsIXULRuntime)
+ .processType;
+ var chromeEventHandler = docShell.chromeEventHandler;
+ sendAsyncMessage("chromeEventHandler", {
+ processType: Services.appinfo.processType,
+ hasCorrectInterface: chromeEventHandler instanceof Components.interfaces.nsIDOMEventTarget
+ });
+
+ /*
+ Ensure that this chromeEventHandler actually works,
+ by creating a new window and listening for its DOMWindowCreated event
+ */
+ chromeEventHandler.addEventListener("DOMWindowCreated", function listener(evt) {
+ if (evt.target == content.document) {
+ return;
+ }
+ chromeEventHandler.removeEventListener("DOMWindowCreated", listener);
+ let new_win = evt.target.defaultView;
+ let new_docShell = new_win.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsIDocShell);
+ sendAsyncMessage("DOMWindowCreatedReceived", {
+ stableChromeEventHandler: chromeEventHandler === docShell.chromeEventHandler,
+ iframeHasNewDocShell: new_docShell !== docShell,
+ iframeHasSameChromeEventHandler: new_docShell.chromeEventHandler === chromeEventHandler
+ });
+ });
+
+ let i = content.document.createElement("iframe");
+ i.setAttribute("src", "data:text/html,foo");
+ content.document.documentElement.appendChild(i);
+ }, false);
+});
+
+</script>
+</body>
+</html>