summaryrefslogtreecommitdiffstats
path: root/dom/xul/test
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/xul/test
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/xul/test')
-rw-r--r--dom/xul/test/1061864.html8
-rw-r--r--dom/xul/test/398289-resource.xul42
-rw-r--r--dom/xul/test/bug497875-iframe.xul6
-rw-r--r--dom/xul/test/chrome.ini40
-rw-r--r--dom/xul/test/file_bug1069772.xul143
-rw-r--r--dom/xul/test/file_bug1271240.xul82
-rw-r--r--dom/xul/test/file_bug236853.rdf14
-rw-r--r--dom/xul/test/mochitest.ini5
-rw-r--r--dom/xul/test/overlay1_bug335375.xul9
-rw-r--r--dom/xul/test/overlay2_bug335375.xul5
-rw-r--r--dom/xul/test/overlay_640158.xul8
-rw-r--r--dom/xul/test/test_bug1061864_1.xul50
-rw-r--r--dom/xul/test/test_bug1061864_2.xul52
-rw-r--r--dom/xul/test/test_bug1069772.xul32
-rw-r--r--dom/xul/test/test_bug1070049_throw_from_script.xul41
-rw-r--r--dom/xul/test/test_bug1271240.xul38
-rw-r--r--dom/xul/test/test_bug1290965.xul39
-rw-r--r--dom/xul/test/test_bug199692.xul98
-rw-r--r--dom/xul/test/test_bug233643.xul76
-rw-r--r--dom/xul/test/test_bug236853.xul37
-rw-r--r--dom/xul/test/test_bug311681.xul106
-rw-r--r--dom/xul/test/test_bug335375.xul50
-rw-r--r--dom/xul/test/test_bug391002.xul41
-rw-r--r--dom/xul/test/test_bug398289.html40
-rw-r--r--dom/xul/test/test_bug403868.xul83
-rw-r--r--dom/xul/test/test_bug414907.xul53
-rw-r--r--dom/xul/test/test_bug418216.xul46
-rw-r--r--dom/xul/test/test_bug445177.xul85
-rw-r--r--dom/xul/test/test_bug449457.xul25
-rw-r--r--dom/xul/test/test_bug468176.xul84
-rw-r--r--dom/xul/test/test_bug486990.xul155
-rw-r--r--dom/xul/test/test_bug497875.xul53
-rw-r--r--dom/xul/test/test_bug583948.xul38
-rw-r--r--dom/xul/test/test_bug640158_overlay_persist.xul51
-rw-r--r--dom/xul/test/test_bug749367.xul39
-rw-r--r--dom/xul/test/test_bug757137.xul52
-rw-r--r--dom/xul/test/test_bug775972.xul35
-rw-r--r--dom/xul/test/test_import_xul_to_content.xul69
-rw-r--r--dom/xul/test/window_bug583948.xul8
-rw-r--r--dom/xul/test/window_bug757137.xul6
40 files changed, 1944 insertions, 0 deletions
diff --git a/dom/xul/test/1061864.html b/dom/xul/test/1061864.html
new file mode 100644
index 000000000..ec8091a6b
--- /dev/null
+++ b/dom/xul/test/1061864.html
@@ -0,0 +1,8 @@
+<html>
+<body>
+<script>
+</script>
+<iframe id="childiframe" src="data:text/html,Test">
+</iframe>
+</body>
+</html>
diff --git a/dom/xul/test/398289-resource.xul b/dom/xul/test/398289-resource.xul
new file mode 100644
index 000000000..71728e58b
--- /dev/null
+++ b/dom/xul/test/398289-resource.xul
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ buttonlabelaccept="OK"
+ ondialogaccept="alert('OK');"
+ buttonlabelcancel="Cancel"
+ ondialogcancel="alert('Cancel');">
+
+ <tabbox id="test" flex="1" persist="selectedIndex">
+
+ <tabs>
+ <tab label="One"/>
+ <tab label="Two"/>
+ </tabs>
+
+ <tabpanels flex="1">
+
+ <vbox flex="1">
+ <description>Text for tab ONE</description>
+ <description class="text-link"
+ onclick="window.open('https://bugzilla.mozilla.org/show_bug.cgi?id=398289');">(test case for bug 398289)</description>
+ <tree>
+ <treecols>
+ <treecol label="Header" flex="1"/>
+ </treecols>
+ </tree>
+ </vbox>
+
+ <vbox flex="1">
+ <description>Text for tab TWO</description>
+ <description>(When the document is reloaded, this content gets replaced by the one from the first tab.)</description>
+ </vbox>
+
+ </tabpanels>
+
+ </tabbox>
+
+ <box height="1000"/> <!-- Push dialog buttons out of sight so that the animated default button isn't part of the snapshot -->
+
+</dialog>
diff --git a/dom/xul/test/bug497875-iframe.xul b/dom/xul/test/bug497875-iframe.xul
new file mode 100644
index 000000000..8365e7df0
--- /dev/null
+++ b/dom/xul/test/bug497875-iframe.xul
@@ -0,0 +1,6 @@
+<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
+<box onerror="document.loadOverlay('file:///does-not-exist', null);" >
+<html:script src="ftp://some.website.that.will.cause.an.error"/>
+</box>
+</window>
diff --git a/dom/xul/test/chrome.ini b/dom/xul/test/chrome.ini
new file mode 100644
index 000000000..d65bf168f
--- /dev/null
+++ b/dom/xul/test/chrome.ini
@@ -0,0 +1,40 @@
+[DEFAULT]
+support-files =
+ 398289-resource.xul
+ bug497875-iframe.xul
+ file_bug236853.rdf
+ overlay1_bug335375.xul
+ overlay2_bug335375.xul
+ window_bug583948.xul
+ window_bug757137.xul
+ 1061864.html
+ file_bug1271240.xul
+ file_bug1069772.xul
+
+[test_bug199692.xul]
+[test_bug233643.xul]
+[test_bug236853.xul]
+[test_bug311681.xul]
+[test_bug335375.xul]
+[test_bug391002.xul]
+[test_bug398289.html]
+[test_bug403868.xul]
+[test_bug414907.xul]
+[test_bug418216.xul]
+[test_bug445177.xul]
+[test_bug449457.xul]
+[test_bug468176.xul]
+[test_bug497875.xul]
+[test_bug583948.xul]
+[test_bug640158_overlay_persist.xul]
+[test_bug757137.xul]
+[test_bug775972.xul]
+[test_bug1061864_1.xul]
+[test_bug1061864_2.xul]
+[test_bug1070049_throw_from_script.xul]
+[test_import_xul_to_content.xul]
+[test_bug1271240.xul]
+skip-if = os == "android"
+[test_bug1069772.xul]
+skip-if = os == "android"
+[test_bug1290965.xul]
diff --git a/dom/xul/test/file_bug1069772.xul b/dom/xul/test/file_bug1069772.xul
new file mode 100644
index 000000000..b90985246
--- /dev/null
+++ b/dom/xul/test/file_bug1069772.xul
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1069772
+-->
+<window title="Mozilla Bug 1069772"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="run();">
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
+ Cu.import("resource://testing-common/ContentTask.jsm");
+ Cu.import("resource://testing-common/BrowserTestUtils.jsm");
+ Cu.import("resource://gre/modules/Services.jsm");
+ ContentTask.setTestScope(window.opener.wrappedJSObject);
+
+ let imports = ['SimpleTest', 'ok', 'is'];
+ for (let name of imports) {
+ window[name] = window.opener.wrappedJSObject[name];
+ }
+
+ /** Test for Bug 1069772 **/
+ function run() {
+ // test the transition:
+ // prerender => visible => hidden => visible
+ // on a non-remote browser
+ createPrerenderedBrowser(false)
+ .then(browser => verifyBrowser(browser, true, false))
+ .then(browser => verifyVisibility(browser, 'prerender'))
+ .then(browser => makePrerenderedBrowserActive(browser))
+ .then(browser => verifyBrowser(browser, false, false))
+ .then(browser => verifyVisibility(browser, 'visible'))
+ .then(browser => hideBrowser(browser))
+ .then(browser => verifyBrowser(browser, false, false))
+ .then(browser => verifyVisibility(browser, 'hidden'))
+ .then(browser => showBrowser(browser))
+ .then(browser => verifyBrowser(browser, false, false))
+ .then(browser => verifyVisibility(browser, 'visible'))
+
+ // test the transition:
+ // prerender => visible => hidden => visible
+ // on a remote browser
+ .then(() => createPrerenderedBrowser(true))
+ .then(browser => verifyBrowser(browser, true, true))
+ .then(browser => verifyVisibility(browser, 'prerender'))
+ .then(browser => makePrerenderedBrowserActive(browser))
+ .then(browser => verifyBrowser(browser, false, true))
+ .then(browser => verifyVisibility(browser, 'visible'))
+ .then(browser => hideBrowser(browser))
+ .then(browser => verifyBrowser(browser, false, true))
+ .then(browser => verifyVisibility(browser, 'hidden'))
+ .then(browser => showBrowser(browser))
+ .then(browser => verifyBrowser(browser, false, true))
+ .then(browser => verifyVisibility(browser, 'visible'))
+
+ // finish test
+ .then(() => {
+ window.close();
+ SimpleTest.finish();
+ });
+ }
+
+ function createPrerenderedBrowser(remote) {
+ let browser = document.createElement('browser');
+ browser.setAttribute('type', 'content');
+ browser.setAttribute('prerendered', true);
+ browser.setAttribute('remote', remote);
+ browser.setAttribute('src', 'data:text/html;charset=UTF-8,<html><body>' +
+ '<iframe id="iframe" src="data:text/html;charset=UTF-8,Hello Frame!">' +
+ '</iframe></body></html>');
+
+ // wait for 'load' and 'pageshow'
+ let promises = [];
+ promises.push(BrowserTestUtils.browserLoaded(browser));
+ promises.push(new Promise(resolve =>
+ Services.mm.addMessageListener('test:pageshow', resolve)));
+ Services.mm.loadFrameScript('data:,' +
+ 'addEventListener("pageshow", ' +
+ '() => sendAsyncMessage("test:pageshow", null), false);',
+ true);
+
+ document.getElementById('stack').appendChild(browser);
+ return Promise.all(promises).then(() => browser);
+ }
+
+ function verifyBrowser(browser, prerendered, remote) {
+ let docShellOrTabParent = remote ?
+ browser.frameLoader.tabParent : browser.frameLoader.docShell;
+ ok(docShellOrTabParent, 'docShellOrTabParent should not be null');
+ is(docShellOrTabParent.isPrerendered, prerendered,
+ 'isPrerendered should be ' + prerendered);
+ return browser;
+ }
+
+ function verifyVisibility(browser, visibility) {
+ return ContentTask.spawn(browser, visibility, (v) => {
+ let iframe = content.document.getElementById('iframe');
+ is(content.document.visibilityState, v, 'check doc.visibilityState');
+ is(content.document.hidden, v != 'visible', 'check doc.hidden');
+ is(iframe.contentDocument.visibilityState, v, 'check iframe doc.visibilityState');
+ is(iframe.contentDocument.hidden, v != 'visible', 'check iframe doc.hidden');
+ }).then(() => browser);
+ }
+
+ function makePrerenderedBrowserActive(browser) {
+ let promise = waitForVisibilityChange(browser);
+ browser.setAttribute('prerendered', false);
+ browser.makePrerenderedBrowserActive();
+ return promise.then(() => browser);
+ }
+
+ function hideBrowser(browser) {
+ let promise = waitForVisibilityChange(browser);
+ browser.docShellIsActive = false;
+ return promise.then(() => browser);
+ }
+
+ function showBrowser(browser) {
+ let promise = waitForVisibilityChange(browser);
+ browser.docShellIsActive = true;
+ return promise.then(() => browser);
+ }
+
+ function waitForVisibilityChange(browser) {
+ return ContentTask.spawn(browser, null, () => {
+ return new Promise(resolve => {
+ let iframe = content.document.getElementById('iframe');
+ iframe.contentDocument.addEventListener('visibilitychange', function listener() {
+ iframe.contentDocument.removeEventListener('visibilitychange', listener);
+ resolve();
+ });
+ });
+ });
+ }
+
+ ]]>
+ </script>
+ <stack id="stack" flex="1" />
+</window>
diff --git a/dom/xul/test/file_bug1271240.xul b/dom/xul/test/file_bug1271240.xul
new file mode 100644
index 000000000..2edd5a1b4
--- /dev/null
+++ b/dom/xul/test/file_bug1271240.xul
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1271240
+-->
+<window title="Mozilla Bug 1271240"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="run();">
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ function ok(cond, msg) {
+ opener.wrappedJSObject.ok(cond, msg);
+ }
+
+ function is(actual, expected, msg) {
+ opener.wrappedJSObject.is(actual, expected, msg);
+ }
+
+ /** Test for Bug 1271240 **/
+ function run() {
+ // test non-remote, non-prerendered browser
+ createBrowser(false, false)
+ .then(browser => verifyBrowser(browser, false, false))
+
+ // test non-remote, prerendered browser
+ .then(() => createBrowser(true, false))
+ .then(browser => verifyBrowser(browser, true, false))
+ .then(browser => makePrerenderedBrowserActive(browser))
+ .then(browser => verifyBrowser(browser, false, false))
+
+ // test remote, non-prerendered browser
+ .then(() => createBrowser(false, true))
+ .then(browser => verifyBrowser(browser, false, true))
+
+ // test remote, prerendered browser
+ .then(() => createBrowser(true, true))
+ .then(browser => verifyBrowser(browser, true, true))
+ .then(browser => makePrerenderedBrowserActive(browser))
+ .then(browser => verifyBrowser(browser, false, true))
+
+ // finish test
+ .then(() => {
+ opener.postMessage('finish', '*');
+ window.close();
+ });
+ }
+
+ function createBrowser(prerendered, remote) {
+ return new Promise(resolve => {
+ var browser = document.createElement('browser');
+ browser.setAttribute('type', 'content');
+ browser.setAttribute('prerendered', prerendered);
+ browser.setAttribute('remote', remote);
+ document.documentElement.appendChild(browser);
+ browser.loadURI('example.com');
+ resolve(browser);
+ });
+ }
+
+ function verifyBrowser(browser, prerendered, remote) {
+ var docShellOrTabParent = remote ?
+ browser.frameLoader.tabParent : browser.frameLoader.docShell;
+ ok(docShellOrTabParent, 'docShellOrTabParent should not be null');
+ is(docShellOrTabParent.isPrerendered, prerendered,
+ 'isPrerendered should be ' + prerendered);
+ return browser;
+ }
+
+ function makePrerenderedBrowserActive(browser) {
+ browser.makePrerenderedBrowserActive();
+ return browser;
+ }
+
+ ]]>
+ </script>
+ <!-- <browser type="content-primary" flex="1" id="content" />
+ <browser type="content-primary" flex="1" id="content-remote" remote="true" /> -->
+</window>
diff --git a/dom/xul/test/file_bug236853.rdf b/dom/xul/test/file_bug236853.rdf
new file mode 100644
index 000000000..8d17bf691
--- /dev/null
+++ b/dom/xul/test/file_bug236853.rdf
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:ex="http://www.ex.org/ex-rdf#">
+
+ <rdf:Description about="urn:root">
+ <ex:nodes>
+ <rdf:Bag about="http://www.ex.org/nodes">
+ <rdf:li>
+ <rdf:Description about="http://www.ex.org/nodes/A"/>
+ </rdf:li>
+ </rdf:Bag>
+ </ex:nodes>
+ </rdf:Description>
+</rdf:RDF>
diff --git a/dom/xul/test/mochitest.ini b/dom/xul/test/mochitest.ini
new file mode 100644
index 000000000..4ef4e2b99
--- /dev/null
+++ b/dom/xul/test/mochitest.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+
+[test_bug486990.xul]
+skip-if = toolkit == 'android' #TIMED_OUT
+[test_bug749367.xul]
diff --git a/dom/xul/test/overlay1_bug335375.xul b/dom/xul/test/overlay1_bug335375.xul
new file mode 100644
index 000000000..a3448b7f8
--- /dev/null
+++ b/dom/xul/test/overlay1_bug335375.xul
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<overlay id="overlay1"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <commandset id="test_commandset">
+ <command id="cmd_test"/>
+ </commandset>
+ <toolbarbutton id="button_test"
+ command="cmd_test"/>
+</overlay>
diff --git a/dom/xul/test/overlay2_bug335375.xul b/dom/xul/test/overlay2_bug335375.xul
new file mode 100644
index 000000000..cb37db642
--- /dev/null
+++ b/dom/xul/test/overlay2_bug335375.xul
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<overlay id="overlay2"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <command id="cmd_test" accesskey="C"/>
+</overlay>
diff --git a/dom/xul/test/overlay_640158.xul b/dom/xul/test/overlay_640158.xul
new file mode 100644
index 000000000..536beb529
--- /dev/null
+++ b/dom/xul/test/overlay_640158.xul
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<overlay id="overlay1"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <window id="rootwin">
+ <box id="bar" testattr="original"/>
+ </window>
+</overlay>
+
diff --git a/dom/xul/test/test_bug1061864_1.xul b/dom/xul/test/test_bug1061864_1.xul
new file mode 100644
index 000000000..8fe3b8e30
--- /dev/null
+++ b/dom/xul/test/test_bug1061864_1.xul
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1061864
+-->
+<window title="Mozilla Bug 1061864"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="RunTest();">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1061864 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function RunTest()
+ {
+ // Test that the docshell belonging to a prerendered frame loader will
+ // be created with the correct prerendered flag.
+ test(false, function() {
+ test(true, function() {
+ SimpleTest.finish();
+ });
+ });
+ }
+
+ function test(prerendered, callback) {
+ var parentIframe = document.createElement("iframe");
+ if (prerendered) {
+ parentIframe.setIsPrerendered();
+ }
+ parentIframe.onload = function() {
+ var docShell = parentIframe.frameLoader.docShell;
+ is(docShell.isPrerendered, prerendered, "The docshell is" + (prerendered ? "" : " not") + " prerendered");
+ callback();
+ }
+ document.documentElement.appendChild(parentIframe);
+ }
+ ]]>
+ </script>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1061864"
+ target="_blank">Mozilla Bug 1061864</a>
+ </body>
+</window>
diff --git a/dom/xul/test/test_bug1061864_2.xul b/dom/xul/test/test_bug1061864_2.xul
new file mode 100644
index 000000000..e7ed5a630
--- /dev/null
+++ b/dom/xul/test/test_bug1061864_2.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1061864
+-->
+<window title="Mozilla Bug 1061864"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="RunTest();">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1061864 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function RunTest()
+ {
+ // Test that the docshell prerendered flag will be correctly inherited in
+ // prerendered documents.
+ test(false, function() {
+ test(true, function() {
+ SimpleTest.finish();
+ });
+ });
+ }
+
+ function test(prerendered, callback) {
+ var parentIframe = document.createElement("iframe");
+ if (prerendered) {
+ parentIframe.setIsPrerendered();
+ }
+ parentIframe.setAttribute("src", "1061864.html");
+ parentIframe.onload = function() {
+ var childIframe = parentIframe.contentDocument.getElementById("childiframe");
+ var childDocShell = childIframe.frameLoader.docShell;
+ is(childDocShell.isPrerendered, prerendered, "The docshell is" + (prerendered ? "" : " not") + " prerendered");
+ callback();
+ }
+ document.documentElement.appendChild(parentIframe);
+ }
+ ]]>
+ </script>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1061864"
+ target="_blank">Mozilla Bug 1061864</a>
+ </body>
+</window>
diff --git a/dom/xul/test/test_bug1069772.xul b/dom/xul/test/test_bug1069772.xul
new file mode 100644
index 000000000..173113fdb
--- /dev/null
+++ b/dom/xul/test/test_bug1069772.xul
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1069772
+-->
+<window title="Mozilla Bug 1069772"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="loadTest();">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069772"
+ target="_blank">Mozilla Bug 1069772</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1069772 **/
+ SimpleTest.waitForExplicitFinish();
+ function loadTest() {
+ window.open("file_bug1069772.xul", "", "width=360,height=240,chrome");
+ }
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/test_bug1070049_throw_from_script.xul b/dom/xul/test/test_bug1070049_throw_from_script.xul
new file mode 100644
index 000000000..baa04a89e
--- /dev/null
+++ b/dom/xul/test/test_bug1070049_throw_from_script.xul
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1070049
+-->
+<window title="Mozilla Bug 1070049"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1070049 **/
+ SimpleTest.waitForExplicitFinish();
+ addLoadEvent(function() {
+ // Prevent the test from failing when the exception hits onerror.
+ SimpleTest.expectUncaughtException();
+
+ // Tell the test to expect exactly one console error with the given parameters,
+ // with SimpleTest.finish as a continuation function.
+ SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('flimfniffle')}]);
+
+ // Schedule the console accounting (and continuation) to run next, right
+ // after we throw (below).
+ SimpleTest.executeSoon(SimpleTest.endMonitorConsole);
+
+ // Throw.
+ throw "flimfniffle";
+ });
+ ]]>
+ </script>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1070049"
+ target="_blank">Mozilla Bug 1070049</a>
+ </body>
+</window>
diff --git a/dom/xul/test/test_bug1271240.xul b/dom/xul/test/test_bug1271240.xul
new file mode 100644
index 000000000..cfba37523
--- /dev/null
+++ b/dom/xul/test/test_bug1271240.xul
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1271240
+-->
+<window title="Mozilla Bug 1271240"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="loadTest();">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1271240"
+ target="_blank">Mozilla Bug 1271240</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1271240 **/
+ SimpleTest.waitForExplicitFinish();
+ window.addEventListener('message', (event) => {
+ if (event.data == 'finish') {
+ SimpleTest.finish();
+ }
+ });
+
+ function loadTest() {
+ window.open("file_bug1271240.xul", "", "chrome");
+ }
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/test_bug1290965.xul b/dom/xul/test/test_bug1290965.xul
new file mode 100644
index 000000000..8701b55be
--- /dev/null
+++ b/dom/xul/test/test_bug1290965.xul
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml">
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+ <toolbarbutton oncommand="++countera;" id="a">A</toolbarbutton>
+ <toolbarbutton oncommand="++counterb;" id="b">B</toolbarbutton>
+ <script type="text/javascript">
+ <![CDATA[
+ let aEl = document.getElementById('a');
+ let bEl = document.getElementById('b');
+ let countera = 0;
+ let counterb = 0;
+
+ aEl.addEventListener('click', function (aEvent) {
+ aEvent.preventDefault();
+ let cmdEvent = document.createEvent("xulcommandevent");
+ cmdEvent.initCommandEvent("command", true, true, window, 0,
+ aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
+ aEvent.metaKey, null);
+ aEvent.currentTarget.dispatchEvent(cmdEvent);
+ });
+
+ bEl.addEventListener('click', function (aEvent) {
+ let cmdEvent = document.createEvent("xulcommandevent");
+ cmdEvent.initCommandEvent("command", true, true, window, 0,
+ aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
+ aEvent.metaKey, null);
+ aEvent.currentTarget.dispatchEvent(cmdEvent);
+ });
+
+ bEl.click();
+ aEl.click();
+
+ is(countera, 1, "Counter should be one as event fires once");
+ is(counterb, 2, "Counter should be two as event fires twice");
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/test_bug199692.xul b/dom/xul/test/test_bug199692.xul
new file mode 100644
index 000000000..69a400a2a
--- /dev/null
+++ b/dom/xul/test/test_bug199692.xul
@@ -0,0 +1,98 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=199692
+-->
+<window title="Test for Bug 199692"
+ id="test_bug199692_xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <vbox hidden="true">
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <binding id="anon">
+ <content>
+ <xul:label id="anon-label" value="ANON"/>
+ </content>
+ </binding>
+ </bindings>
+ </vbox>
+
+<body id="body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=199692">Mozilla Bug 199692</a>
+
+<vbox id="content" style="position: relative;"
+xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <xul:label id="non-anon-label" value="a textbox!:" control="textbox"/>
+ <xul:textbox id="textbox" multiline="true" rows="4" />
+ <xul:radiogroup style="outline: 2px solid orange;">
+ <xul:radio id="unselected-radio" label="Orange" style="outline: 2px solid red;"/>
+ <xul:radio id="selected-radio" label="Violet" selected="true"/>
+ <xul:radio id="disabled-radio" label="Yellow" disabled="true"/>
+ </xul:radiogroup>
+ <hbox id="bound" style="-moz-binding:url('#anon'); border: 2px solid green;"></hbox>
+</vbox>
+<pre id="test">
+ <script class="testbody" type="text/javascript">
+<![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ // Before onload, XUL docs have no root frame.
+ is(document.elementFromPoint(10,10), null,
+ "Calls to elementFromPoint before onload should return null");
+
+ var d = 10;
+ function middle(e) {
+ return { "x": e.boxObject.x + e.boxObject.width/2,
+ "y": e.boxObject.y + e.boxObject.height/2 };
+ }
+ function lower_right(e) {
+ return { "x": e.boxObject.x + e.boxObject.width - d,
+ "y": e.boxObject.y + e.boxObject.height - d };
+ }
+ function upper_left(e) {
+ return { "x": e.boxObject.x + d,
+ "y": e.boxObject.y + d };
+ }
+ function scrollbar_button(e) { // a bit down from upper right
+ return { "x": e.boxObject.x + e.boxObject.width - d,
+ "y": e.boxObject.y + d + 15 };
+ }
+
+ function test(ptFunc, id, message) {
+ var pt = ptFunc($(id));
+ var e = document.elementFromPoint(pt.x, pt.y);
+ ok(e != null, message + " (returned null)");
+ is(e.id, id, message);
+ }
+
+ function do_test() {
+ // Avoid hardcoding x,y pixel values, to better deal with differing default
+ // font sizes or other layout defaults.
+
+ test(middle, 'textbox', "Point within textbox should return textbox element");
+ test(lower_right, 'textbox', "Point on textbox's scrollbar should return textbox element");
+ test(scrollbar_button, 'textbox', "Point on textbox's scrollbar button should return textbox element");
+ test(middle, 'non-anon-label', "Point on label should return label");
+ test(upper_left, 'bound', "Point on XBL content should return element with -moz-binding style");
+
+ SimpleTest.finish();
+ }
+ $("textbox").setAttribute("value",
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet " +
+ "lorem ipsum dolor sit amet "); // force scrollbars to appear
+ addLoadEvent(do_test);
+]]>
+ </script>
+</pre>
+</body>
+</window>
diff --git a/dom/xul/test/test_bug233643.xul b/dom/xul/test/test_bug233643.xul
new file mode 100644
index 000000000..a1cf22bc8
--- /dev/null
+++ b/dom/xul/test/test_bug233643.xul
@@ -0,0 +1,76 @@
+<?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 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="Test for Bug 233643">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=233643
+-->
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <!-- NOTE: This testcase depends on the patch for bug 366770
+ (ability to apply bindings with data: URIs). -->
+
+ <!-- The data URI: below corresponds to:
+ <?xml version="1.0"?>
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <binding id="label">
+ <content>
+ <xul:label anonid="foo" style="display: none; color: green;" value="PASS"/>
+ </content>
+ <implementation>
+ <property name="fooDisplay">
+ <setter>document.getAnonymousElementByAttribute(this, "anonid", "foo").style.display = val;</setter>
+ <getter>return document.getAnonymousElementByAttribute(this, "anonid", "foo").style.display;</getter>
+ </property>
+ </implementation>
+ </binding>
+ </bindings>
+ -->
+ <html:style type="text/css">
+ foo {
+ -moz-binding: url(data:text/xml,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%0A%20%20%20%20%20%20%20%20%20%20xmlns%3Axul%3D%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%3E%0A%20%20%3Cbinding%20id%3D%22label%22%3E%0A%20%20%20%20%3Ccontent%3E%0A%20%20%20%20%20%20%3Cxul%3Alabel%20anonid%3D%22foo%22%20style%3D%22display%3A%20none%3B%20color%3A%20green%3B%22%20value%3D%22PASS%22/%3E%0A%20%20%20%20%3C/content%3E%0A%20%20%20%20%3Cimplementation%3E%0A%20%20%20%20%20%20%3Cproperty%20name%3D%22fooDisplay%22%3E%0A%20%20%20%20%20%20%20%20%3Csetter%3Edocument.getAnonymousElementByAttribute%28this%2C%20%22anonid%22%2C%20%22foo%22%29.style.display%20%3D%20val%3B%3C/setter%3E%0A%20%20%20%20%20%20%20%20%3Cgetter%3Ereturn%20document.getAnonymousElementByAttribute%28this%2C%20%22anonid%22%2C%20%22foo%22%29.style.display%3B%3C/getter%3E%0A%20%20%20%20%20%20%3C/property%3E%0A%20%20%20%20%3C/implementation%3E%0A%20%20%3C/binding%3E%0A%3C/bindings%3E);
+ }
+ </html:style>
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=233643">Mozilla Bug 233643</a>
+ <p id="display">
+ <foo xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
+ <foo xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
+ </p>
+ <div id="content" style="display: none">
+ <script class="testbody" type="text/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ function test_233643() {
+ var foos = document.getElementsByTagName("foo");
+ ok(foos.length == 2, "Found 2 <foo> elements");
+
+ // Make sure that the binding was applied successfully
+ ok(foos[0].fooDisplay !== undefined, "Binding applied");
+
+ // Show both both child elements by setting their display to "".
+ foos[0].fooDisplay = "";
+ foos[1].fooDisplay = "";
+
+ // Hide the second one. In a build with bug 233643, this hides both.
+ foos[1].fooDisplay = "none";
+
+ // Check that changing the second didn't affect the first.
+ ok(foos[0].fooDisplay != foos[1].fooDisplay, "XUL Element have their own style rules");
+
+ SimpleTest.finish();
+ }
+
+ function do_test() {
+ setTimeout(test_233643, 0);
+ }
+ addLoadEvent(do_test);
+ ]]>
+ </script>
+ </div>
+ </body>
+</window>
diff --git a/dom/xul/test/test_bug236853.xul b/dom/xul/test/test_bug236853.xul
new file mode 100644
index 000000000..9b79deb75
--- /dev/null
+++ b/dom/xul/test/test_bug236853.xul
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<window
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ window.onload = function() {
+ ok(true, "Didn't crash");
+ SimpleTest.finish();
+ }
+ ]]>
+ </script>
+ <vbox flex="1">
+ <svg:svg datasources="file_bug236853.rdf" ref="urn:root">
+ <template>
+ <rule>
+ <conditions>
+ <content uri="?root"/>
+ <triple subject="?root"
+ predicate="http://www.ex.org/ex-rdf#nodes"
+ object="?nodes"/>
+ <member container="?nodes" child="?node"/>
+ </conditions>
+ <action>
+ <!-- The line below causes Mozilla to crash -->
+ <svg:text uri="?node" x="64" y="64">Text</svg:text>
+ </action>
+ </rule>
+ </template>
+ <!--<svg:text x="64" y="64">Text</svg:text>-->
+ </svg:svg>
+ </vbox>
+</window>
diff --git a/dom/xul/test/test_bug311681.xul b/dom/xul/test/test_bug311681.xul
new file mode 100644
index 000000000..2774d8731
--- /dev/null
+++ b/dom/xul/test/test_bug311681.xul
@@ -0,0 +1,106 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=311681
+-->
+<window title="Mozilla Bug 311681"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
+<script class="testbody" type="text/javascript">
+<![CDATA[
+ // Setup script
+ SimpleTest.waitForExplicitFinish();
+
+ // Make sure to trigger the hashtable case by asking for enough elements
+ // by ID.
+ for (var i = 0; i < 256; ++i) {
+ var x = document.getElementById(i);
+ }
+
+ // save off the document.getElementById function, since getting it as a
+ // property off the document it causes a content flush.
+ var fun = document.getElementById;
+
+ // Slot for our initial element with id "content"
+ var testNode;
+
+ function getCont() {
+ return fun.call(document, "content");
+ }
+
+ function testClone() {
+ // Test to make sure that if we have multiple nodes with the same ID in
+ // a document we don't forget about one of them when the other is
+ // removed.
+ var newParent = $("display");
+ var node = testNode.cloneNode(true);
+ isnot(node, testNode, "Clone should be a different node");
+
+ newParent.appendChild(node);
+
+ // Check what getElementById returns, no flushing
+ is(getCont(), node, "Should be getting new node pre-flush 1")
+
+ // Trigger a layout flush, just in case.
+ var itemHeight = newParent.offsetHeight/10;
+
+ // Check what getElementById returns now.
+ is(getCont(), node, "Should be getting new node post-flush 1")
+
+ clear(newParent);
+
+ // Check what getElementById returns, no flushing
+ is(getCont(), testNode, "Should be getting orig node pre-flush 2");
+
+ // Trigger a layout flush, just in case.
+ var itemHeight = newParent.offsetHeight/10;
+
+ // Check what getElementById returns now.
+ is(getCont(), testNode, "Should be getting orig node post-flush 2");
+
+ node = testNode.cloneNode(true);
+ newParent.appendChild(node);
+ testNode.parentNode.removeChild(testNode);
+
+ // Check what getElementById returns, no flushing
+ is(getCont(), node, "Should be getting clone pre-flush");
+
+ // Trigger a layout flush, just in case.
+ var itemHeight = newParent.offsetHeight/10;
+
+ // Check what getElementById returns now.
+ is(getCont(), node, "Should be getting clone post-flush");
+
+ }
+
+ function clear(node) {
+ while (node.hasChildNodes()) {
+ node.removeChild(node.firstChild);
+ }
+ }
+
+ addLoadEvent(testClone);
+ addLoadEvent(SimpleTest.finish);
+]]>
+</script>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <script class="testbody" type="text/javascript">
+ <![CDATA[
+ testNode = fun.call(document, "content");
+ // Needs incremental XML parser
+ isnot(testNode, null, "Should have node here");
+ ]]>
+ </script>
+</div>
+<pre id="test">
+</pre>
+</body>
+
+</window>
diff --git a/dom/xul/test/test_bug335375.xul b/dom/xul/test/test_bug335375.xul
new file mode 100644
index 000000000..20b8dd1d2
--- /dev/null
+++ b/dom/xul/test/test_bug335375.xul
@@ -0,0 +1,50 @@
+<?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"?>
+<?xul-overlay href="overlay1_bug335375.xul"?>
+<?xul-overlay href="overlay2_bug335375.xul"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=335375
+-->
+<window title="Mozilla Bug 335375"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="RunTest();">
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <script type="application/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ function RunTest()
+ {
+ var cmd = document.getElementById("cmd_test");
+ var button = document.getElementById("button_test");
+
+ is(cmd.getAttribute("accesskey"), "C",
+ "checking command has an accesskey");
+ is(button.getAttribute("accesskey"), cmd.getAttribute("accesskey"),
+ "checking command and button have the same accesskey");
+
+ cmd.setAttribute("accesskey", "D");
+ is(button.getAttribute("accesskey"), "D",
+ "checking button has inherited new accesskey from command");
+
+ SimpleTest.finish();
+ }
+ ]]>
+ </script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=335375"
+ target="_blank">Mozilla Bug 335375</a>
+ <p id="display"></p>
+ <div id="content" style="display: none"></div>
+ <pre id="test"></pre>
+ </body>
+
+ <commandset id="test_commandset"/>
+ <toolbarbutton id="button_test"/>
+
+</window>
diff --git a/dom/xul/test/test_bug391002.xul b/dom/xul/test/test_bug391002.xul
new file mode 100644
index 000000000..9387caeaf
--- /dev/null
+++ b/dom/xul/test/test_bug391002.xul
@@ -0,0 +1,41 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=391002
+-->
+<window title="Mozilla Bug 391002"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=391002"
+ target="_blank">Mozilla Bug 391002</a>
+ </body>
+
+ <button id="btn1" command="cmd1"/>
+
+ <button id="btn2">
+ <observes id="observes" element="cmd1" attribute="label"/>
+ </button>
+
+ <commandset>
+ <command id="cmd1" label="cmd1"/>
+ <command id="cmd2" label="cmd2"/>
+ </commandset>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ /** Test for Bug 391002 **/
+
+ $("btn1").setAttribute("command", "cmd2");
+ is($("btn1").getAttribute("label"), $("cmd2").getAttribute("label"))
+
+ $("observes").setAttribute("element", "cmd2");
+ is($("btn2").getAttribute("label"), $("cmd2").getAttribute("label"))
+
+ ]]></script>
+</window>
+
diff --git a/dom/xul/test/test_bug398289.html b/dom/xul/test/test_bug398289.html
new file mode 100644
index 000000000..4fc36c923
--- /dev/null
+++ b/dom/xul/test/test_bug398289.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html style="height: 100%">
+<head>
+ <title>Test for bug 398289</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+</head>
+<body style="height: 100%" onload="setTimeout(onBodyLoad, 0);">
+ <iframe id="test" src="398289-resource.xul" width="100%" height="100%">
+ </iframe>
+
+ <script class="testbody" type="text/javascript">
+ var snap1, snap2;
+
+ SimpleTest.waitForExplicitFinish();
+
+ function onBodyLoad() {
+ window.frames[0].document.getElementById("test").selectedIndex = 0;
+ window.frames[0].document.getElementById("test").selectedIndex = 1;
+
+ snap1 = snapshotWindow(window);
+
+ document.getElementById("test").onload = onFrameLoad;
+ window.frames[0].location.reload();
+ }
+
+ function onFrameLoad() {
+ snap2 = snapshotWindow(window);
+
+ var equal, str1, str2;
+ [equal, str1, str2] = compareSnapshots(snap1, snap2, true);
+
+ ok(equal, "persistent attribute in tab box broken, expected: "+str1+" got: "+str2);
+
+ SimpleTest.finish();
+ }
+ </script>
+</body>
+</html>
diff --git a/dom/xul/test/test_bug403868.xul b/dom/xul/test/test_bug403868.xul
new file mode 100644
index 000000000..e82c1f62b
--- /dev/null
+++ b/dom/xul/test/test_bug403868.xul
@@ -0,0 +1,83 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=403868
+-->
+<window title="Mozilla Bug 403868"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868"
+ target="_blank">Mozilla Bug 403868</a>
+ <div id="content" style="display: none"/>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ /** Test for Bug 403868 **/
+function createSpan(id, insertionPoint) {
+ var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
+ s.id = id;
+ $("content").insertBefore(s, insertionPoint);
+ return s;
+}
+
+var s1a = createSpan("test1", null);
+is(document.getElementById("test1"), s1a,
+ "Only one span with id=test1 in the tree; should work!");
+
+var s2a = createSpan("test1", null);
+is(document.getElementById("test1"), s1a,
+ "Appending span with id=test1 doesn't change which one comes first");
+
+var s3a = createSpan("test1", s2a);
+is(document.getElementById("test1"), s1a,
+ "Inserting span with id=test1 not at the beginning; doesn't matter");
+
+var s4a = createSpan("test1", s1a);
+is(document.getElementById("test1"), s4a,
+ "Inserting span with id=test1 at the beginning changes which one is first");
+
+s4a.parentNode.removeChild(s4a);
+is(document.getElementById("test1"), s1a,
+ "First-created span with id=test1 is first again");
+
+s1a.parentNode.removeChild(s1a);
+is(document.getElementById("test1"), s3a,
+ "Third-created span with id=test1 is first now");
+
+// Start the id hashtable
+for (var i = 0; i < 256; ++i) {
+ document.getElementById("no-such-id-in-the-document" + i);
+}
+
+var s1b = createSpan("test2", null);
+is(document.getElementById("test2"), s1b,
+ "Only one span with id=test2 in the tree; should work!");
+
+var s2b = createSpan("test2", null);
+is(document.getElementById("test2"), s1b,
+ "Appending span with id=test2 doesn't change which one comes first");
+
+var s3b = createSpan("test2", s2b);
+is(document.getElementById("test2"), s1b,
+ "Inserting span with id=test2 not at the beginning; doesn't matter");
+
+var s4b = createSpan("test2", s1b);
+is(document.getElementById("test2"), s4b,
+ "Inserting span with id=test2 at the beginning changes which one is first");
+
+s4b.parentNode.removeChild(s4b);
+is(document.getElementById("test2"), s1b,
+ "First-created span with id=test2 is first again");
+
+s1b.parentNode.removeChild(s1b);
+is(document.getElementById("test2"), s3b,
+ "Third-created span with id=test2 is first now");
+
+ ]]></script>
+</window>
diff --git a/dom/xul/test/test_bug414907.xul b/dom/xul/test/test_bug414907.xul
new file mode 100644
index 000000000..cc4ecedeb
--- /dev/null
+++ b/dom/xul/test/test_bug414907.xul
@@ -0,0 +1,53 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=414907
+-->
+<window title="Mozilla Bug 414907"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <vbox hidden="true">
+ <bindings xmlns="http://www.mozilla.org/xbl" style="display: block;"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <binding id="anon">
+ <implementation>
+ <constructor>
+ <![CDATA[
+ var node = this.firstChild;
+ this.palette = node;
+ this.removeChild(node);
+ ]]>
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+ </vbox>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=414907"
+ target="_blank">Mozilla Bug 414907</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ SimpleTest.waitForExplicitFinish();
+ window.onload = function onload() {
+ is($("box").palette.getAttribute("label"), $("command").getAttribute("label"));
+ SimpleTest.finish();
+ }
+
+ ]]></script>
+
+ <command id="command" label="label"/>
+
+ <box id="box" style="-moz-binding:url('#anon');">
+ <button observes="command"/>
+ </box>
+
+
+
+</window>
diff --git a/dom/xul/test/test_bug418216.xul b/dom/xul/test/test_bug418216.xul
new file mode 100644
index 000000000..e1e42ce11
--- /dev/null
+++ b/dom/xul/test/test_bug418216.xul
@@ -0,0 +1,46 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=418216
+-->
+<window title="Mozilla Bug 418216"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=418216"
+ target="_blank">Mozilla Bug 418216</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ /** Test for Bug 418216 **/
+ SimpleTest.waitForExplicitFinish();
+ window.onload = function onload() {
+ var element = $("item");
+ $("container").removeChild($("item"));
+ $("broadcaster").removeAttribute("disabled");
+ $("container").appendChild(element);
+ is($("item").hasAttribute("disabled"), $("broadcaster").hasAttribute("disabled"));
+ SimpleTest.finish();
+ }
+
+
+
+
+ ]]></script>
+
+<box id="container">
+<textbox id="item">
+ <observes element="broadcaster" attribute="disabled"/>
+</textbox>
+</box>
+
+<broadcasterset>
+ <broadcaster id="broadcaster" disabled="true"/>
+</broadcasterset>
+
+</window>
diff --git a/dom/xul/test/test_bug445177.xul b/dom/xul/test/test_bug445177.xul
new file mode 100644
index 000000000..ef89b7d87
--- /dev/null
+++ b/dom/xul/test/test_bug445177.xul
@@ -0,0 +1,85 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=445177
+-->
+<window title="Test for Bug 445177"
+ id="test_bug445177_xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<body id="body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=445177">Mozilla Bug 445177</a>
+
+
+<hbox id="b1" value="foo"/>
+<hbox id="o1" observes="b1"/>
+
+<pre id="test">
+ <script class="testbody" type="text/javascript">
+<![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ function do_test() {
+ var b1 = document.getElementById("b1");
+ var o1 = document.getElementById("o1");
+
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)");
+
+ b1.setAttribute("value", "bar");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)");
+
+ b1.removeAttribute("value");
+ is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (3)");
+
+ o1.setAttribute("value", "foo");
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (4)");
+
+ b1.setAttribute("value", "foobar");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (5)");
+
+ //After removing listener, changes to broadcaster shouldn't have any effect.
+ o1.parentNode.removeChild(o1);
+ b1.setAttribute("value", "foo");
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)");
+
+ b1.parentNode.appendChild(o1);
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (7)");
+
+ o1.parentNode.removeChild(o1);
+ o1.removeAttribute("observes");
+ o1.removeAttribute("value");
+ b1.parentNode.appendChild(o1);
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)");
+
+ document.addBroadcastListenerFor(b1, o1, "value");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (9)");
+
+ o1.parentNode.removeChild(o1);
+ b1.setAttribute("value", "foobar");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)");
+
+ b1.parentNode.appendChild(o1);
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (11)");
+
+ o1.setAttribute("observes", "b1");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)");
+
+ // When broadcaster isn't in document, changes to its attributes aren't
+ // reflected to listener.
+ b1.parentNode.removeChild(b1);
+ b1.setAttribute("value", "foo");
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (13)");
+
+ SimpleTest.finish();
+ }
+
+ addLoadEvent(do_test);
+]]>
+ </script>
+</pre>
+</body>
+</window>
diff --git a/dom/xul/test/test_bug449457.xul b/dom/xul/test/test_bug449457.xul
new file mode 100644
index 000000000..0401725f7
--- /dev/null
+++ b/dom/xul/test/test_bug449457.xul
@@ -0,0 +1,25 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=449457
+-->
+<window title="Mozilla Bug 449457"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=449457"
+ target="_blank">Mozilla Bug 449457</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ /** Test for Bug 449457 **/
+ document.popupNode = document;
+ ok(true, "This is just a leak test");
+
+ ]]></script>
+</window>
diff --git a/dom/xul/test/test_bug468176.xul b/dom/xul/test/test_bug468176.xul
new file mode 100644
index 000000000..1f3312266
--- /dev/null
+++ b/dom/xul/test/test_bug468176.xul
@@ -0,0 +1,84 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=468176
+-->
+<window title="Test for Bug 468176"
+ id="test_bug468176_xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<body id="body" xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468176">Mozilla Bug 468176</a>
+
+<xul:hbox id="b1" value="foo"/>
+
+<xul:hbox id="o1">
+ <xul:observes id="inner" element="b1" attribute="*"/>
+</xul:hbox>
+
+<pre id="test">
+ <script class="testbody" type="text/javascript">
+<![CDATA[
+ SimpleTest.waitForExplicitFinish();
+
+ var broadcastCount = 0;
+ function b_listener(evt) {
+ ++broadcastCount;
+ }
+
+ function do_test() {
+ var b1 = document.getElementById("b1");
+ var o1 = document.getElementById("o1");
+ var inner = document.getElementById("inner");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (1)");
+
+ inner.addEventListener("broadcast", b_listener, true);
+ b1.setAttribute("value", "bar");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (2)");
+ is(broadcastCount, 1, "Wrong value (3)");
+
+ b1.removeAttribute("value");
+ is(o1.hasAttribute("value"), b1.hasAttribute("value"), "Wrong value (4)");
+ is(broadcastCount, 2, "Wrong value (5)");
+
+ o1.setAttribute("value", "foo");
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (6)");
+ is(broadcastCount, 2, "Wrong value (7)");
+
+ b1.setAttribute("value", "foobar");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (8)");
+ is(broadcastCount, 3, "Wrong value (9)");
+
+ b1.removeAttribute("value");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (10)");
+ is(broadcastCount, 4, "Wrong value (11)");
+
+ b1.removeAttribute("value");
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (12)");
+ is(broadcastCount, 4, "Wrong value (13)");
+
+ o1.setAttribute("value", "bar");
+ b1.setAttribute("value", "bar"); // This should still dispatch 'broadcast'
+ is(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (14)");
+ is(broadcastCount, 5, "Wrong value (15)");
+
+ //After removing listener, changes to broadcaster shouldn't have any effect.
+ o1.parentNode.removeChild(o1);
+ b1.setAttribute("value", "foo");
+ isnot(o1.getAttribute("value"), b1.getAttribute("value"), "Wrong value (16)");
+ is(broadcastCount, 5, "Wrong value (17)");
+
+ SimpleTest.finish();
+ }
+
+ addLoadEvent(do_test);
+]]>
+ </script>
+</pre>
+</body>
+</window>
diff --git a/dom/xul/test/test_bug486990.xul b/dom/xul/test/test_bug486990.xul
new file mode 100644
index 000000000..fb375a4cc
--- /dev/null
+++ b/dom/xul/test/test_bug486990.xul
@@ -0,0 +1,155 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=486990
+-->
+<window title="Mozilla Bug 486990"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="setTimeout(runTests, 0);">
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=486990"
+ target="_blank">Mozilla Bug 486990</a>
+
+ </body>
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <select size="5" id="select">
+ <option>1</option>
+ <option>2</option>
+ <option>3</option>
+ <option>4</option>
+ <option>5</option>
+ <option>6</option>
+ <option>7</option>
+ <option>8</option>
+ <option>9</option>
+ <option>10</option>
+ </select>
+ </div>
+ <menupopup id="cm" onpopupshowing="popupShowing(event);">
+ <menuitem label="Mozilla" value="http://mozilla.org"/>
+ <menuitem label="Slashdot" value="http://slashdot.org"/>
+ <menuitem label="Sourceforge" value="http://sf.net"/>
+ <menuitem label="Freshmeat" value="http://freshmeat.net"/>
+ </menupopup>
+ <button label="test button" contextmenu="cm" id="testbutton"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 486990 **/
+
+ SimpleTest.waitForExplicitFinish();
+
+ var prevented = false;
+ var eventCount = 0;
+
+ function fooListener(evt) {
+ evt.preventDefault();
+ prevented = evt.defaultPrevented;
+ ++eventCount;
+ };
+
+ var clickCount = 0;
+ var mouseDownCount = 0;
+ var mouseUpCount = 0;
+ function clickListener(evt) {
+ ++clickCount;
+ }
+
+ function mouseDownListener(evt) {
+ ++mouseDownCount;
+ }
+
+ function mouseUpListener(evt) {
+ ++mouseUpCount;
+ }
+
+ var popupshowingcount = 0;
+
+ function popupShowing(evt) {
+ ++popupshowingcount;
+ evt.preventDefault();
+ }
+
+ function contextMenuStopper(evt) {
+ evt.stopPropagation();
+ }
+
+ function contextMenuPreventer(evt) {
+ evt.preventDefault();
+ }
+
+ var tb;
+ function runTests() {
+ document.addEventListener("foo", fooListener, true);
+ var e1 = document.createEvent("Event");
+ e1.initEvent("foo", true, true);
+ document.dispatchEvent(e1);
+ is(eventCount, 1, "Wrong event count");
+ ok(prevented, "Default handling should have been prevented.");
+
+ prevented = false;
+ var e2 = document.createEvent("Event");
+ e2.initEvent("foo", false, false);
+ document.dispatchEvent(e1);
+ is(eventCount, 2, "Wrong event count");
+ ok(prevented, "Default handling should have been prevented.");
+
+ tb = document.getElementById("testbutton");
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 1, "Should have got 'popupShowing' event!");
+
+ tb.addEventListener("contextmenu", contextMenuStopper, true);
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 2, "Should have got 'popupShowing' event!");
+
+ tb.addEventListener("contextmenu", contextMenuPreventer, true);
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 2, "Should not have got 'popupShowing' event!");
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.event.contextmenu.enabled", false]]}, test2);
+ }
+
+ function test2() {
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 3, "Should have got 'popupShowing' event!");
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.event.contextmenu.enabled", true]]}, test3);
+ }
+
+ function test3() {
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 3, "Should not have got 'popupshowing' event!");
+
+ var s = document.getElementById("select");
+ s.addEventListener("click", clickListener, true);
+ s.addEventListener("mousedown", mouseDownListener, true);
+ s.addEventListener("mouseup", mouseUpListener, true);
+
+ synthesizeMouse(s, 1, 10, {}, window);
+ is(clickCount, 1, "Should have got click event!");
+ is(mouseDownCount, 1, "Should have got mousedown event!");
+ is(mouseUpCount, 1, "Should have got mouseup event!");
+
+ // Dispatch to scrollbar.
+ synthesizeMouse(s, s.getBoundingClientRect().right - 3, 10, {}, window);
+ is(clickCount, 1, "Should not have got click event!");
+ is(mouseDownCount, 2, "Should have got mousedown event!");
+ is(mouseUpCount, 2, "Should have got mouseup event!");
+
+ SimpleTest.finish();
+ }
+
+ function dispatchTrustedContextMenuEvent(target) {
+ return sendMouseEvent({type:"contextmenu"}, target, window);
+ }
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/test_bug497875.xul b/dom/xul/test/test_bug497875.xul
new file mode 100644
index 000000000..a083daa53
--- /dev/null
+++ b/dom/xul/test/test_bug497875.xul
@@ -0,0 +1,53 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=497875
+-->
+<window title="Mozilla Bug 497875"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497875">Mozilla Bug 497875</a>
+<p id="display"><iframe id="iframe" src="bug497875-iframe.xul"></iframe></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 497875 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function done_test() {
+ var f = document.getElementById('iframe')
+ f.src="about:blank"
+ f.parentNode.removeChild(f)
+ ok(true, "this is a crashtest");
+ SimpleTest.finish();
+}
+
+function do_test() {
+ setTimeout(function () {document.getElementById('iframe').contentWindow.location.reload()}, 500);
+ setTimeout(function () {document.getElementById('iframe').contentWindow.location.reload()}, 1000);
+ setTimeout(function () {document.getElementById('iframe').contentWindow.location.reload()}, 1500);
+ setTimeout(done_test, 2000);
+}
+
+do_test();
+
+
+]]>
+</script>
+
+</window>
diff --git a/dom/xul/test/test_bug583948.xul b/dom/xul/test/test_bug583948.xul
new file mode 100644
index 000000000..c0d6ebd49
--- /dev/null
+++ b/dom/xul/test/test_bug583948.xul
@@ -0,0 +1,38 @@
+<?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 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+ <div id="content" style="display: none"/>
+</body>
+
+<script>
+SimpleTest.waitForExplicitFinish();
+
+var attempts = 0;
+
+function update() {
+ // without the crash fix, this usually crashes after 2 to 4 reloads
+ if (++attempts == 6) {
+ ok(true, "didn't crash after 6 attempts");
+ otherWindow.close();
+ SimpleTest.waitForFocus(function() {
+ SimpleTest.finish();
+ });
+ } else {
+ otherWindow.document.commandDispatcher.updateCommands('');
+ setTimeout(function() {
+ otherWindow.location.reload()
+ }, 0);
+ }
+}
+
+var otherWindow = window.open("window_bug583948.xul", "_new", "chrome");
+</script>
+
+</window>
diff --git a/dom/xul/test/test_bug640158_overlay_persist.xul b/dom/xul/test/test_bug640158_overlay_persist.xul
new file mode 100644
index 000000000..ad4817331
--- /dev/null
+++ b/dom/xul/test/test_bug640158_overlay_persist.xul
@@ -0,0 +1,51 @@
+<?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"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=640158
+-->
+<window title="Mozilla Bug 640158" id="rootwin"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=640158"
+ target="_blank">Mozilla Bug 640158</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ SimpleTest.waitForExplicitFinish();
+ window.onload = function onload() {
+ is($("foo").getAttribute("testattr"), "original", "Attribute should be in original state");
+ // Change and persist another value:
+ $("foo").setAttribute("testattr", "changed");
+ document.persist("foo", "testattr");
+ $("foo").setAttribute("testattr", "original");
+
+ // Hacky times: check that items which are overlaid do get persisted into correctly,
+ // by first creating an extra element and persisting the value before loading an
+ // overlay that changes that value - the persisted value should be reinstated.
+ let root = document.documentElement;
+ let bar = document.createElement("box");
+ bar.id = "bar";
+ bar.setAttribute("testattr", "changed"); // The overlay we load has 'original'
+ root.appendChild(bar);
+ document.persist("bar", "testattr");
+ document.loadOverlay(location.href.replace(/[^\\\/]*.xul/, "overlay_bug640158.xul"), function() {
+ is($("foo").getAttribute("testattr"), "original",
+ "Non-overlaid attribute should still be in original state");
+ is($("bar").getAttribute("testattr"), "changed",
+ "Overlaid attribute should have been changed.");
+ SimpleTest.finish();
+ });
+ }
+
+ ]]></script>
+
+ <box id="foo" testattr="original"/>
+
+</window>
+
diff --git a/dom/xul/test/test_bug749367.xul b/dom/xul/test/test_bug749367.xul
new file mode 100644
index 000000000..478a119e8
--- /dev/null
+++ b/dom/xul/test/test_bug749367.xul
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=749367
+-->
+<window title="Mozilla Bug 749367"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="setTimeout(runTests, 0);">
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=486990"
+ target="_blank">Mozilla Bug 486990</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="text/template">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ function runTests() {
+ ok(false, "Shouldn't execute");
+ SimpleTest.finish();
+ }
+ ]]>
+ </script>
+
+ <script type="text/javascript">
+ <![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ function runTests() {
+ ok(true, "Should execute");
+ SimpleTest.finish();
+ }
+ ]]>
+ </script>
+
+</window>
diff --git a/dom/xul/test/test_bug757137.xul b/dom/xul/test/test_bug757137.xul
new file mode 100644
index 000000000..e44a160b3
--- /dev/null
+++ b/dom/xul/test/test_bug757137.xul
@@ -0,0 +1,52 @@
+<?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 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+ <div id="content" style="display: none"/>
+</body>
+
+<script>
+var Ci = Components.interfaces;
+var chromeWindowInterface = Ci.nsIDOMChromeWindow;
+
+SimpleTest.waitForExplicitFinish();
+
+// Force off out-of-process mozbrowser because we need to grab its
+// |window| synchronously from here. Out-of-process docshell creation
+// for mozbrowser haves entirely differently.
+// XXX why doesn't pushPrefEnv() work here?
+var otherWindow = window.open("window_bug757137.xul", "", "chrome");
+ok(chromeWindowInterface !== null, 'nsIDOMChromeWindow interface is defined');
+var otherChromeWindow = null;
+try {
+ otherChromeWindow = otherWindow.QueryInterface(chromeWindowInterface);
+} catch(e) {
+ ok(false, 'exception when QI to ChromeWindow');
+}
+ok(otherChromeWindow !== null, 'XUL window should QI to ChromeWindow');
+
+SpecialPowers.pushPrefEnv({"set":[["dom.ipc.tabs.disabled", true]]}, startTest);
+
+function startTest() {
+ otherWindow.onload = function () {
+ var w = otherWindow.document.getElementById('f').contentWindow;
+ ok(w !== null, 'got the |window| for a mozbrowser iframe');
+ var chromeWindow = null;
+ try {
+ var chromeWindow = w.QueryInterface(chromeWindowInterface);
+ } catch(e) { }
+ ok(chromeWindow === null, 'mozbrowser iframe should not get ChromeWindow');
+
+ otherWindow.close();
+ SimpleTest.waitForFocus(SimpleTest.finish);
+ };
+}
+</script>
+
+</window>
diff --git a/dom/xul/test/test_bug775972.xul b/dom/xul/test/test_bug775972.xul
new file mode 100644
index 000000000..eeb7ebdac
--- /dev/null
+++ b/dom/xul/test/test_bug775972.xul
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=775972
+-->
+<window title="Mozilla Bug 775972"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="test()">
+ <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">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=775972"
+ target="_blank">Mozilla Bug 775972</a>
+ </body>
+
+ <hbox id="container"><label value="test" id=""/></hbox>
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 775972 **/
+
+ function test() {
+ var c = document.getElementById("container");
+ var clone = c.cloneNode(true);
+ document.documentElement.appendChild(clone);
+ ok(true, "This shouldn't crash!");
+ }
+
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/test_import_xul_to_content.xul b/dom/xul/test/test_import_xul_to_content.xul
new file mode 100644
index 000000000..a0b26fa96
--- /dev/null
+++ b/dom/xul/test/test_import_xul_to_content.xul
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window title="Mozilla Importing XUL into Content"
+ 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">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1027299"
+ target="_blank">Mozilla Bug 1027299</a>
+ </body>
+
+ <browser id="browserelt" src="about:blank" type="content"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ Components.utils.import("resource://gre/modules/Services.jsm");
+
+ SimpleTest.waitForExplicitFinish();
+
+ function expectWarning(expected, when, f) {
+ Services.console.reset();
+
+ f();
+
+ var sawWarning = false;
+ var msgs = Services.console.getMessageArray();
+ for (var i = 0; i < msgs.length; i++) {
+ var msg = msgs[i];
+ if (!msg || !(msg instanceof Components.interfaces.nsIScriptError)) {
+ continue;
+ }
+
+ if (msg.category.includes("DOM") && msg.errorMessage.includes("Importing XUL")) {
+ sawWarning = true;
+ }
+ }
+
+ ok(sawWarning == expected, "correct warning condition when " + when);
+ }
+
+ var browser = document.getElementById("browserelt");
+ browser.addEventListener("load", function() {
+ var doc = browser.contentDocument;
+
+ // We add a <video> element, which contains anonymous XUL content. This should not warn.
+ var video = doc.createElement("video");
+ expectWarning(false, "appending video", function() {
+ doc.documentElement.appendChild(video);
+ // Force a layout flush to make sure the anonymous content is added.
+ let dummy = doc.documentElement.offsetLeft;
+ });
+
+ // We add some XUL to a content document. This should generate a warning.
+ var elt = document.createElement("label");
+ var newElt = doc.importNode(elt, false);
+ expectWarning(true, "appending XUL", function() {
+ doc.documentElement.appendChild(newElt);
+ });
+
+ SimpleTest.finish();
+ });
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xul/test/window_bug583948.xul b/dom/xul/test/window_bug583948.xul
new file mode 100644
index 000000000..d0f6a2692
--- /dev/null
+++ b/dom/xul/test/window_bug583948.xul
@@ -0,0 +1,8 @@
+<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="opener.update()">
+
+<command oncommandupdate="document.removeChild(document.documentElement)" commandupdater="true"/>
+<box command="c"/>
+<iframe/>
+
+</window>
diff --git a/dom/xul/test/window_bug757137.xul b/dom/xul/test/window_bug757137.xul
new file mode 100644
index 000000000..16f38ef20
--- /dev/null
+++ b/dom/xul/test/window_bug757137.xul
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <html:iframe id="f" mozbrowser="true"
+ src="data:text/html;charset=utf-8,%3C!DOCTYPE html>Hi" />
+</window>