summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/bugs
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/tests/mochitest/bugs
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/tests/mochitest/bugs')
-rw-r--r--dom/tests/mochitest/bugs/bug289714.sjs16
-rw-r--r--dom/tests/mochitest/bugs/bug346659-echoer.html4
-rw-r--r--dom/tests/mochitest/bugs/bug346659-opener-echoer.html6
-rw-r--r--dom/tests/mochitest/bugs/bug346659-opener.html15
-rw-r--r--dom/tests/mochitest/bugs/bug346659-parent-echoer.html5
-rw-r--r--dom/tests/mochitest/bugs/bug346659-parent.html17
-rw-r--r--dom/tests/mochitest/bugs/bug458091_child.html13
-rw-r--r--dom/tests/mochitest/bugs/child_bug260264.html11
-rw-r--r--dom/tests/mochitest/bugs/devicemotion_inner.html10
-rw-r--r--dom/tests/mochitest/bugs/devicemotion_outer.html19
-rw-r--r--dom/tests/mochitest/bugs/file_bug291653.html28
-rw-r--r--dom/tests/mochitest/bugs/file_bug406375.html5
-rw-r--r--dom/tests/mochitest/bugs/file_bug504862.html22
-rw-r--r--dom/tests/mochitest/bugs/file_bug593174_1.html5
-rw-r--r--dom/tests/mochitest/bugs/file_bug593174_2.html30
-rw-r--r--dom/tests/mochitest/bugs/file_bug809290_b1.html14
-rw-r--r--dom/tests/mochitest/bugs/file_bug809290_b2.html14
-rw-r--r--dom/tests/mochitest/bugs/file_bug809290_c.html10
-rw-r--r--dom/tests/mochitest/bugs/file_bug927901.html18
-rw-r--r--dom/tests/mochitest/bugs/file_cookieOutputter.html13
-rw-r--r--dom/tests/mochitest/bugs/file_empty.html2
-rw-r--r--dom/tests/mochitest/bugs/file_prime_cookie.html14
-rw-r--r--dom/tests/mochitest/bugs/file_redirector.sjs9
-rw-r--r--dom/tests/mochitest/bugs/file_window_bar.html7
-rw-r--r--dom/tests/mochitest/bugs/grandchild_bug260264.html18
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug304459-1.html12
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug304459-2.html18
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug38959-1.html14
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug38959-2.html14
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug430276-2.html23
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug430276.html21
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug440572.html17
-rw-r--r--dom/tests/mochitest/bugs/iframe_bug49312.html7
-rw-r--r--dom/tests/mochitest/bugs/iframe_domparser_after_blank.html22
-rw-r--r--dom/tests/mochitest/bugs/mochitest.ini164
-rw-r--r--dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html14
-rw-r--r--dom/tests/mochitest/bugs/test_bug1022869.html39
-rw-r--r--dom/tests/mochitest/bugs/test_bug1112040.html32
-rw-r--r--dom/tests/mochitest/bugs/test_bug1160342_marquee.html337
-rw-r--r--dom/tests/mochitest/bugs/test_bug1171215.html89
-rw-r--r--dom/tests/mochitest/bugs/test_bug132255.html38
-rw-r--r--dom/tests/mochitest/bugs/test_bug159849.html41
-rw-r--r--dom/tests/mochitest/bugs/test_bug260264.html198
-rw-r--r--dom/tests/mochitest/bugs/test_bug260264_nested.html138
-rw-r--r--dom/tests/mochitest/bugs/test_bug265203.html110
-rw-r--r--dom/tests/mochitest/bugs/test_bug289714.html44
-rw-r--r--dom/tests/mochitest/bugs/test_bug291377.html40
-rw-r--r--dom/tests/mochitest/bugs/test_bug291653.html56
-rw-r--r--dom/tests/mochitest/bugs/test_bug304459.html47
-rw-r--r--dom/tests/mochitest/bugs/test_bug308856.html42
-rw-r--r--dom/tests/mochitest/bugs/test_bug327891.html33
-rw-r--r--dom/tests/mochitest/bugs/test_bug333983.html35
-rw-r--r--dom/tests/mochitest/bugs/test_bug335976.xhtml68
-rw-r--r--dom/tests/mochitest/bugs/test_bug342448.html36
-rw-r--r--dom/tests/mochitest/bugs/test_bug345521.html36
-rw-r--r--dom/tests/mochitest/bugs/test_bug346659.html163
-rw-r--r--dom/tests/mochitest/bugs/test_bug351601.html35
-rw-r--r--dom/tests/mochitest/bugs/test_bug369306.html137
-rw-r--r--dom/tests/mochitest/bugs/test_bug370098.html50
-rw-r--r--dom/tests/mochitest/bugs/test_bug377539.html55
-rw-r--r--dom/tests/mochitest/bugs/test_bug384122.html32
-rw-r--r--dom/tests/mochitest/bugs/test_bug389366.html65
-rw-r--r--dom/tests/mochitest/bugs/test_bug38959.html57
-rw-r--r--dom/tests/mochitest/bugs/test_bug393974.html68
-rw-r--r--dom/tests/mochitest/bugs/test_bug394769.html42
-rw-r--r--dom/tests/mochitest/bugs/test_bug396843.html242
-rw-r--r--dom/tests/mochitest/bugs/test_bug400204.html64
-rw-r--r--dom/tests/mochitest/bugs/test_bug404748.html31
-rw-r--r--dom/tests/mochitest/bugs/test_bug406375.html37
-rw-r--r--dom/tests/mochitest/bugs/test_bug414291.html35
-rw-r--r--dom/tests/mochitest/bugs/test_bug427744.html33
-rw-r--r--dom/tests/mochitest/bugs/test_bug42976.html81
-rw-r--r--dom/tests/mochitest/bugs/test_bug430276.html41
-rw-r--r--dom/tests/mochitest/bugs/test_bug437361.html72
-rw-r--r--dom/tests/mochitest/bugs/test_bug440572.html48
-rw-r--r--dom/tests/mochitest/bugs/test_bug456151.html73
-rw-r--r--dom/tests/mochitest/bugs/test_bug458091.html100
-rw-r--r--dom/tests/mochitest/bugs/test_bug459848.html60
-rw-r--r--dom/tests/mochitest/bugs/test_bug465263.html49
-rw-r--r--dom/tests/mochitest/bugs/test_bug479143.html44
-rw-r--r--dom/tests/mochitest/bugs/test_bug484775.html55
-rw-r--r--dom/tests/mochitest/bugs/test_bug492925.html45
-rw-r--r--dom/tests/mochitest/bugs/test_bug49312.html47
-rw-r--r--dom/tests/mochitest/bugs/test_bug495219.html27
-rw-r--r--dom/tests/mochitest/bugs/test_bug504862.html45
-rw-r--r--dom/tests/mochitest/bugs/test_bug529328.html122
-rw-r--r--dom/tests/mochitest/bugs/test_bug531176.html66
-rw-r--r--dom/tests/mochitest/bugs/test_bug531542.html40
-rw-r--r--dom/tests/mochitest/bugs/test_bug534149.html80
-rw-r--r--dom/tests/mochitest/bugs/test_bug541530.html92
-rw-r--r--dom/tests/mochitest/bugs/test_bug545314.html29
-rw-r--r--dom/tests/mochitest/bugs/test_bug548828.html37
-rw-r--r--dom/tests/mochitest/bugs/test_bug558973.html42
-rw-r--r--dom/tests/mochitest/bugs/test_bug562433.html35
-rw-r--r--dom/tests/mochitest/bugs/test_bug563487.html34
-rw-r--r--dom/tests/mochitest/bugs/test_bug581072.html47
-rw-r--r--dom/tests/mochitest/bugs/test_bug583225.html41
-rw-r--r--dom/tests/mochitest/bugs/test_bug585240.html33
-rw-r--r--dom/tests/mochitest/bugs/test_bug585819.html38
-rw-r--r--dom/tests/mochitest/bugs/test_bug593174.html85
-rw-r--r--dom/tests/mochitest/bugs/test_bug597809.html36
-rw-r--r--dom/tests/mochitest/bugs/test_bug61098.html339
-rw-r--r--dom/tests/mochitest/bugs/test_bug612267.html27
-rw-r--r--dom/tests/mochitest/bugs/test_bug617296.html27
-rw-r--r--dom/tests/mochitest/bugs/test_bug620947.html31
-rw-r--r--dom/tests/mochitest/bugs/test_bug622361.html53
-rw-r--r--dom/tests/mochitest/bugs/test_bug633133.html47
-rw-r--r--dom/tests/mochitest/bugs/test_bug641552.html88
-rw-r--r--dom/tests/mochitest/bugs/test_bug642026.html56
-rw-r--r--dom/tests/mochitest/bugs/test_bug648465.html33
-rw-r--r--dom/tests/mochitest/bugs/test_bug654137.html25
-rw-r--r--dom/tests/mochitest/bugs/test_bug664737.html39
-rw-r--r--dom/tests/mochitest/bugs/test_bug665548.html29
-rw-r--r--dom/tests/mochitest/bugs/test_bug684544.html56
-rw-r--r--dom/tests/mochitest/bugs/test_bug691707.html36
-rw-r--r--dom/tests/mochitest/bugs/test_bug698061.html40
-rw-r--r--dom/tests/mochitest/bugs/test_bug698551.html39
-rw-r--r--dom/tests/mochitest/bugs/test_bug707749.html34
-rw-r--r--dom/tests/mochitest/bugs/test_bug735237.html38
-rw-r--r--dom/tests/mochitest/bugs/test_bug739038.html38
-rw-r--r--dom/tests/mochitest/bugs/test_bug740811.html27
-rw-r--r--dom/tests/mochitest/bugs/test_bug743615.html84
-rw-r--r--dom/tests/mochitest/bugs/test_bug750051.html38
-rw-r--r--dom/tests/mochitest/bugs/test_bug755320.html30
-rw-r--r--dom/tests/mochitest/bugs/test_bug777628.html42
-rw-r--r--dom/tests/mochitest/bugs/test_bug809290.html54
-rw-r--r--dom/tests/mochitest/bugs/test_bug817476.html45
-rw-r--r--dom/tests/mochitest/bugs/test_bug823173.html30
-rw-r--r--dom/tests/mochitest/bugs/test_bug848088.html48
-rw-r--r--dom/tests/mochitest/bugs/test_bug850517.html47
-rw-r--r--dom/tests/mochitest/bugs/test_bug857555.html33
-rw-r--r--dom/tests/mochitest/bugs/test_bug862540.html31
-rw-r--r--dom/tests/mochitest/bugs/test_bug876098.html52
-rw-r--r--dom/tests/mochitest/bugs/test_bug927901.html40
-rw-r--r--dom/tests/mochitest/bugs/test_devicemotion_multiple_listeners.html35
-rw-r--r--dom/tests/mochitest/bugs/test_domparser_after_blank.html33
-rw-r--r--dom/tests/mochitest/bugs/test_errorReporting.html73
-rw-r--r--dom/tests/mochitest/bugs/test_onerror_message.html99
-rw-r--r--dom/tests/mochitest/bugs/test_protochains.html59
-rw-r--r--dom/tests/mochitest/bugs/test_resize_move_windows.html378
-rw-r--r--dom/tests/mochitest/bugs/test_sizetocontent_clamp.html74
-rw-r--r--dom/tests/mochitest/bugs/test_toJSON.html67
-rw-r--r--dom/tests/mochitest/bugs/test_window_bar.html97
-rw-r--r--dom/tests/mochitest/bugs/utils_bug260264.js60
-rw-r--r--dom/tests/mochitest/bugs/utils_bug743615.js25
-rw-r--r--dom/tests/mochitest/bugs/worker_bug743615.js38
146 files changed, 7614 insertions, 0 deletions
diff --git a/dom/tests/mochitest/bugs/bug289714.sjs b/dom/tests/mochitest/bugs/bug289714.sjs
new file mode 100644
index 000000000..aae8247ae
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug289714.sjs
@@ -0,0 +1,16 @@
+// Send a payload that's over 32k in size, which for a plain response should be
+// large enough to ensure that OnDataAvailable is called more than once (and so
+// the XHR will be triggered to send more than one "loading" event if desired).
+
+function handleRequest(request, response)
+{
+ // Send 81920 bytes of こんにちは in Shift-JIS encoding, framed in XML.
+ let data = "<?xml version='1.0' encoding='shift-jis'?><xml>" +
+ (new Array(1 << 13)).join("\x82\xb1\x82\xf1\x82\xc9\x82\xbf\x82\xcd") +
+ "</xml>";
+ response.processAsync();
+ response.setHeader("Content-Type", "text/xml", false);
+ response.setHeader("Content-Length", "" + data.length, false);
+ response.write(data, data.length);
+ response.finish();
+}
diff --git a/dom/tests/mochitest/bugs/bug346659-echoer.html b/dom/tests/mochitest/bugs/bug346659-echoer.html
new file mode 100644
index 000000000..bc6f6a903
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug346659-echoer.html
@@ -0,0 +1,4 @@
+<script>
+ window.opener.postMessage("1 - " + window.x, "http://mochi.test:8888");
+ window.close();
+</script>
diff --git a/dom/tests/mochitest/bugs/bug346659-opener-echoer.html b/dom/tests/mochitest/bugs/bug346659-opener-echoer.html
new file mode 100644
index 000000000..277d35874
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug346659-opener-echoer.html
@@ -0,0 +1,6 @@
+<script>
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ window.opener.opener.postMessage(window.opener.testNum + " - " + window.x, "http://mochi.test:8888");
+ window.opener.close();
+ window.close();
+</script>
diff --git a/dom/tests/mochitest/bugs/bug346659-opener.html b/dom/tests/mochitest/bugs/bug346659-opener.html
new file mode 100644
index 000000000..52facb07a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug346659-opener.html
@@ -0,0 +1,15 @@
+<body onload="postBack();">
+ <script>
+ function postBack() {
+ var s = decodeURIComponent(window.location.search.substring(1));
+ var cmd = JSON.parse(s);
+ if ("load" in cmd) {
+ window.testNum = cmd.load;
+ } else if ("write" in cmd) {
+ window.testNum = cmd.write;
+ }
+ window.opener.postMessage(s, "http://mochi.test:8888");
+ }
+ var childWin = window.open();
+ </script>
+</body>
diff --git a/dom/tests/mochitest/bugs/bug346659-parent-echoer.html b/dom/tests/mochitest/bugs/bug346659-parent-echoer.html
new file mode 100644
index 000000000..e5035397f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug346659-parent-echoer.html
@@ -0,0 +1,5 @@
+<script>
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ window.parent.opener.postMessage(window.parent.testNum + " - " + window.x, "http://mochi.test:8888");
+ window.parent.close();
+</script>
diff --git a/dom/tests/mochitest/bugs/bug346659-parent.html b/dom/tests/mochitest/bugs/bug346659-parent.html
new file mode 100644
index 000000000..0fea91c69
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug346659-parent.html
@@ -0,0 +1,17 @@
+<body onload="postBack();">
+ <script>
+ var childWin;
+ function postBack() {
+ childWin = window.frames[0];
+ var s = decodeURIComponent(window.location.search.substring(1));
+ var cmd = JSON.parse(s);
+ if ("load" in cmd) {
+ window.testNum = cmd.load;
+ } else if ("write" in cmd) {
+ window.testNum = cmd.write;
+ }
+ window.opener.postMessage(s, "http://mochi.test:8888");
+ }
+ </script>
+ <iframe></iframe>
+</body>
diff --git a/dom/tests/mochitest/bugs/bug458091_child.html b/dom/tests/mochitest/bugs/bug458091_child.html
new file mode 100644
index 000000000..90f848e4f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/bug458091_child.html
@@ -0,0 +1,13 @@
+<html> <head>
+<title></title>
+<script type="text/javascript">
+function finish() {
+ window.opener.finish(sessionStorage["testItem"]);
+ window.close();
+}
+</script>
+</head>
+
+<body onload="finish();">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/child_bug260264.html b/dom/tests/mochitest/bugs/child_bug260264.html
new file mode 100644
index 000000000..e8f7d578b
--- /dev/null
+++ b/dom/tests/mochitest/bugs/child_bug260264.html
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ </head>
+ <body>
+ <iframe id="frame"></iframe>
+ <script type="application/javascript">
+ var tempstr = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')+1);
+ document.getElementById("frame").src = "http://mochi.test:8888" + tempstr + "grandchild_bug260264.html" + window.location.hash;
+ </script>
+ </body>
+</html>
diff --git a/dom/tests/mochitest/bugs/devicemotion_inner.html b/dom/tests/mochitest/bugs/devicemotion_inner.html
new file mode 100644
index 000000000..c3ceb858b
--- /dev/null
+++ b/dom/tests/mochitest/bugs/devicemotion_inner.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script>
+function handler(ev) {}
+window.addEventListener("devicemotion", handler);
+window.ondeviceorientation = handler;
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/devicemotion_outer.html b/dom/tests/mochitest/bugs/devicemotion_outer.html
new file mode 100644
index 000000000..43bcb6028
--- /dev/null
+++ b/dom/tests/mochitest/bugs/devicemotion_outer.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script>
+var total = 50;
+var loaded = 0;
+for (var i = 0; i < total; i++) {
+ var f = document.createElement("iframe");
+ document.body.appendChild(f);
+ f.onload = function() {
+ loaded++;
+ if (loaded == total - 1)
+ document.location.replace("about:blank");
+ }
+ f.setAttribute('src', 'devicemotion_inner.html');
+}
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug291653.html b/dom/tests/mochitest/bugs/file_bug291653.html
new file mode 100644
index 000000000..4bfc8337e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug291653.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <script>
+ <!--
+ function listener1() {
+ window.showModalDialog("data:text/html,<script>var maintest = opener.opener; opener.location = 'data:text/html,test'; maintest.end(); window.close();</script>");
+ }
+
+ function listener2() {
+ opener.secondListenerDidRun = true;
+ }
+
+ window.addEventListener("foo", listener1);
+ window.addEventListener("foo", listener2);
+
+
+ function fireFoo() {
+ var e = document.createEvent("Events");
+ e.initEvent("foo", true, true);
+ window.dispatchEvent(e);
+ }
+ //-->
+ </script>
+ </head>
+ <body onload="setTimeout(fireFoo, 0)">
+ Test for bug 291653
+ </body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug406375.html b/dom/tests/mochitest/bugs/file_bug406375.html
new file mode 100644
index 000000000..215257824
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug406375.html
@@ -0,0 +1,5 @@
+<script>
+ var w = window.open("about:blank", "", "width=200,height=200,dialog");
+ w.close();
+ window.close();
+</script>
diff --git a/dom/tests/mochitest/bugs/file_bug504862.html b/dom/tests/mochitest/bugs/file_bug504862.html
new file mode 100644
index 000000000..dc11ced6f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug504862.html
@@ -0,0 +1,22 @@
+<html>
+<body>
+<script>
+window.returnValue = 3;
+
+if (location.toString().match(/^http:\/\/mochi.test:8888/)) {
+ // Test that we got the right arguments.
+ opener.is(window.dialogArguments, "my args",
+ "dialog did not get the right arguments.");
+
+ // Load a different url, and test that it sees the arguments (since it's same origin).
+ window.location="data:text/html,<html><body onload=\"opener.is(window.dialogArguments, 'my args', 'subsequent dialog document did not get the right arguments.'); close();\">';";
+} else {
+ // Post a message containing our arguments to the opener to test
+ // that this cross origing dialog does *not* see the passed in
+ // arguments.
+ opener.postMessage("args: " + window.dialogArguments,
+ "http://mochi.test:8888");
+
+ close();
+}
+</script>
diff --git a/dom/tests/mochitest/bugs/file_bug593174_1.html b/dom/tests/mochitest/bugs/file_bug593174_1.html
new file mode 100644
index 000000000..ec455fcf2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug593174_1.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+Nothing to see here. Move along.
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug593174_2.html b/dom/tests/mochitest/bugs/file_bug593174_2.html
new file mode 100644
index 000000000..8379b11d5
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug593174_2.html
@@ -0,0 +1,30 @@
+<html>
+<body>
+Page 2 has an iframe of its own.
+<iframe id='inner-iframe' onload='innerIframeLoaded()' src='data:text/html,
+ <html><body>
+ <script>function go() { window.location = "file_bug593174_1.html"; }</script>
+ </body></html>'>
+</iframe>
+
+<script>
+function innerIframeLoaded() {
+ if (parent.iframeLoaded) {
+ parent.iframeLoaded('inner');
+ }
+ else if(opener.iframeLoaded) {
+ opener.iframeLoaded('popup/inner');
+ }
+}
+
+function navigateInnerIframe() {
+ document.getElementById('inner-iframe').contentWindow.go();
+}
+
+function getInnerIframeReferrer() {
+ return document.getElementById('inner-iframe').contentWindow.document.referrer;
+}
+</script>
+
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug809290_b1.html b/dom/tests/mochitest/bugs/file_bug809290_b1.html
new file mode 100644
index 000000000..3a3863a61
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug809290_b1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function innerLoad() {
+ var win = document.getElementById('ifr').contentWindow;
+ win.location = "file_bug809290_c.html";
+}
+</script>
+</head>
+<body>
+<iframe id="ifr" src="file_empty.html">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug809290_b2.html b/dom/tests/mochitest/bugs/file_bug809290_b2.html
new file mode 100644
index 000000000..83c6f894c
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug809290_b2.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function eventHandlerLoad() {
+ var win = document.getElementById('ifr').contentWindow;
+ win.location = "file_bug809290_c.html";
+}
+</script>
+</head>
+<body onload="eventHandlerLoad();">
+<iframe id="ifr" src="file_empty.html">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug809290_c.html b/dom/tests/mochitest/bugs/file_bug809290_c.html
new file mode 100644
index 000000000..2d8c135e9
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug809290_c.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+window.parent.parent.notifyReferrer(document.referrer);
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_bug927901.html b/dom/tests/mochitest/bugs/file_bug927901.html
new file mode 100644
index 000000000..907b0d96c
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_bug927901.html
@@ -0,0 +1,18 @@
+<html>
+ <head>
+ <title></title>
+ <script>
+ var ret = "pass";
+ try {
+ window.foo = window.crypto.getRandomValues;
+ } catch(ex) {
+ ret = "" + ex;
+ }
+ parent.postMessage(ret, "*");
+ </script>
+ <style>
+ </style>
+ </head>
+ <body onload="document.body.textContent = 'Crypto test file on ' + location">
+ </body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_cookieOutputter.html b/dom/tests/mochitest/bugs/file_cookieOutputter.html
new file mode 100644
index 000000000..edc004ad1
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_cookieOutputter.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+ - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<html>
+<head>
+<meta charset=UTF-8>
+</head>
+<body>
+ <script>
+parent.postMessage(document.cookie, "*");
+ </script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_empty.html b/dom/tests/mochitest/bugs/file_empty.html
new file mode 100644
index 000000000..ca105f950
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_empty.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<html><head></head><body></body></html>
diff --git a/dom/tests/mochitest/bugs/file_prime_cookie.html b/dom/tests/mochitest/bugs/file_prime_cookie.html
new file mode 100644
index 000000000..ee9240e3a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_prime_cookie.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+ - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<html>
+<head>
+<meta charset=UTF-8>
+</head>
+<body>
+<script>
+document.cookie = "b=c";
+parent.postMessage("done", "*");
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/file_redirector.sjs b/dom/tests/mochitest/bugs/file_redirector.sjs
new file mode 100644
index 000000000..70478e69a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_redirector.sjs
@@ -0,0 +1,9 @@
+/* vim: set ft=javascript: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+function handleRequest(request, response) {
+ response.setHeader("Content-type", "text/html", false);
+ response.setStatusLine(request.httpVersion, "302", "Found");
+ response.setHeader("Location", request.queryString, false);
+ response.write("<!DOCTYPE html><html><body>Look away!</body></html>");
+}
diff --git a/dom/tests/mochitest/bugs/file_window_bar.html b/dom/tests/mochitest/bugs/file_window_bar.html
new file mode 100644
index 000000000..59b2c1601
--- /dev/null
+++ b/dom/tests/mochitest/bugs/file_window_bar.html
@@ -0,0 +1,7 @@
+<html>
+<body onload='opener.testWindow(window)'>
+
+Nothing to see here!
+
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/grandchild_bug260264.html b/dom/tests/mochitest/bugs/grandchild_bug260264.html
new file mode 100644
index 000000000..a786c5b9e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/grandchild_bug260264.html
@@ -0,0 +1,18 @@
+<html>
+ <head>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="utils_bug260264.js"></script>
+ </head>
+ <body>
+ <a id="nested link" href="javascript:(function(){})()">nested link</a>
+ <script type="application/javascript">
+ var event = location.hash.split("#").pop();
+ send(document.getElementById("nested link"), event, function() {
+ var popup = window.open("http://example.com"),
+ grandparent = window.open("", "parent260264");
+ try { grandparent.report(popup) }
+ finally { popup && popup.close() }
+ });
+ </script>
+ </body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug304459-1.html b/dom/tests/mochitest/bugs/iframe_bug304459-1.html
new file mode 100644
index 000000000..2721c5c78
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug304459-1.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+ <title>Iframe test for bug 304459</title>
+</head>
+<body">
+<script>
+
+Object.prototype.x = "oops";
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug304459-2.html b/dom/tests/mochitest/bugs/iframe_bug304459-2.html
new file mode 100644
index 000000000..3a922b9b2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug304459-2.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+ <title>Iframe test for bug 304459</title>
+</head>
+<body">
+<script>
+
+var result;
+try {
+ x == undefined;
+} catch (e) {
+ result = true;
+}
+window.parent.postMessage(result, "http://mochi.test:8888");
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug38959-1.html b/dom/tests/mochitest/bugs/iframe_bug38959-1.html
new file mode 100644
index 000000000..d4c16c47a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug38959-1.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+ <title>Iframe test for bug 38959</title>
+</head>
+<body">
+<script>
+
+x = false;
+window.opener.postMessage(1, "http://mochi.test:8888");
+window.close();
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug38959-2.html b/dom/tests/mochitest/bugs/iframe_bug38959-2.html
new file mode 100644
index 000000000..36cd0c156
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug38959-2.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+ <title>Iframe test for bug 38959</title>
+</head>
+<body">
+<script>
+
+x = true;
+window.opener.postMessage(2, "http://mochi.test:8888");
+window.close();
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug430276-2.html b/dom/tests/mochitest/bugs/iframe_bug430276-2.html
new file mode 100644
index 000000000..0d495cc97
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug430276-2.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <script type="application/javascript">
+ new XMLHttpRequest();
+ function runTest() {
+ document.open();
+ var succeeded = true;
+ try {
+ new XMLHttpRequest();
+ } catch(e) {
+ succeeded = false;
+ }
+ window.parent.ok(succeeded, "Creating XMLHttpRequest failed!");
+ window.parent.SimpleTest.finish();
+ document.close();
+ }
+ </script>
+</head>
+<body onload="runTest()">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug430276.html b/dom/tests/mochitest/bugs/iframe_bug430276.html
new file mode 100644
index 000000000..703eb5dd5
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug430276.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <script type="application/javascript">
+ function runTest() {
+ document.write("<body>");
+ var succeeded = true;
+ try {
+ new XMLHttpRequest();
+ } catch(e) {
+ succeeded = false;
+ }
+ window.parent.ok(succeeded, "Creating XMLHttpRequest failed!");
+ window.parent.nextTest();
+ }
+ </script>
+</head>
+<body onload="runTest()">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug440572.html b/dom/tests/mochitest/bugs/iframe_bug440572.html
new file mode 100644
index 000000000..c8d9f8fe2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug440572.html
@@ -0,0 +1,17 @@
+<html>
+<body>
+<script>
+
+var success = 0;
+
+try {
+ parent[name].success = 1;
+ parent.postMessage(success ? "success" : "failure", "http://mochi.test:8888");
+} catch (e) {
+ parent.postMessage(e.toString(), "http://mochi.test:8888");
+}
+
+</script>
+<p>Move on, nothing to see here...</p>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/iframe_bug49312.html b/dom/tests/mochitest/bugs/iframe_bug49312.html
new file mode 100644
index 000000000..e1df2f6de
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_bug49312.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<script>
+ window.onload = function() {
+ var win = window.opener ? window.opener : window.parent;
+ win.subframeLoaded(window);
+ }
+</script>
diff --git a/dom/tests/mochitest/bugs/iframe_domparser_after_blank.html b/dom/tests/mochitest/bugs/iframe_domparser_after_blank.html
new file mode 100644
index 000000000..f37339377
--- /dev/null
+++ b/dom/tests/mochitest/bugs/iframe_domparser_after_blank.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head><meta charset=utf-8>
+ <title></title>
+ <script type="application/javascript">
+ function runTest() {
+ document.write("<body>");
+ var succeeded = true;
+ try {
+ new DOMParser();
+ } catch(e) {
+ succeeded = false;
+ }
+ window.parent.ok(succeeded, "Creating DOMParser failed!");
+ window.parent.SimpleTest.finish();
+ document.close();
+ }
+ </script>
+</head>
+<body onload="runTest()">
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/mochitest.ini b/dom/tests/mochitest/bugs/mochitest.ini
new file mode 100644
index 000000000..e0c71f857
--- /dev/null
+++ b/dom/tests/mochitest/bugs/mochitest.ini
@@ -0,0 +1,164 @@
+[DEFAULT]
+support-files =
+ bug289714.sjs
+ bug346659-echoer.html
+ bug346659-opener-echoer.html
+ bug346659-opener.html
+ bug346659-parent-echoer.html
+ bug346659-parent.html
+ bug458091_child.html
+ child_bug260264.html
+ devicemotion_inner.html
+ devicemotion_outer.html
+ file_bug291653.html
+ file_bug406375.html
+ file_bug504862.html
+ file_bug593174_1.html
+ file_bug593174_2.html
+ file_bug809290_b1.html
+ file_bug809290_b2.html
+ file_bug809290_c.html
+ file_empty.html
+ file_window_bar.html
+ grandchild_bug260264.html
+ iframe_bug304459-1.html
+ iframe_bug304459-2.html
+ iframe_bug38959-1.html
+ iframe_bug38959-2.html
+ iframe_bug430276-2.html
+ iframe_bug430276.html
+ iframe_bug440572.html
+ iframe_bug49312.html
+ iframe_domparser_after_blank.html
+ utils_bug260264.js
+ utils_bug743615.js
+ worker_bug743615.js
+ file_bug927901.html
+ file_cookieOutputter.html
+ file_redirector.sjs
+ file_prime_cookie.html
+
+[test_DOMWindowCreated_chromeonly.html]
+[test_bug132255.html]
+[test_bug159849.html]
+[test_bug289714.html]
+[test_bug260264.html]
+skip-if = toolkit == 'android'
+[test_bug260264_nested.html]
+[test_bug265203.html]
+[test_bug291377.html]
+[test_bug291653.html]
+skip-if = toolkit == 'android' #TIMED_OUT
+[test_bug304459.html]
+[test_bug308856.html]
+[test_bug327891.html]
+[test_bug333983.html]
+[test_bug335976.xhtml]
+[test_bug342448.html]
+[test_bug345521.html]
+[test_bug346659.html]
+[test_bug351601.html]
+[test_bug369306.html]
+skip-if = toolkit == 'android' #TIMED_OUT
+[test_bug370098.html]
+[test_bug377539.html]
+[test_bug384122.html]
+[test_bug389366.html]
+[test_bug38959.html]
+[test_bug393974.html]
+[test_bug394769.html]
+[test_bug396843.html]
+[test_bug400204.html]
+[test_bug404748.html]
+[test_bug406375.html]
+skip-if = toolkit == 'android'
+[test_bug414291.html]
+tags = openwindow
+[test_bug427744.html]
+skip-if = toolkit == 'android'
+[test_bug42976.html]
+[test_bug430276.html]
+[test_bug437361.html]
+skip-if = toolkit == 'android'
+[test_bug440572.html]
+[test_bug456151.html]
+[test_bug458091.html]
+[test_bug459848.html]
+[test_bug465263.html]
+[test_bug479143.html]
+skip-if = toolkit == 'android'
+[test_bug484775.html]
+[test_bug492925.html]
+[test_bug49312.html]
+[test_bug495219.html]
+[test_bug504862.html]
+skip-if = toolkit == 'android' #RANDOM
+[test_bug529328.html]
+[test_bug531176.html]
+[test_bug531542.html]
+[test_bug534149.html]
+[test_bug541530.html]
+[test_bug545314.html]
+[test_bug548828.html]
+[test_bug558973.html]
+[test_bug562433.html]
+[test_bug563487.html]
+[test_bug581072.html]
+[test_bug583225.html]
+[test_bug585240.html]
+[test_bug585819.html]
+[test_bug593174.html]
+[test_bug597809.html]
+skip-if = toolkit == 'android'
+[test_bug61098.html]
+skip-if = toolkit == 'android'
+[test_bug612267.html]
+[test_bug617296.html]
+[test_bug620947.html]
+[test_bug622361.html]
+[test_bug633133.html]
+[test_bug641552.html]
+skip-if = toolkit == 'android'
+[test_bug642026.html]
+[test_bug648465.html]
+[test_bug654137.html]
+[test_bug664737.html]
+[test_bug665548.html]
+[test_bug684544.html]
+[test_bug691707.html]
+[test_bug698061.html]
+[test_bug698551.html]
+[test_bug707749.html]
+[test_bug735237.html]
+[test_bug739038.html]
+[test_bug740811.html]
+[test_bug743615.html]
+[test_bug750051.html]
+[test_bug755320.html]
+[test_bug777628.html]
+[test_bug809290.html]
+[test_bug817476.html]
+[test_bug823173.html]
+[test_bug848088.html]
+[test_bug850517.html]
+[test_bug857555.html]
+[test_bug862540.html]
+[test_bug876098.html]
+[test_bug927901.html]
+[test_devicemotion_multiple_listeners.html]
+skip-if = toolkit == 'android' #bug 775227
+[test_domparser_after_blank.html]
+[test_errorReporting.html]
+[test_onerror_message.html]
+[test_protochains.html]
+[test_resize_move_windows.html]
+skip-if = toolkit == 'android' || os == 'linux' #Windows can't change size and position on Android
+[test_sizetocontent_clamp.html]
+skip-if = toolkit == 'android' #Windows can't change size on Android
+[test_toJSON.html]
+[test_window_bar.html]
+skip-if = toolkit == 'android'
+[test_bug1022869.html]
+[test_bug1112040.html]
+[test_bug1160342_marquee.html]
+[test_bug1171215.html]
diff --git a/dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html b/dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html
new file mode 100644
index 000000000..fc1a4cbbc
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<head>
+ <title>DOMWindowCreated not visible in content</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+<body onload="ok(true, 'Test finished'); SimpleTest.finish();">
+ <p id="display"></p>
+
+ <script type="application/javascript">
+ SimpleTest.waitForExplicitFinish();
+ window.addEventListener("DOMWindowCreated", function() { ok(false, "DOMWindowCreated should not have fired"); }, false);
+ window.addEventListener("DOMDocElementInserted", function() { ok(false, "DOMDocElementInserted should not have fired"); }, false);
+
+ <iframe src="data:text/plain,Hi"></iframe>
diff --git a/dom/tests/mochitest/bugs/test_bug1022869.html b/dom/tests/mochitest/bugs/test_bug1022869.html
new file mode 100644
index 000000000..d094f5a6c
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug1022869.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1022869
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1022869</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <iframe src="data:text/html,<html><body>"></iframe>
+ <script type="application/javascript">
+
+ var f = document.getElementsByTagName("iframe")[0];
+
+ SimpleTest.waitForExplicitFinish();
+
+ /** Test for Bug 1022869 **/
+ function startTest() {
+ var div = f.contentDocument.createElement("div");
+ div.innerHTML = "<template>x";
+ is(div.firstChild.content.ownerDocument.parentNode, null, "Should be able to access property on document.");
+ f.contentDocument.open();
+ is(div.firstChild.content.ownerDocument.parentNode, null, "Should be able to access property on document after document.open().");
+
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body onload="startTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022869">Mozilla Bug 1022869</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug1112040.html b/dom/tests/mochitest/bugs/test_bug1112040.html
new file mode 100644
index 000000000..690d24e66
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug1112040.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1112040
+-->
+<head>
+ <title>Test for Bug 1112040</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <base href="http://mochi.test:8888/tests/dom/tests/mochitest/">
+ <meta charset="UTF-8">
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1112040">Mozilla Bug 1112040</a>
+<p id="display">
+</p>
+<div id="content">
+ <input id="i" type="text" pattern="^.**$">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1112040 **/
+SimpleTest.runTestExpectingConsoleMessages(
+ function() { $('i').value = "42"; },
+ [{ errorMessage: /nothing to repeat/ }]
+);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug1160342_marquee.html b/dom/tests/mochitest/bugs/test_bug1160342_marquee.html
new file mode 100644
index 000000000..8da13478e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug1160342_marquee.html
@@ -0,0 +1,337 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1160342
+-->
+<head>
+ <title>Test for Bug 411103</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1160342">Mozilla Bug 1160342</a>
+<p id="display"></p>
+<div id="content">
+<marquee id="a" style="border: 1px solid black;">marquee</marquee>
+</div>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/* The todos are cases where IE/Edge is throwing errors, but
+ for Mozilla it was decided to not do that for now */
+ var x=document.getElementById('a');
+
+ SimpleTest.waitForExplicitFinish();
+
+ setTimeout(function() {
+ is(x.behavior, "scroll", "Wrong behavior value");
+ x.setAttribute('behavior', 'alternate');
+ is(x.behavior, "alternate", "Wrong behavior value");
+ x.setAttribute('behavior', 'invalid');
+ is(x.behavior, "scroll", "Wrong behavior value");;
+ x.setAttribute('behavior', 'Scroll');
+ is(x.behavior, "scroll", "Wrong behavior value");
+ x.setAttribute('behavior', 'Slide');
+ is(x.behavior, "slide", "Wrong behavior value");
+ x.setAttribute('behavior', '');
+ is(x.behavior, "scroll", "Wrong behavior value");
+ x.setAttribute('behavior', 'slide');
+ x.removeAttribute('behavior');
+ is(x.behavior, "scroll", "Wrong behavior value");
+ is(x.getAttribute('behavior'), null, "Wrong behavior attribute");
+
+ x.behavior = 'alternate';
+ is(x.behavior, "alternate", "Wrong behavior value");
+ try {
+ x.behavior = 'invalid';
+ todo_is(false, true, "marquee.behavior = 'invalid' should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.behavior, "alternate", "Wrong behavior value");
+ is(x.getAttribute('behavior'), "alternate", "Wrong behavior attribute");
+ x.behavior = 'Slide';
+ is(x.behavior, "slide", "Wrong behavior value");
+ is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
+ try {
+ x.behavior = 'invalid';
+ todo_is(false, true, "marquee.behavior = 'invalid' should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ try {
+ x.behavior = null;
+ x.behavior = undefined;
+ todo_is(false, true, "marquee.behavior = 'invalid' should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.behavior, "slide", "Wrong behavior value");
+ is(x.getAttribute('behavior'), "slide", "Wrong behavior attribute");
+ // This doesn't work in Mozilla due to chrome XBL security issues
+ x.behavior = { toString: function _toString() { return "scroll"} }
+ is(x.behavior, x.getAttribute('behavior'), "Wrong behavior value");
+ x.behavior = 'scroll';
+ is(x.behavior, "scroll", "Wrong behavior value");
+
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '1');
+ is(x.loop, 1, "Wrong loop value");
+ x.setAttribute('loop', 'invalid');
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '');
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '0');
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '1000');
+ is(x.loop, 1000, "Wrong loop value");
+ x.setAttribute('loop', '-0.123');
+ is(x.loop, 1000, "Wrong loop value");
+ x.setAttribute('loop', '-1.123');
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '-1');
+ is(x.loop, -1, "Wrong loop value");
+ x.setAttribute('loop', '1000');
+ is(x.loop, 1000, "Wrong loop value");
+ x.removeAttribute('loop');
+ is(x.loop, -1, "Wrong loop value");
+ is(x.getAttribute('loop'), null, "Wrong loop attribute");
+
+ x.loop = 1;
+ is(x.loop, 1, "Wrong loop value");
+ is(x.getAttribute('loop'), "1", "Wrong loop attribute");
+ try {
+ x.loop = -2;
+ todo_is(false, true, "marquee.loop = -2 should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.loop, 1, "Wrong loop value");
+ is(x.getAttribute('loop'), "1", "Wrong loop attribute");
+ try {
+ x.loop = 'invalid';
+ todo_is(false, true, ".loop = 'invalid' should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.loop, 1, "Wrong loop value");
+ is(x.getAttribute('loop'), "1", "Wrong loop attribute");
+ try {
+ x.loop = null;
+ todo_is(false, true, "marquee.loop = null should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.loop, 1, "Wrong loop value");
+ is(x.getAttribute('loop'), "1", "Wrong loop attribute");
+ x.loop = -1;
+ is(x.loop, -1, "Wrong loop value");
+ is(x.getAttribute('loop'), "-1", "Wrong loop attribute");
+ x.loop = '100';
+ is(x.loop, 100, "Wrong loop value");
+ is(x.getAttribute('loop'), "100", "Wrong loop attribute");
+ try {
+ x.loop = -0.123;
+ todo_is(false, true, "marquee.loop = null should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.loop, 100, "Wrong loop value");
+ is(x.getAttribute('loop'), "100", "Wrong loop attribute");
+ try {
+ x.loop = 0;
+ todo_is(false, true, "marquee.loop = null should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.loop, 100, "Wrong loop value");
+ is(x.getAttribute('loop'), "100", "Wrong loop attribute");
+ x.loop = -1.123;
+ is(x.loop, -1, "Wrong loop value");
+ is(x.getAttribute('loop'), "-1", "Wrong loop attribute");
+
+
+ is(x.scrollAmount, 6, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '1');
+ is(x.scrollAmount, 1, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', 'invalid');
+ is(x.scrollAmount, 6, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '1000');
+ is(x.scrollAmount, 1000, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '-1');
+ is(x.scrollAmount, 1000, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '999');
+ is(x.scrollAmount, 999, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '');
+ is(x.scrollAmount, 6, "Wrong scrollAmount value");
+ x.setAttribute('scrollAmount', '999');
+ x.removeAttribute('scrollAmount');
+ is(x.scrollAmount, 6, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), null, "Wrong scrollamount attribute");
+
+ x.scrollAmount = 1;
+ is(x.scrollAmount, 1, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
+ try {
+ x.scrollAmount = -2;
+ todo_is(false, true, "marquee.scrollAmount = -2 should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.scrollAmount, 1, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), "1", "Wrong scrolldelay attribute");
+ x.scrollAmount = 'invalid';
+ is(x.scrollAmount, 0, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
+ x.scrollAmount = 1;
+ x.scrollAmount = null;
+ is(x.scrollAmount, 0, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), "0", "Wrong scrolldelay attribute");
+ x.scrollAmount = '2';
+ is(x.scrollAmount, 2, "Wrong scrollAmount value");
+ is(x.getAttribute('scrollamount'), "2", "Wrong scrolldelay attribute");
+
+
+ is(x.scrollDelay, 85, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '1');
+ is(x.scrollDelay, 1, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', 'invalid');
+ is(x.scrollDelay, 85, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '70');
+ is(x.scrollDelay, 70, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '59');
+ is(x.scrollDelay, 59, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '1000');
+ is(x.scrollDelay, 1000, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '-1');
+ is(x.scrollDelay, 1000, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '');
+ is(x.scrollDelay, 85, "Wrong scrollDelay value");
+ x.setAttribute('scrollDelay', '1000');
+ x.removeAttribute('scrollDelay');
+ is(x.scrollDelay, 85, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), null, "Wrong scrolldelay attribute");
+
+ x.scrollDelay = 100;
+ is(x.scrollDelay, 100, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
+ try {
+ x.scrollDelay = -2;
+ todo_is(false, true, "marquee.scrollDelay = -2 should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.scrollDelay, 100, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
+ try {
+ x.scrollDelay = 'invalid';
+ todo_is(false, true, "marquee.scrollDelay = 'invalid' should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.scrollDelay, 100, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
+ try {
+ x.scrollDelay = null;
+ todo_is(false, true, "marquee.scrollDelay = null should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.scrollDelay, 100, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
+ try {
+ x.scrollDelay = -1;
+ todo_is(false, true, "marquee.scrollDelay = -1 should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.scrollDelay, 100, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "100", "Wrong scrolldelay attribute");
+ x.scrollDelay = '50';
+ is(x.scrollDelay, 50, "Wrong scrollDelay value");
+ is(x.getAttribute('scrolldelay'), "50", "Wrong scrolldelay attribute");
+
+
+ is(x.trueSpeed, false, "Wrong trueSpeed value");
+ x.setAttribute('trueSpeed', '1');
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ x.setAttribute('trueSpeed', 'false');
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ x.setAttribute('trueSpeed', '');
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ x.removeAttribute('trueSpeed');
+ is(x.trueSpeed, false, "Wrong trueSpeed value");
+ is(x.getAttribute('truespeed'), null, "Wrong truespeed attribute");
+
+ x.trueSpeed = 1;
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");
+ x.trueSpeed = -2;
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");
+ x.trueSpeed = null;
+ is(x.trueSpeed, false, "Wrong trueSpeed value");
+ is(x.getAttribute('truespeed'), null, "Wrong truespeed attribute");
+ x.trueSpeed = '100';
+ is(x.trueSpeed, true, "Wrong trueSpeed value");
+ is(x.getAttribute('truespeed'), "", "Wrong truespeed attribute");
+
+
+ is(x.direction, "left", "Wrong direction value");
+ x.setAttribute('direction', 'right');
+ is(x.direction, "right", "Wrong direction value");
+ x.setAttribute('direction', 'invalid');
+ is(x.direction, "left", "Wrong direction value");
+ x.setAttribute('direction', 'RIGHT');
+ is(x.direction, "right", "Wrong direction value");
+ x.setAttribute('direction', '');
+ is(x.direction, "left", "Wrong direction value");
+ x.setAttribute('direction', 'right');
+ x.removeAttribute('direction');
+ is(x.direction, "left", "Wrong direction value");
+ is(x.getAttribute('direction'), null, "Wrong direction attribute");
+ x.setAttribute('direction', 'up');
+ is(x.direction, "up", "Wrong direction value");
+ x.setAttribute('direction', 'down');
+ is(x.direction, "down", "Wrong direction value");
+ x.removeAttribute('direction');
+ is(x.direction, "left", "Wrong direction value");
+ is(x.getAttribute('direction'), null, "Wrong direction attribute");
+
+ x.direction = 'right';
+ is(x.direction, "right", "Wrong direction value");
+ is(x.getAttribute('direction'), "right", "Wrong direction attribute");
+ x.direction = 'up';
+ is(x.direction, "up", "Wrong direction value");
+ is(x.getAttribute('direction'), "up", "Wrong direction attribute");
+ x.direction = 'down';
+ is(x.direction, "down", "Wrong direction value");
+ is(x.getAttribute('direction'), "down", "Wrong direction attribute");
+ try {
+ x.direction = 1;
+ todo_is(false, true, "marquee.direction = 1 should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.direction, "down", "Wrong direction value");
+ is(x.getAttribute('direction'), "down", "Wrong direction attribute");
+ try {
+ x.direction = null;
+ todo_is(false, true, "marquee.direction = null should throw");
+ } catch(e) {
+ ok(true, "Exception was raised");
+ }
+ is(x.direction, "down", "Wrong direction value");
+ is(x.getAttribute('direction'), "down", "Wrong direction attribute");
+ // This doesn't work in Mozilla due to chrome XBL security issues
+ x.direction = { toString: function _toString() { return "right"} }
+ is(x.direction, x.getAttribute('direction'), "Wrong direction value");
+ x.direction = 'left';
+ is(x.direction, "left", "Wrong direction value");
+ SimpleTest.finish();
+ }, 0);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug1171215.html b/dom/tests/mochitest/bugs/test_bug1171215.html
new file mode 100644
index 000000000..d989fb62e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug1171215.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1022869
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1022869</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <iframe src="about:blank"></iframe>
+ <script type="text/javascript; version=1.8">
+
+ var f = document.getElementsByTagName("iframe")[0];
+
+ SimpleTest.waitForExplicitFinish();
+
+ /** Test for Bug 1022869 **/
+ function startTest() {
+ // Initialize our cookie.
+ document.cookie = "a=b";
+
+ // Set a cookie in example.org so we can test that we can't read it in
+ // third-party cases.
+ f.contentWindow.location =
+ "http://example.org/tests/dom/tests/mochitest/bugs/file_prime_cookie.html";
+ waitForLoad().then(function() {
+ // Cookies are set up, disallow third-party cookies and start the test.
+ SpecialPowers.pushPrefEnv({ set: [[ 'network.cookie.cookieBehavior', 1 ]] },
+ () => { spawn_task(continueTest); });
+ }).catch((e) => { ok(false, `Got exception: ${e}`) });
+ }
+
+ function waitForLoad() {
+ return new Promise((resolve) => {
+ window.addEventListener("message", function received(msg) {
+ window.removeEventListener("message", received);
+ info(`got message ${msg.data}`);
+ resolve(msg.data);
+ });
+ });
+ }
+
+ function* continueTest() {
+ var sameOrigin = "http://mochi.test:8888";
+ var thirdParty = "http://example.org";
+ var page = "tests/dom/tests/mochitest/bugs/file_cookieOutputter.html"
+ var redirect = "tests/dom/tests/mochitest/bugs/file_redirector.sjs";
+
+ function createRedirect(firstOrigin, secondOrigin) {
+ return `${firstOrigin}/${redirect}?${secondOrigin}/${page}`;
+ }
+
+ info("starting test");
+
+ // Same origin to same origin.
+ f.contentWindow.location = createRedirect(sameOrigin, sameOrigin);
+ let cookie = yield waitForLoad();
+ is(cookie, "a=b", "got the cookie");
+
+ // Cross origin to cross origin.
+ f.contentWindow.location = createRedirect(thirdParty, thirdParty);
+ cookie = yield waitForLoad();
+ is(cookie, "", "no third-party cookies");
+
+ // Same origin to cross origin.
+ f.contentWindow.location = createRedirect(sameOrigin, thirdParty);
+ cookie = yield waitForLoad();
+ is(cookie, "", "no third-party cookies");
+
+ // Cross origin to same origin
+ f.contentWindow.location = createRedirect(thirdParty, sameOrigin);
+ cookie = yield waitForLoad();
+ is(cookie, "a=b", "got the cookie");
+
+ SimpleTest.finish();
+ }
+ </script>
+</head>
+<body onload="startTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022869">Mozilla Bug 1022869</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug132255.html b/dom/tests/mochitest/bugs/test_bug132255.html
new file mode 100644
index 000000000..a2165d886
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug132255.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=132255
+-->
+<head>
+ <title>Test for Bug 132255</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <base href="http://mochi.test:8888/tests/dom/tests/mochitest/">
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=132255">Mozilla Bug 132255</a>
+<p id="display">
+ <iframe src="javascript:'<a href=\'foo.html\'>test-anchor</a>'"></iframe>
+ <iframe src="javascript:'<base href=\'http://example.com/\'><a href=\'foo.html\'>test-anchor</a>'"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 132255 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ is(window.frames[0].document.links[0].href,
+ window.location.href.replace(/bugs\/test_bug132255\.html/, "foo.html"),
+ "Unexpected anchor href");
+ is(window.frames[1].document.links[0].href,
+ "http://example.com/foo.html",
+ "Unexpected anchor href when base set");
+})
+addLoadEvent(SimpleTest.finish);
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug159849.html b/dom/tests/mochitest/bugs/test_bug159849.html
new file mode 100644
index 000000000..ed5ddf19a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug159849.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=159849
+-->
+<head>
+ <title>Test for Bug 159849</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=159849">Mozilla Bug 159849</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 159849 **/
+function testFunc() {
+}
+
+var c = $("content");
+with (c) {
+ onmouseover = testFunc;
+ fooExpando = testFunc;
+}
+
+is(c.onmouseover, testFunc, "Event handler should have been set on node");
+ok(c.fooExpando === undefined, "Expando should not have been set on node",
+ "got " + repr(c.fooExpando) + ", expected undefined");
+ok(window.onmouseover === null,
+ "Event handler should not have been set on window",
+ "got " + repr(window.onmouseover) + ", expected undefined");
+is(window.fooExpando, testFunc, "Expando should have been set on window");
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug260264.html b/dom/tests/mochitest/bugs/test_bug260264.html
new file mode 100644
index 000000000..420281858
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug260264.html
@@ -0,0 +1,198 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=260264
+-->
+<head>
+ <title>Test for Bug 260264</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="utils_bug260264.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=260264">Mozilla Bug 260264</a>
+<p id="display">
+ <a id="link" href="javascript:(function(){})()">link</a>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 260264 **/
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+var a = $("link"),
+ checkOpened = function() { ok(window.open("http://example.com"), "not properly opened") },
+ checkBlocked = function() { ok(!window.open("http://example.com"), "not properly blocked") };
+
+
+function run_tests() {
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ window.open.close().then(() => {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}, run_tests2);
+ });
+}
+
+function run_tests2() {
+ for (var count = 0, n = 0; n < 3; n++)
+ send(a, "mouseup", function() { if (window.open("http://example.com")) count++ });
+ send(a, "mouseup", checkBlocked);
+ window.open.close(1).then(() => {
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkBlocked);
+ send(a, "mouseup", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ ok(count > 0, "Windows left open by previous tests?");
+ while (count --> 0)
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 2]]}, run_tests3);
+ });
+}
+
+function run_tests3() {
+ send(a, "mouseover", checkBlocked);
+ window.open.close().then(() => {
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': ALLOW_ACTION, 'context': document}], function() {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}, run_tests4);
+ });
+ });
+}
+
+function run_tests4() {
+ var count;
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ window.open.close().then(() => {
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkOpened);
+ return window.open.close();
+ }).then(() => {
+ for (count = 0, n = 0; n < 3; n++)
+ send(a, "mouseover", function() { if (window.open("http://example.com")) count++ });
+ send(a, "mouseover", checkBlocked);
+ return window.open.close(1);
+ }).then(() => {
+ send(a, "mouseover", checkOpened);
+ send(a, "mouseover", checkBlocked);
+ send(a, "mouseover", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ ok(count > 0, "Windows left open by previous tests?");
+ while (count --> 0)
+ send(a, "mouseover", checkOpened);
+ send(a, "mouseover", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events", "click"]]}, run_tests5);
+ });
+}
+
+function run_tests5() {
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': DENY_ACTION, 'context': document}], run_tests6);
+}
+
+function run_tests6() {
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ window.open.close().then(() => {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 2]]}, run_tests7);
+ });
+}
+
+function run_tests7() {
+ send(a, "mouseup", checkBlocked);
+ window.open.close().then(() => {
+ send(a, "mouseover", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': ALLOW_ACTION, 'context': document}], function() {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}, run_tests8);
+ });
+ });
+}
+
+function run_tests8() {
+ var count;
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ send(a, "click", checkOpened);
+ window.open.close().then(() => {
+ for (count = 0, n = 0; n < 3; n++)
+ send(a, "mouseup", function() { if (window.open("http://example.com")) count++ });
+ send(a, "mouseup", checkBlocked);
+ return window.open.close(1);
+ }).then(() => {
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkBlocked);
+ send(a, "mouseup", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ ok(count > 0, "Windows left open by previous tests?");
+ while (count --> 0)
+ send(a, "mouseup", checkOpened);
+ send(a, "mouseup", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ for (count = 0, n = 0; n < 3; n++)
+ send(a, "mouseover", function() { if (window.open("http://example.com")) count++ });
+ send(a, "mouseover", checkBlocked);
+ return window.open.close(1);
+ }).then(() => {
+ send(a, "mouseover", checkOpened);
+ send(a, "mouseover", checkBlocked);
+ send(a, "mouseover", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ ok(count > 0, "Windows left open by previous tests?");
+ while (count --> 0)
+ send(a, "mouseover", checkOpened);
+ send(a, "mouseover", checkBlocked);
+ return window.open.close();
+ }).then(() => {
+ SimpleTest.finish();
+ });
+}
+
+function check_sanity() {
+ ok(SpecialPowers.testPermission('popup', UNKNOWN_ACTION, document), 'popup value should have UNKNOWN permission');
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': true, 'context': document}], check_sanity2);
+}
+
+function check_sanity2() {
+ ok(SpecialPowers.testPermission('popup', ALLOW_ACTION, document), 'popup value should have ALLOW permission');
+ SpecialPowers.pushPrefEnv({"set": [["dom.disable_open_during_load", true],
+ ["dom.popup_allowed_events", "click mouseup"],
+ ["dom.popup_maximum", 3]]}, function() {
+ // Note: UNKNOWN_ACTION is the same as DENY_ACTION.
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': DENY_ACTION, 'context': document}], run_tests);
+ });
+}
+
+setTimeout(function() {
+ SpecialPowers.pushPermissions([{'type': 'popup', 'remove': true, 'context': document}], check_sanity);
+}, 200);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug260264_nested.html b/dom/tests/mochitest/bugs/test_bug260264_nested.html
new file mode 100644
index 000000000..230324389
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug260264_nested.html
@@ -0,0 +1,138 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=260264
+-->
+<head>
+ <title>Test for Bug 260264</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="utils_bug260264.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=260264">Mozilla Bug 260264</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 260264 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function makeIframe(aEvent) {
+ var tempURL = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')+1);
+ tempURL = 'http://example.com' + tempURL + "child_bug260264.html#" + aEvent;
+ $("display").appendChild(document.createElement("iframe")).src = tempURL;
+}
+
+function test_nested_frames() {
+ SpecialPowers.pushPrefEnv({"set": [["dom.disable_open_during_load", true]]}, test_nested_frames2);
+}
+
+function test_nested_frames2() {
+ // Grandchild will use this name to refer to the current window:
+ window.name = "parent260264";
+
+ if (tests[0]) {
+ tests[0].setup(function() {makeIframe(tests[0].event);});
+ } else {
+ ok(false, "There should have run 8 tests here");
+ SimpleTest.finish();
+ }
+}
+
+function should_have_blocked(popup) {
+ ok(!popup, "popup should have been blocked");
+}
+
+function should_not_have_blocked(popup) {
+ ok(popup, "popup should not have been blocked");
+}
+
+function setupPP(aAllowedEvents, aPopup1, aPopup2, aNext) {
+ SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events", aAllowedEvents]]}, function() {
+ SpecialPowers.pushPermissions([{'type': 'popup', 'allow': aPopup1, 'context': document},
+ {'type': 'popup', 'allow': aPopup2, 'context': 'http://example.com'}], aNext);
+ });
+}
+
+/**
+ * The example_priv (DENY_ACTION) parameter controls whether or not the child frame has
+ * popup clearance. Neither the top window nor the grandchild frame have
+ * this clearance. The point of these tests is to make sure the child's
+ * clearance (or lack thereof) is properly considered when opening a popup
+ * from the grandchild.
+*/
+
+var tests = [
+ { event: "mouseup",
+ setup: function(aNext) {
+ setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ },
+ { event: "mouseup",
+ setup: function(aNext) {
+ setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ },
+ { event: "mouseup",
+ setup: function(aNext) {
+ setupPP("click", ALLOW_ACTION, ALLOW_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ },
+ { event: "mouseup",
+ setup: function(aNext) {
+ setupPP("click", DENY_ACTION, DENY_ACTION, aNext);
+ },
+ report: should_have_blocked
+ },
+ { event: "mouseover",
+ setup: function(aNext) {
+ setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext);
+ },
+ report: should_have_blocked
+ },
+ { event: "mouseover",
+ setup: function(aNext) {
+ setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ },
+ { event: "click",
+ setup: function(aNext) {
+ setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ },
+ { event: "click",
+ setup: function(aNext) {
+ setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext);
+ },
+ report: should_not_have_blocked
+ }
+];
+
+// Visible to child windows:
+function report(popup) {
+ tests[0].report(popup);
+ tests.shift();
+
+ if (tests[0]) {
+ tests[0].setup(function() {makeIframe(tests[0].event);});
+ } else {
+ SimpleTest.finish();
+ }
+}
+
+test_nested_frames();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug265203.html b/dom/tests/mochitest/bugs/test_bug265203.html
new file mode 100644
index 000000000..e5fe713f5
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug265203.html
@@ -0,0 +1,110 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=265203
+-->
+<head>
+ <title>Test for Bug 265203</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=265203">Mozilla Bug 265203</a>
+<p id="display">
+<a id="a1" href="http://www.mozilla.org">Mozilla</a><a id="a2"
+ href="http://www.mozilla.org/products/firefox">Firefox</a><br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 100%;">
+ <tbody>
+
+ <tr>
+ <td style="vertical-align: top;"><a id="a3" href="http://www.mozilla.org">Mozilla</a></td>
+ <td style="vertical-align: top;"><a
+ href="http://www.mozilla.org/products/firefox">Firefox</a></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;"><a href="http://www.mozilla.org">Mozilla</a></td>
+ <td style="vertical-align: top;"><a
+ href="http://www.mozilla.org/products/firefox">Firefox</a></td>
+
+ </tr>
+ </tbody>
+</table>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 265203 **/
+var gTestStarted = false;
+var expectedResult = [ null, 0, null ];
+var nextTest;
+var test = 0;
+
+function testFocus() {
+ var selection = window.getSelection()
+ is(selection.focusNode, expectedResult[0],"test" + test + ": " + "caret node");
+ is(selection.focusOffset, expectedResult[1],"test" + test + ": " + "caret offset");
+ is(document.activeElement, expectedResult[2],"test" + test + ": " + "focused node");
+ ++test;
+ if (nextTest)
+ nextTest();
+}
+
+function test0() {
+ $("a1").focus();
+ expectedResult = [ $("a1"), 0, $("a1") ]
+ nextTest = test1;
+ testFocus();
+}
+function test1() {
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ expectedResult = [ $("a1").firstChild, 7, $("a2") ]
+ nextTest = test2;
+ testFocus();
+}
+function test2() {
+ $("a3").focus();
+ expectedResult = [ $("a3"), 0, $("a3") ]
+ nextTest = test3;
+ testFocus();
+}
+function test3() {
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ synthesizeKey("VK_RIGHT", { });
+ expectedResult = [ $("a3").firstChild, 7, $("a3") ]
+ nextTest = SimpleTest.finish;
+ testFocus();
+}
+
+function startTest() {
+ if (gTestStarted)
+ return;
+ gTestStarted = true;
+ // Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown
+ // events
+ SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true], ["snav.enabled", false]]}, test0);
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(startTest);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug289714.html b/dom/tests/mochitest/bugs/test_bug289714.html
new file mode 100644
index 000000000..e52e375e4
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug289714.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=289714
+-->
+<head>
+ <title>Test for Bug 289714</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=289714">Mozilla Bug 289714</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+let xhr = new XMLHttpRequest(),
+ expectedResponseText = "<?xml version='1.0' encoding='shift-jis'?><xml>" +
+ (new Array(1 << 13)).join("こんにちは") +
+ "</xml>";
+xhr.open("GET", "bug289714.sjs");
+xhr.onprogress = function() {
+ let text = xhr.responseText;
+ is(text, expectedResponseText.substring(0, text.length),
+ "Data before OnStopRequest is decoded properly");
+ xhr.onprogress = undefined;
+}
+xhr.onload = xhr.onerror = function() {
+ is(xhr.responseText, expectedResponseText,
+ "Final response is decoded properly");
+ SimpleTest.finish();
+}
+xhr.send();
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug291377.html b/dom/tests/mochitest/bugs/test_bug291377.html
new file mode 100644
index 000000000..1d3de1dfc
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug291377.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=291377
+-->
+<head>
+ <title>Test for Bug 291377</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=291377">Mozilla Bug 291377</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Bug 291377 **/
+/* Do something that causes an XPConnect exception */
+var threw = true;
+try {
+ window.location.port = -2;
+ threw = false;
+} catch (e) {
+ /* Check that we can touch various properties */
+ isnot(e.lineNumber, undefined, "Unexpected line number"); //This line number is dependent on the implementation of the SpecialPowers API
+ is(e.name, "NS_ERROR_MALFORMED_URI", "Unexpected exception name");
+ is(e.message, "", "Should not have a message for this case");
+ isnot(e.result, 0, "Should have a result");
+
+ is(e.result, SpecialPowers.Cr.NS_ERROR_MALFORMED_URI);
+}
+
+is(threw, true, "We need a different testcase for XPConnect exceptions?");
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug291653.html b/dom/tests/mochitest/bugs/test_bug291653.html
new file mode 100644
index 000000000..1543cdd96
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug291653.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=291653
+-->
+<head>
+ <title>Test for Bug 291653</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=291653">Mozilla Bug 291653</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 291653 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+var secondListenerDidRun = false;
+
+var w;
+function start() {
+ if ("showModalDialog" in window) {
+ w = window.open("file_bug291653.html", "foo", "width=300,height=300");
+ } else {
+ // window.showModalDialog doesn't exist in e10s mode, nothing to do in this test.
+ ok(true, "nothing to do in e10s mode");
+ SimpleTest.finish();
+ }
+}
+
+function closeTest() {
+ w.setTimeout("close()", 0);
+ setTimeout("finish()", 500);
+}
+
+function finish() {
+ ok(!secondListenerDidRun, "Shouldn't have run second listener!");
+ SimpleTest.finish();
+}
+
+function end() {
+ setTimeout("closeTest()", 500);
+}
+
+start();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug304459.html b/dom/tests/mochitest/bugs/test_bug304459.html
new file mode 100644
index 000000000..baf25d570
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug304459.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=304459
+-->
+<head>
+ <title>Test for Bug 304459</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=304459">Mozilla Bug 304459</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe id="frame"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 304459 **/
+
+function iframeLoaded()
+{
+ var frame = document.getElementById("frame");
+ frame.onload = undefined;
+ frame.src = "http://example.org/tests/dom/tests/mochitest/bugs/iframe_bug304459-2.html";
+}
+
+function receiveMessage(evt)
+{
+ ok(evt.data, "Prototype leaks across navigation");
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+window.addEventListener("message", receiveMessage, false);
+
+var frame = document.getElementById("frame");
+frame.onload = iframeLoaded;
+frame.src = "iframe_bug304459-1.html"
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug308856.html b/dom/tests/mochitest/bugs/test_bug308856.html
new file mode 100644
index 000000000..4d32535c2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug308856.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=308856
+-->
+<head>
+ <title>Test for Bug 308856</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=308856">Mozilla Bug 308856</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 308856 **/
+
+var monkey = 12;
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ is(12,window.monkey,"Window global is correct value");
+ var found = false;
+ for (var p in window) {
+ if (p == "monkey") {
+ found = true;
+ }
+ }
+ ok(found, "Global js variables show up when enumerating [Window]");
+});
+addLoadEvent(SimpleTest.finish);
+
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug327891.html b/dom/tests/mochitest/bugs/test_bug327891.html
new file mode 100644
index 000000000..61a0771a3
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug327891.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=327891
+-->
+<head>
+ <title>Test for Bug 327891</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=327891">Mozilla Bug 327891</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+var pass = false;
+
+try {
+ new HTMLDocument();
+} catch(e) {
+ pass = true;
+}
+
+ok(pass, "new HTMLDocument() should have thrown");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug333983.html b/dom/tests/mochitest/bugs/test_bug333983.html
new file mode 100644
index 000000000..d5ea7abee
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug333983.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=333983
+-->
+<head>
+ <title>Test for Bug 333983</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=333983">Mozilla Bug 333983</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 333983 **/
+HTMLElement.prototype.foopy = function () { return "foopy"; }
+
+var foopy = "";
+try {
+ foopy = document.body.foopy()
+} catch (ex) {
+ foopy = ex + "";
+}
+
+is(foopy, "foopy", "HTMLElement.prototype functions work");
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug335976.xhtml b/dom/tests/mochitest/bugs/test_bug335976.xhtml
new file mode 100644
index 000000000..39137eb64
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug335976.xhtml
@@ -0,0 +1,68 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=335976
+-->
+<head>
+ <title>Test for Bug 335976</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=335976">Mozilla Bug 335976</a>
+<p id="display"></p>
+
+<iframe src="data:application/xhtml+xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;body&gt; &lt;textbox xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'/&gt; &lt;/body&gt;&lt;/html&gt;" style="width: 95%; height: 150px;"></iframe>
+
+<div id="rootish" style="background: yellow">
+ <div>
+ <textbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
+ </div>
+</div>
+
+
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+function lookAtTextboxesIn(root, numExpected)
+{
+ var textboxes = root.getElementsByTagName("textbox");
+ var threw;
+ var i;
+ var n;
+
+ for (i = 0; n = textboxes[i]; ++i) {
+ threw = true;
+ try { n.nodeType; threw = false; } catch(e) { }
+ ok(!threw, "n.nodeType threw");
+ }
+
+ ok(textboxes.length == numExpected, "Wrong number of textboxes");
+}
+
+function init()
+{
+ // Look at the textbox in the yellow div.
+ lookAtTextboxesIn(document.getElementById('rootish'), 1);
+
+ // Move the yellow div into the iframe.
+ var nd = window.frames[0].document;
+ nd.body.appendChild(nd.adoptNode(document.getElementById('rootish')));
+
+ // Look at the textboxes in the iframe.
+ lookAtTextboxesIn(window.frames[0].document.body, 2);
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(init);
+
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug342448.html b/dom/tests/mochitest/bugs/test_bug342448.html
new file mode 100644
index 000000000..f5cd05151
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug342448.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=342448
+-->
+<head>
+ <title>Test for Bug 342448</title>
+ <script type="text/javascript" src="/MochiKit/Base.js"></script>
+ <script type="text/javascript" src="/MochiKit/Async.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=342448">Mozilla Bug 342448</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 342448 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+try {
+setTimeout(1, 0);
+} catch (ex) {}
+callLater(.1, function() { ok(true, "shouldn't crash when passing a number as the first arg to setTimeout"); SimpleTest.finish(); })
+
+
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug345521.html b/dom/tests/mochitest/bugs/test_bug345521.html
new file mode 100644
index 000000000..ce98016bf
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug345521.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=345521
+-->
+<head>
+ <title>Test for Bug 345521</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=345521">Mozilla Bug 345521</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <a id="testlink" onclick="return 0">test</a><br />
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 345521 **/
+function hitlink() {
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ var isOk = $("testlink").dispatchEvent(evt);
+ ok(isOk, "return 0 should not cancel an event");
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(hitlink);
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug346659.html b/dom/tests/mochitest/bugs/test_bug346659.html
new file mode 100644
index 000000000..78c1fc659
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug346659.html
@@ -0,0 +1,163 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=346659
+-->
+<head>
+ <title>Test for Bug 346659</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=346659">Mozilla Bug 346659</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 346659 **/
+var numTests = 10;
+SimpleTest.requestLongerTimeout(2); // test takes a long time on android and b2g emulators
+SimpleTest.waitForExplicitFinish();
+
+var wins = [];
+
+function r(base, tail) {
+ return base.replace(/\/[^\/]*$/, "/" + tail);
+}
+
+function handleCmd(evt) {
+ var cmd;
+ try {
+ cmd = JSON.parse(evt.data);
+ } catch (e) {
+ // Not json
+ return false;
+ }
+
+ // Grab privileges so we can access cross-domain windows
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ if ("load" in cmd) {
+ var testNum = cmd.load;
+ var win = wins[testNum];
+ win.childWin.x = testNum;
+ if (win.childWin.opener == win) {
+ if ("xsite" in cmd) {
+ var loc = r(window.location.href, "bug346659-opener-echoer.html");
+ } else {
+ var loc = r(win.location.href, "bug346659-opener-echoer.html");
+ }
+ } else {
+ if ("xsite" in cmd) {
+ var loc = r(window.location.href, "bug346659-parent-echoer.html");
+ } else {
+ var loc = r(win.location.href, "bug346659-parent-echoer.html");
+ }
+ }
+ win.childWin.location.href = loc;
+ wins[testNum] = null;
+ } else if ("write" in cmd) {
+ var testNum = cmd.write;
+ var win = wins[testNum];
+ win.childWin.x = testNum;
+ try {
+ if (win.childWin.opener == win) {
+ win.childWin.document.write('<script>window.opener.opener.postMessage(window.opener.testNum + " - " + window.x, "http://mochi.test:8888/"); window.opener.close(); window.close();<' + '/script>');
+ } else {
+ win.childWin.document.write('<script>window.parent.opener.postMessage(window.parent.testNum + " - " + window.x, "http://mochi.test:8888/"); window.parent.close();<' + '/script>');
+ }
+ } catch (e if (e.name == "SecurityError" && e.code == 18)) {
+ // Security error on cross-site write() is fine
+ if (win.childWin.opener == win) {
+ win.childWin.close();
+ }
+ win.close()
+ handleTestEnd();
+ }
+ wins[testNum] = null;
+ }
+ return true;
+}
+
+function messageReceiver(evt) {
+ // First try to detect a load/write command
+ if (handleCmd(evt)) {
+ return;
+ }
+
+ var testNumber = parseInt(evt.data);
+ var testResult = evt.data.substring(3 + Math.floor(Math.log(testNumber) * Math.LOG10E + 1));
+
+ switch (testNumber) {
+ case 1:
+ is(testResult, "1", "Props on new window should be preserved when loading");
+ break;
+ case 2:
+ is(testResult, "2", "Props on new window should be preserved when writing");
+ break;
+ case 3:
+ is(testResult, "3", "Props on window opened from new window should be preserved when loading");
+ break;
+ case 4:
+ is(testResult, "4", "Props on window opened from new window should be preserved when writing");
+ break;
+ case 5:
+ is(testResult, "undefined", "Props on new window's child should go away when loading");
+ break;
+ case 6:
+ is(testResult, "undefined", "Props on new window's child should go away when writing");
+ break;
+ case 7:
+ is(testResult, "7", "Props on different-domain window opened from different-domain new window can stay");
+ break;
+ case 9:
+ is(testResult, "undefined", "Props on different-domain new window's child should go away when loading");
+ break;
+ case 11:
+ is(testResult, "undefined", "Props on same-domain window opened from different-domain new window should go away when loading");
+ break;
+ case 12:
+ is(testResult, "undefined", "Props on different-domain new window's same-domain child should go away when loading");
+ break;
+ default:
+ ok(0, "unexpected test number (" + testNumber + ") when data is " + evt.data);
+ }
+
+ handleTestEnd();
+}
+
+function handleTestEnd() {
+ if (!--numTests) {
+ SimpleTest.finish();
+ }
+}
+window.addEventListener("message", messageReceiver, false);
+
+var win = window.open("");
+win.x = 1;
+win.location.href = "bug346659-echoer.html";
+
+win = window.open("");
+win.x = 2;
+win.document.write('<script> window.opener.postMessage("2 - " + window.x, window.location.href); window.close(); </' + 'script>');
+
+wins[3] = window.open('bug346659-opener.html?{"load":3}');
+wins[4] = window.open('bug346659-opener.html?{"write":4}');
+wins[5] = window.open('bug346659-parent.html?{"load":5}');
+wins[6] = window.open('bug346659-parent.html?{"write":6}');
+
+is(location.host, "mochi.test:8888", "Unexpected host");
+
+var baseurl = window.location.href.replace(/mochi\.test:8888/, "example.com");
+wins[7] = window.open(r(baseurl, 'bug346659-opener.html?{"load":7}'));
+wins[9] = window.open(r(baseurl, 'bug346659-parent.html?{"load":9}'));
+
+wins[11] = window.open(r(baseurl, 'bug346659-opener.html?{"load":11,"xsite":true}'));
+wins[12] = window.open(r(baseurl, 'bug346659-parent.html?{"load":12,"xsite":true}'));
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug351601.html b/dom/tests/mochitest/bugs/test_bug351601.html
new file mode 100644
index 000000000..af7c2d590
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug351601.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=351601
+-->
+<head>
+ <title>Test for Bug 351601</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=351601">Mozilla Bug 351601</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 351601 **/
+
+var isOK = false;
+try {
+ var foo = navigator.buildID;
+ isOK = true;
+} catch (ex) {
+}
+ok(isOK, "navigator.buildID should never throw");
+
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug369306.html b/dom/tests/mochitest/bugs/test_bug369306.html
new file mode 100644
index 000000000..c35431a56
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug369306.html
@@ -0,0 +1,137 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=369306
+-->
+<head>
+ <title>Test for Bug 369306</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=369306">Mozilla Bug 369306</a>
+<p id="display"></p>
+<div id='content'>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 369306 **/
+
+var originatingWindow = self;
+
+function focusShouldNotChange(aAction, nextTest)
+{
+ var w = window.open('about:blank', '', 'foo');
+ var fail = false;
+
+ SimpleTest.waitForFocus(function () {
+ function failHandler() { fail = true; }
+
+ originatingWindow.addEventListener("focus", failHandler, false);
+ w.addEventListener("blur", failHandler, false);
+
+ aAction(w);
+
+ SimpleTest.executeSoon(function () {
+ originatingWindow.removeEventListener("focus", failHandler, false);
+ w.removeEventListener("blur", failHandler, false);
+
+ ok(!fail, "The focus should not have been changed!");
+
+ // Cleaning and running next test.
+ w.close();
+ SimpleTest.waitForFocus(nextTest, originatingWindow);
+ });
+ }, w, true);
+}
+
+function focusShouldNotChange2(aURL, nextTest)
+{
+ var w = window.open(aURL, '', 'foo');
+ var fail = false;
+
+ SimpleTest.waitForFocus(function () {
+ function failHandler() { fail = true; }
+
+ originatingWindow.addEventListener("focus", failHandler, false);
+ w.addEventListener("blur", failHandler, false);
+
+ /**
+ * NOTE: This setTimeout can cause a random green.
+ * onload handler + executeSoon doesn't work too so we have to use setTimeout.
+ * The check may be call before w script being executed but that would make
+ * this check green even if it should be orange.
+ */
+ setTimeout(function () {
+ originatingWindow.removeEventListener("focus", failHandler, false);
+ w.removeEventListener("blur", failHandler, false);
+
+ ok(!fail, "The focus should not have been changed with URL=" + aURL);
+
+ // Cleaning and running next test.
+ w.close();
+ SimpleTest.waitForFocus(nextTest, originatingWindow);
+ }, 1000);
+ }, w);
+}
+
+function test1()
+{
+ focusShouldNotChange(function (aW) { aW.blur(); }, test2);
+}
+
+function test2()
+{
+ focusShouldNotChange(function () { originatingWindow.focus(); }, test3);
+}
+
+function test3()
+{
+ focusShouldNotChange2("data:text/html,\<script>opener.focus();\<\/script>", test4);
+}
+
+function test4()
+{
+ focusShouldNotChange2("data:text/html,\<script>blur();\<\/script>", test5);
+}
+
+function test5()
+{
+ var w = window.open('about:blank', '', 'foo');
+
+ SimpleTest.waitForFocus(function () {
+ SimpleTest.waitForFocus(function () {
+ SimpleTest.waitForFocus(function () {
+ ok(true, "The last opened window should be able to get focus");
+ w.close();
+ SimpleTest.executeSoon(SimpleTest.finish);
+ }, w, true);
+
+ w.focus();
+ }, originatingWindow);
+
+ SimpleTest.executeSoon(function() {
+ // We have to focus back the originating window but we can't do that with
+ // .focus() or .blur() anymore.
+ SpecialPowers.focus(window);
+ });
+ }, w, true);
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+function startTest() {
+ // dom.disable_window_flip has to be set to true for this test.
+ SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_flip", true]]}, test1);
+}
+
+// startTest is going to call the next tests.
+SimpleTest.waitForFocus(startTest);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug370098.html b/dom/tests/mochitest/bugs/test_bug370098.html
new file mode 100644
index 000000000..e0a06338f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug370098.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=370098
+-->
+<head>
+ <title>Test for Bug 370098</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370098">Mozilla Bug 370098</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Bug 370098 **/
+function test_constructor(dom_proto, shouldthrow) {
+ var threw = false;
+ try {
+ window[dom_proto]();
+ } catch (e) {
+ threw = true;
+ }
+ // XSLTProcessor is still on the old bindings.
+ if (dom_proto != 'XSLTProcessor')
+ ok(threw, "Calling |" + dom_proto + "()| should always throw");
+
+ threw = false;
+ try {
+ new window[dom_proto]();
+ } catch (e) {
+ threw = true;
+ }
+ is(threw, shouldthrow, "Calling |new " + dom_proto + "()| should" + (shouldthrow ? " " : " not ") + "throw");
+}
+var dom_protos = [ "Element" ];
+var dom_constructors = [ "Document", "Image", "DOMParser", "XMLSerializer",
+ "XMLHttpRequest", "XPathEvaluator", "XSLTProcessor" ];
+dom_protos.forEach(
+ function(p) { test_constructor(p, true); });
+dom_constructors.forEach(
+ function(p) { test_constructor(p, false); });
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug377539.html b/dom/tests/mochitest/bugs/test_bug377539.html
new file mode 100644
index 000000000..37b3041d9
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug377539.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=377539
+-->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <title>Testcase for bug 377539</title>
+
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377539">Mozilla Bug 377539</a>
+
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+
+<script type="text/javascript">
+var sw;
+var child_sw = -1;
+
+function test(){
+ var t = '<div style="display: none;"><iframe onload="doChecks()" src="data:text/html,<body><scr'+'ipt>try {parent.child_sw=screen.width}catch(e){}</scr'+'ipt>"></iframe></div>';
+ var div = document.createElement('div');
+ div.innerHTML = t;
+ document.getElementsByTagName('body')[0].appendChild(div);
+}
+
+try {
+ sw = screen.width;
+} catch (e) {
+ sw = -1;
+}
+
+</script>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+function doChecks() {
+ isnot(sw, -1, "screen.width threw an exception");
+ is(child_sw, sw, "iframe got wrong screen.width");
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+test();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug384122.html b/dom/tests/mochitest/bugs/test_bug384122.html
new file mode 100644
index 000000000..be40c35f7
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug384122.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=384122
+-->
+<head>
+ <title>Test for Bug 384122</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=384122">Mozilla Bug 384122</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 384122 **/
+
+var foundQI = false;
+for (var property in Node)
+ if (property == "QueryInterface")
+ foundQI = true;
+is(foundQI, false,
+ "QueryInterface should not be enumerable on DOM interface objects");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug389366.html b/dom/tests/mochitest/bugs/test_bug389366.html
new file mode 100644
index 000000000..7567bacc5
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug389366.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=389366
+-->
+<head>
+ <title>Test for Bug 389366</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389366">Mozilla Bug 389366</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <h4>Canvas testcase</h4>
+
+ Canvas, with pixel set to #ff0000 at 50% opacity:<br>
+ <canvas id="canvas1" width="10" height="10"></canvas>
+ <br>
+ <canvas id="canvas2" width="10" height="10"></canvas>
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function test()
+{
+ // Draw to canvas1
+ var canvas1 = document.getElementById("canvas1");
+ var ctx1 = canvas1.getContext("2d");
+
+ ctx1.globalAlpha = 0.502;
+ ctx1.fillStyle = "#FF0000";
+ ctx1.fillRect(0, 0, 10, 10);
+
+ var data1 = ctx1.getImageData(0,0,1,1).data;
+ isDeeply(data1, [255, 0, 0, 128], "expected half-transparent red canvas 1");
+
+ // half-transparent red 10x10 square
+ var imgData = ctx1.createImageData(10, 10);
+ var rgba = [ 255, 0, 0, 128 ];
+ for (i = 0; i < 50; ++i) {
+ for (j = 0; j < 4; ++j) {
+ imgData.data[(i * 4) + j] = rgba[j];
+ }
+ }
+
+ var canvas2 = document.getElementById("canvas2");
+ var ctx2 = canvas2.getContext("2d");
+ ctx2.putImageData(imgData, 0, 0);
+
+ var data2 = ctx2.getImageData(0,0,1,1).data;
+ isDeeply(data2, [255, 0, 0, 128], "expected half-transparent red canvas 2");
+
+ SimpleTest.finish();
+}
+
+addLoadEvent(test);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug38959.html b/dom/tests/mochitest/bugs/test_bug38959.html
new file mode 100644
index 000000000..a8d07d1a6
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug38959.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=38959
+-->
+<head>
+ <title>Test for Bug 38959</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=38959">Mozilla Bug 38959</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe id="frame"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 38959 **/
+
+var newValue;
+
+function watcher(id, ol, ne)
+{
+ newValue = ne;
+ return ne;
+}
+
+function openWindow(url, crossOrigin)
+{
+ newValue = true;
+ var w = window.open(url);
+ w.watch("x", watcher);
+}
+
+function receiveMessage(evt)
+{
+ ok(newValue, "Watchpoints only allowed same-origin.");
+ if (evt.data == 1) {
+ openWindow("/tests/dom/tests/mochitest/bugs/iframe_bug38959-2.html");
+ }
+ else {
+ SimpleTest.finish();
+ }
+}
+
+SimpleTest.waitForExplicitFinish();
+
+window.addEventListener("message", receiveMessage, false);
+
+openWindow("http://example.org/tests/dom/tests/mochitest/bugs/iframe_bug38959-1.html");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug393974.html b/dom/tests/mochitest/bugs/test_bug393974.html
new file mode 100644
index 000000000..fbdcbfcdc
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug393974.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=393974
+-->
+<head>
+ <title>Test for Bug 393974</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=393974">Mozilla Bug 393974</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function test()
+{
+ // Create a tree walker with a filter which creates a cycle...
+ var tw = document.createTreeWalker(document, NodeFilter.SHOW_ALL,
+ function(n)
+ {
+ // force the closure to contain the
+ // global object, in case a future
+ // optimization might minimize the
+ // function's captured environment
+ if ("foo" + window == "fooPIRATES!")
+ return NodeFilter.FILTER_ACCEPT;
+ return NodeFilter.FILTER_REJECT;
+ });
+
+ // That should have been enough to create a leak, but we should do at least
+ // a couple tests while we're here so that this document doesn't show up as
+ // having no tests pass *or* fail.
+
+ ok(tw.firstChild() === null, "shouldn't be a first child");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.lastChild() === null, "shouldn't be a last child");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.nextNode() === null, "shouldn't be a next node");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.nextSibling() === null, "shouldn't be a next sibling");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.parentNode() === null, "shouldn't be a parent node");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.previousNode() === null, "shouldn't be a previous node");
+ ok(tw.currentNode === document, "should be unchanged");
+
+ ok(tw.previousSibling() === null, "shouldn't be a previous sibling");
+ ok(tw.currentNode === document, "should be unchanged");
+}
+
+addLoadEvent(test);
+addLoadEvent(SimpleTest.finish);
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug394769.html b/dom/tests/mochitest/bugs/test_bug394769.html
new file mode 100644
index 000000000..c9925269f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug394769.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=394769
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 394769</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=394769">Mozilla Bug 394769</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 394769 **/
+SimpleTest.waitForExplicitFinish();
+function h() {
+ is(arguments.length, 1, "Should only have one argument");
+ SimpleTest.finish();
+}
+
+function g() {
+ is(arguments.length, 0, "Should not have lateness argument for function with delay");
+ setTimeout(h, 0, "arg");
+}
+
+function f() {
+ is(arguments.length, 0, "Should not have lateness argument for function with no delay");
+ setTimeout(g, 0);
+}
+
+setTimeout(f);
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug396843.html b/dom/tests/mochitest/bugs/test_bug396843.html
new file mode 100644
index 000000000..20dc53068
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug396843.html
@@ -0,0 +1,242 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=396843
+-->
+<head>
+ <title>Test for Bug 396843</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396843">Mozilla Bug 396843</a>
+<p id="display">
+ <iframe src="http://example.org:80/" id="t"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 396843 **/
+SimpleTest.waitForExplicitFinish();
+
+var allNodes = [];
+var XMLNodes = [];
+
+// HTML
+function HTML_TAG(name) {
+ allNodes.push(document.createElement(name));
+}
+
+/* List copy/pasted from nsHTMLTagList.h */
+HTML_TAG("a", "Anchor")
+HTML_TAG("abbr", "Span")
+HTML_TAG("acronym", "Span")
+HTML_TAG("address", "Span")
+HTML_TAG("applet", "SharedObject")
+HTML_TAG("area", "Area")
+HTML_TAG("b", "Span")
+HTML_TAG("base", "Shared")
+HTML_TAG("basefont", "Span")
+HTML_TAG("bdo", "Span")
+HTML_TAG("bgsound", "Unknown")
+HTML_TAG("big", "Span")
+HTML_TAG("blockquote", "Shared")
+HTML_TAG("body", "Body")
+HTML_TAG("br", "BR")
+HTML_TAG("button", "Button")
+HTML_TAG("canvas", "Canvas")
+HTML_TAG("caption", "TableCaption")
+HTML_TAG("center", "Span")
+HTML_TAG("cite", "Span")
+HTML_TAG("code", "Span")
+HTML_TAG("col", "TableCol")
+HTML_TAG("colgroup", "TableCol")
+HTML_TAG("dd", "Span")
+HTML_TAG("del", "Mod")
+HTML_TAG("dfn", "Span")
+HTML_TAG("dir", "Shared")
+HTML_TAG("div", "Div")
+HTML_TAG("dl", "SharedList")
+HTML_TAG("dt", "Span")
+HTML_TAG("em", "Span")
+HTML_TAG("embed", "SharedObject")
+HTML_TAG("fieldset", "FieldSet")
+HTML_TAG("font", "Font")
+HTML_TAG("form", "Form")
+HTML_TAG("frame", "Frame")
+HTML_TAG("frameset", "FrameSet")
+HTML_TAG("h1", "Heading")
+HTML_TAG("h2", "Heading")
+HTML_TAG("h3", "Heading")
+HTML_TAG("h4", "Heading")
+HTML_TAG("h5", "Heading")
+HTML_TAG("h6", "Heading")
+HTML_TAG("head", "Head")
+HTML_TAG("hr", "HR")
+HTML_TAG("html", "Html")
+HTML_TAG("i", "Span")
+HTML_TAG("iframe", "IFrame")
+HTML_TAG("image", "")
+HTML_TAG("img", "Image")
+HTML_TAG("input", "Input")
+HTML_TAG("ins", "Mod")
+HTML_TAG("isindex", "Unknown")
+HTML_TAG("kbd", "Span")
+HTML_TAG("keygen", "Span")
+HTML_TAG("label", "Label")
+HTML_TAG("legend", "Legend")
+HTML_TAG("li", "LI")
+HTML_TAG("link", "Link")
+HTML_TAG("listing", "Span")
+HTML_TAG("map", "Map")
+HTML_TAG("marquee", "Div")
+HTML_TAG("menu", "Shared")
+HTML_TAG("meta", "Meta")
+HTML_TAG("multicol", "Unknown")
+HTML_TAG("nobr", "Span")
+HTML_TAG("noembed", "Div")
+HTML_TAG("noframes", "Div")
+HTML_TAG("noscript", "Div")
+HTML_TAG("object", "Object")
+HTML_TAG("ol", "SharedList")
+HTML_TAG("optgroup", "OptGroup")
+HTML_TAG("option", "Option")
+HTML_TAG("p", "Paragraph")
+HTML_TAG("param", "Shared")
+HTML_TAG("plaintext", "Span")
+HTML_TAG("pre", "Pre")
+HTML_TAG("q", "Shared")
+HTML_TAG("s", "Span")
+HTML_TAG("samp", "Span")
+HTML_TAG("script", "Script")
+HTML_TAG("select", "Select")
+HTML_TAG("small", "Span")
+HTML_TAG("spacer", "Unknown")
+HTML_TAG("span", "Span")
+HTML_TAG("strike", "Span")
+HTML_TAG("strong", "Span")
+HTML_TAG("style", "Style")
+HTML_TAG("sub", "Span")
+HTML_TAG("sup", "Span")
+HTML_TAG("table", "Table")
+HTML_TAG("tbody", "TableSection")
+HTML_TAG("td", "TableCell")
+HTML_TAG("textarea", "TextArea")
+HTML_TAG("tfoot", "TableSection")
+HTML_TAG("th", "TableCell")
+HTML_TAG("thead", "TableSection")
+HTML_TAG("template", "Template")
+HTML_TAG("title", "Title")
+HTML_TAG("tr", "TableRow")
+HTML_TAG("tt", "Span")
+HTML_TAG("u", "Span")
+HTML_TAG("ul", "SharedList")
+HTML_TAG("var", "Span")
+HTML_TAG("wbr", "Shared")
+HTML_TAG("xmp", "Span")
+
+function SVG_TAG(name) {
+ allNodes.push(document.createElementNS("http://www.w3.org/2000/svg", name));
+}
+
+// List sorta stolen from SVG element factory.
+SVG_TAG("a")
+SVG_TAG("polyline")
+SVG_TAG("polygon")
+SVG_TAG("circle")
+SVG_TAG("ellipse")
+SVG_TAG("line")
+SVG_TAG("rect")
+SVG_TAG("svg")
+SVG_TAG("g")
+SVG_TAG("foreignObject")
+SVG_TAG("path")
+SVG_TAG("text")
+SVG_TAG("tspan")
+SVG_TAG("image")
+SVG_TAG("style")
+SVG_TAG("linearGradient")
+SVG_TAG("metadata")
+SVG_TAG("radialGradient")
+SVG_TAG("stop")
+SVG_TAG("defs")
+SVG_TAG("desc")
+SVG_TAG("script")
+SVG_TAG("use")
+SVG_TAG("symbol")
+SVG_TAG("marker")
+SVG_TAG("title")
+SVG_TAG("clipPath")
+SVG_TAG("textPath")
+SVG_TAG("filter")
+SVG_TAG("feBlend")
+SVG_TAG("feColorMatrix")
+SVG_TAG("feComponentTransfer")
+SVG_TAG("feComposite")
+SVG_TAG("feFuncR")
+SVG_TAG("feFuncG")
+SVG_TAG("feFuncB")
+SVG_TAG("feFuncA")
+SVG_TAG("feGaussianBlur")
+SVG_TAG("feMerge")
+SVG_TAG("feMergeNode")
+SVG_TAG("feMorphology")
+SVG_TAG("feOffset")
+SVG_TAG("feFlood")
+SVG_TAG("feTile")
+SVG_TAG("feTurbulence")
+SVG_TAG("feConvolveMatrix")
+SVG_TAG("feDistantLight")
+SVG_TAG("fePointLight")
+SVG_TAG("feSpotLight")
+SVG_TAG("feDiffuseLighting")
+SVG_TAG("feSpecularLighting")
+SVG_TAG("feDisplacementMap")
+SVG_TAG("feImage")
+SVG_TAG("pattern")
+SVG_TAG("mask")
+SVG_TAG("svgSwitch")
+
+// Toss in some other namespaced stuff too, for good measure
+allNodes.push(document.createElementNS(
+ "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
+ "window"));
+allNodes.push(document.createElementNS("http://www.w3.org/1998/Math/MathML",
+ "math"));
+allNodes.push(document.createElementNS("http://www.w3.org/2001/xml-events",
+ "testname"));
+allNodes.push(document.createElementNS("bogus.namespace", "testname"));
+
+var XMLDoc = document.implementation.createDocument("", "", null);
+
+// And non-elements
+allNodes.push(document.createTextNode("some text"));
+allNodes.push(document.createComment("some text"));
+allNodes.push(document.createDocumentFragment());
+XMLNodes.push(XMLDoc.createCDATASection("some text"));
+XMLNodes.push(XMLDoc.createProcessingInstruction("PI", "data"));
+
+function runTest() {
+ ok(document.nodePrincipal === undefined, "Must not have document principal");
+ ok(document.baseURIObject === undefined, "Must not have document base URI");
+ ok(document.documentURIObject === undefined, "Must have document URI");
+
+ for (var i = 0; i < allNodes.length; ++i) {
+ ok(allNodes[i].nodePrincipal === undefined,
+ "Unexpected principal appears for " + allNodes[i].nodeName);
+ ok(allNodes[i].baseURIObject === undefined,
+ "Unexpected base URI appears for " + allNodes[i].nodeName);
+ }
+}
+
+addLoadEvent(runTest);
+addLoadEvent(SimpleTest.finish);
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug400204.html b/dom/tests/mochitest/bugs/test_bug400204.html
new file mode 100644
index 000000000..44703f949
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug400204.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=400204
+-->
+<head>
+ <title>Test for Bug 400204</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=400204">Mozilla Bug 400204</a>
+<p id="display"></p>
+<iframe id="content" src="about:blank" style="display: none"></iframe>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+ var c = document.getElementById("content");
+ var success = false;
+ // try to access innerWidth
+ try { success = (c.contentWindow.innerWidth == 0); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerWidth, or it's not 0");
+
+ // try to access innerHeight
+ success = false;
+ try { success = (c.contentWindow.innerHeight == 0); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerHeight, or it's not 0");
+
+ // Snag the canonical getter and setter
+ var innerWidthGetter = Object.getOwnPropertyDescriptor(c.contentWindow, "innerWidth").get;
+ var innerHeightGetter = Object.getOwnPropertyDescriptor(c.contentWindow, "innerHeight").get;
+
+ // try to set innerWidth
+ success = false;
+ try { c.contentWindow.innerWidth = 100; success = true; } catch(ex) { success = false; }
+ ok(success, "can't set hidden iframe innerWidth");
+
+ // try to set innerHeight
+ success = false;
+ try { c.contentWindow.innerHeight = 100; success = true; } catch(ex) { success = false; }
+ ok(success, "can't set hidden iframe innerHeight");
+
+ // now try these again for good measure, and to ensure the values
+ // haven't changed except via getting replaced
+ // try to access innerWidth
+ success = false;
+ try { success = (c.contentWindow.innerWidth == 100); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerWidth, or it's not 100");
+
+ success = false;
+ try { success = (innerWidthGetter.call(c.contentWindow) == 0); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerWidth, or it's not 0");
+
+ // try to access innerHeight
+ success = false;
+ try { success = (c.contentWindow.innerHeight == 100); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerHeight, or it's not 100");
+
+ success = false;
+ try { success = (innerHeightGetter.call(c.contentWindow) == 0); } catch(ex) { success = false; }
+ ok(success, "can't access hidden iframe innerHeight, or it's not 0");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug404748.html b/dom/tests/mochitest/bugs/test_bug404748.html
new file mode 100644
index 000000000..5a5c5c190
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug404748.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=404748
+-->
+<head>
+ <title>Test for Bug 404748</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=404748">Mozilla Bug 404748</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 404748 **/
+var setterCalled = false;
+HTMLDivElement.prototype.
+ __defineSetter__("onclick", function () { window.setterCalled = true });
+$("content").onclick = function () {};
+
+is(setterCalled, true, "Setter should have been called");
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug406375.html b/dom/tests/mochitest/bugs/test_bug406375.html
new file mode 100644
index 000000000..2cd459ffa
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug406375.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=406375
+-->
+<head>
+ <title>Test for Bug 406375</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="runTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=406375">Mozilla Bug 406375</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 406375 **/
+
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+ if ("showModalDialog" in window) {
+ window.showModalDialog("file_bug406375.html");
+ }
+ ok(true, "This test should not hang");
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug414291.html b/dom/tests/mochitest/bugs/test_bug414291.html
new file mode 100644
index 000000000..883e52bb4
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug414291.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=414291
+-->
+<head>
+ <title>Test for Bug 414291</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=414291">Mozilla Bug 414291</a>
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 414291 **/
+
+var result1 = 0;
+var result2 = 0;
+var result3 = 0;
+
+window.open("data:text/html,<html><body onload='close(); opener.result1 = 1;'>", "w1");
+is(result1, 0, "window should not be opened either as modal or loaded synchronously.");
+
+window.open("data:text/html,<html><body onload='close(); opener.result2 = 2;'>", "w2", "modal=yes");
+is(result2, 0, "window should not be opened either as modal or data loaded synchronously.");
+
+if (window.showModalDialog) {
+ result3 = window.showModalDialog("data:text/html,<html><body onload='close(); returnValue = 3;'>");
+ is(result3, 3, "window should be opened as modal.");
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug427744.html b/dom/tests/mochitest/bugs/test_bug427744.html
new file mode 100644
index 000000000..faf7fda7c
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug427744.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=427744
+-->
+<head>
+ <title>Test for Bug 427744</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=427744">Mozilla Bug 427744</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 427744 **/
+
+var firstPlugin = navigator.plugins["Test Plug-in"];
+ok(firstPlugin, "Should have seen the test plugin");
+is(firstPlugin.version, "1.0.0.0", "Should have seen the right test plugin version");
+
+var secondPlugin = navigator.plugins["Second Test Plug-in"];
+ok(secondPlugin, "Should have seen the second test plugin");
+is(secondPlugin.version, "1.0.0.0", "Should have seen the right second test plugin version");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug42976.html b/dom/tests/mochitest/bugs/test_bug42976.html
new file mode 100644
index 000000000..900928d85
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug42976.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=42976
+-->
+<head>
+ <title>Test for Bug 42976</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=42976">Mozilla Bug 42976</a>
+<p id="display"></p>
+<div id="content">
+ <iframe id=specialtest src="data:text/html,<meta http-equiv='Content-Language' content='ja-JP'><base href='http://www.mozilla.org'><p>asdf"></iframe>;
+ <iframe id=htmlquirks src="data:text/html;charset=ISO-8859-2,<html><body><div></div></body></html>"></iframe>
+ <iframe id=htmlstd src="data:text/html;charset=ISO-8859-3,<!DOCTYPE html><html><body><div></div></body></html>"></iframe>
+ <iframe id=textplain src="data:text/plain;charset=ISO-8859-4,asdf%0Azxcv%0A"></iframe>
+ <iframe id=xhtmlstd src="data:application/xhtml+xml;charset=ISO-8859-5,<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><body><div></div></body></html>"></iframe>
+ <iframe id=xmlstd src="data:image/svg+xml;charset=ISO-8859-6,<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width='300' height='300'><text x='60' y='150' fill='blue'>Hello, World!</text><text x='60' y='250' fill='blue'>Hello, World!</text></svg>"></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+
+ var iframes = document.getElementsByTagName("iframe");
+ for (var i = 1; i < iframes.length; i++) {
+ var doc = iframes[i].contentDocument;
+ var clonefalse = doc.cloneNode(false);
+ // doc.compatMode
+ ok(doc.compatMode == clonefalse.compatMode, "compatMode not preserved correctly; " + iframes[i].id);
+
+ // doc.contentType
+ ok(doc.contentType == clonefalse.contentType, "contentType not preserved correctly; " + iframes[i].id);
+
+ // doc.characterSet
+ ok(doc.characterSet == clonefalse.characterSet, "charset not preserved correctly; " + iframes[i].id);
+
+ // innerHTML+tag case test
+ var clonetrue = doc.cloneNode(true);
+ doc.documentElement.firstChild.innerHTML="<div><dD></dD></div>";
+ clonetrue.documentElement.firstChild.innerHTML="<div><dD></dD></div>";
+ ok(doc.documentElement.innerHTML == clonetrue.documentElement.innerHTML,
+ "innerHTML not preserved correctly; " + iframes[i].id);
+
+ }
+
+ // A couple of tests that don't quite fit in the framework.
+ var doc = iframes[0].contentDocument;
+
+ // Setting document.dir does nothing in a document without an <html> element
+ doc.dir="rtl";
+ var docclone = doc.cloneNode(false);
+
+ // doc.dir
+ ok(docclone.dir == "", "dir set on doc without html element");
+
+ // document.querySelectorAll(":lang(ja)")
+ docclone.appendChild(docclone.createElement("html"));
+ ok(docclone.querySelectorAll(":lang(ja)").length == 1, "lang not preserved correctly");
+
+ docclone.documentElement.innerHTML="<body><p><a href='a.html' id=a>asf</a></body>";
+ ok(docclone.getElementById('a').href == "http://www.mozilla.org/a.html",
+ "base not preserved correctly");
+
+ // Now that we have an <html> element, deep cloning preserves document.dir
+ docclone.dir="rtl";
+ var cloneclone = docclone.cloneNode(true);
+
+ // doc.dir
+ ok(cloneclone.dir == "rtl", "dir not preserved correctly");
+
+ SimpleTest.finish();
+}
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug430276.html b/dom/tests/mochitest/bugs/test_bug430276.html
new file mode 100644
index 000000000..0dadb2bd2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug430276.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=430276
+-->
+<head>
+ <title>Test for Bug 430276</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=430276">Mozilla Bug 430276</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 430276 **/
+
+function startTest() {
+ document.getElementById("testFrame")
+ .setAttribute("src", "iframe_bug430276.html");
+}
+
+function nextTest() {
+ document.getElementById("testFrame")
+ .setAttribute("src", "iframe_bug430276-2.html");
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(startTest);
+
+
+</script>
+</pre>
+<iframe id="testFrame">
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug437361.html b/dom/tests/mochitest/bugs/test_bug437361.html
new file mode 100644
index 000000000..ecc2cb08d
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug437361.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=437361
+-->
+<head>
+ <title>Test for Bug 437361</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+ <script class="testbody" type="text/javascript">
+
+ /** Test for Bug 437361 **/
+
+ function testModalDialogBlockedCleanly() {
+ is(true, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
+ var rv = window.showModalDialog( // should be blocked without exception
+ "data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
+ is(rv, null, "Modal dialog opened unexpectedly.");
+ }
+
+ function testModalDialogAllowed() {
+ is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
+ var rv = window.showModalDialog( // should not be blocked this time
+ "data:text/html,<html><body onload='close(); returnValue = 1;' /></html>");
+ is(rv, 1, "Problem with modal dialog returnValue.");
+ }
+
+ function testOtherExceptionsNotTrapped() {
+ is(false, SpecialPowers.getBoolPref("dom.disable_open_during_load"), "mozprefs sanity check");
+ window.showModalDialog('about:config'); // forbidden by SecurityCheckURL
+ }
+
+ function test(disableOpen, exceptionExpected, testFn, errorMsg) {
+ if ("showModalDialog" in window) {
+ var oldPrefVal = SpecialPowers.getBoolPref("dom.disable_open_during_load");
+ try {
+ SpecialPowers.setBoolPref("dom.disable_open_during_load", disableOpen);
+ testFn();
+ ok(!exceptionExpected, errorMsg);
+ } catch (_) {
+ ok(exceptionExpected, errorMsg);
+ }
+ finally {
+ SpecialPowers.setBoolPref("dom.disable_open_during_load", oldPrefVal);
+ }
+ } else {
+ ok(true, "nothing to do in e10s mode");
+ }
+ }
+
+ test(true, false, testModalDialogBlockedCleanly,
+ "Blocked showModalDialog caused an exception.");
+
+ test(false, false, testModalDialogAllowed,
+ "showModalDialog was blocked even though dom.disable_open_during_load was false.");
+
+ test(false, true, testOtherExceptionsNotTrapped,
+ "Incorrectly suppressed insecure showModalDialog exception.");
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=437361">Mozilla Bug 437361</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug440572.html b/dom/tests/mochitest/bugs/test_bug440572.html
new file mode 100644
index 000000000..a86f14137
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug440572.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=440572
+-->
+<head>
+ <title>Test for Bug 440572</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runtests()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440572">Mozilla Bug 440572</a>
+
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 440572 **/
+
+var messages = [];
+
+function receiveMessage(e)
+{
+ is(e.origin, "http://example.org", "wrong sender!");
+ messages.push(e.data);
+}
+
+window.addEventListener("message", receiveMessage, false);
+
+function runtests()
+{
+ is(messages.length, 3, "received the right number of messages.");
+ is(messages[0], "success", "test in frame failed.");
+ isnot(messages[1], "success", "parent[\"content\"] should be the WebIDL property of Window.");
+ isnot(messages[2], "success", "parent[\"dump\"] should be the WebIDL property of Window.");
+
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+</script>
+<br>
+<iframe name="test" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe>
+<br>
+<iframe name="content" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe>
+<br>
+<iframe name="dump" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug456151.html b/dom/tests/mochitest/bugs/test_bug456151.html
new file mode 100644
index 000000000..210a60d82
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug456151.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=456151
+-->
+<head>
+ <title>Test for Bug 456151</title>
+ <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=456151">Mozilla Bug 456151</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 456151 **/
+var intercepted = false;
+
+// Set up our new addEventListener
+var proto = HTMLParagraphElement.prototype;
+proto.oldAdd = proto.addEventListener;
+proto.addEventListener = function(ev, list, capt) {
+ intercepted = true;
+ this.oldAdd(ev, list, capt);
+}
+proto.oldRemove = proto.removeEventListener;
+proto.removeEventListener = function(ev, list, capt) {
+ intercepted = true;
+ this.oldRemove(ev, list, capt);
+}
+
+var called = false;
+
+var func = function() { called = true; };
+$("display").addEventListener("click", func, false);
+is(intercepted, true, "Should have interecepted addEventListener call");
+
+sendMouseEvent({type: "click"}, "display");
+is(called, true, "Should have called event listener");
+
+interecepted = false;
+called = false;
+
+$("display").removeEventListener("click", func, false);
+is(intercepted, true, "Should have interecepted removeEventListener call");
+
+sendMouseEvent({type: "click"}, "display");
+is(called, false, "Should have removed event listener");
+
+// And now some simple sanity tests
+var recursion = false;
+var x = document.createElement("span");
+HTMLSpanElement.prototype.addEventListener =
+ function(a, b, c) {
+ return x.addEventListener(a,b,c);
+ }
+try {
+ x.addEventListener("click", function() { called = true; }, false);
+} catch (e) {
+ recursion = e.message.match(/recursion/);
+}
+SimpleTest.isDeeply(recursion, ["recursion"], "Caught infinite recursion");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug458091.html b/dom/tests/mochitest/bugs/test_bug458091.html
new file mode 100644
index 000000000..371478f1b
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug458091.html
@@ -0,0 +1,100 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=458091
+-->
+<head>
+ <title>Test for Bug 458091</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=458091">Mozilla Bug 458091</a>
+
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<a id="testlink1" target="_blank" href="javascript:window.opener.finish(sessionStorage['testItem']);window.close();">Javascript Link</a>
+<a id="testlink2" target="_blank" href="bug458091_child.html">HTTP Link</a>
+<a id="testlink3" target="alreadyOpened" href="bug458091_child.html">Target Link</a>
+<script type="application/javascript">
+
+/** Test for Bug 458091 **/
+
+var gTestWin;
+var gRunningTests = 0;
+
+function runNextTest()
+{
+ if (gTests.length > 0) {
+ var test = gTests.shift();
+ test();
+ } else {
+ SimpleTest.finish();
+ }
+}
+
+function finish(val)
+{
+ is(val, "correct value",
+ "New window should access the correct session storage");
+ if (--gRunningTests == 0) {
+ runNextTest();
+ }
+}
+
+SimpleTest.waitForExplicitFinish();
+
+function test1() {
+ sessionStorage["testItem"] = "correct value";
+
+ gRunningTests++;
+ window.open('javascript:window.opener.finish(sessionStorage["testItem"]);window.close();');
+
+ gRunningTests++;
+ window.open("bug458091_child.html");
+
+ gRunningTests++;
+ sendMouseEvent({type: "click"}, "testlink1");
+
+ gRunningTests++;
+ sendMouseEvent({type: "click"}, "testlink2");
+
+ // targetted load into an existing window
+ var testWin = window.open("about:blank", "alreadyOpened");
+ gRunningTests++;
+ sendMouseEvent({type: "click"}, "testlink3");
+
+ // window.location into an existing window. Leave the window open
+ // for further tests...
+ gRunningTests++;
+ gTestWin = window.open("about:blank", "testWindow");
+ gTestWin.location = 'javascript:window.opener.finish(sessionStorage["testItem"]);';
+}
+
+function test2() {
+ // Now change session storage and load a new item in gTestWin, to
+ // verify that they properly diverged after window.open().
+ gRunningTests++;
+ sessionStorage["testItem"] = "incorrect value";
+ gTestWin.location = 'javascript:window.opener.finish(sessionStorage["testItem"]);';
+}
+
+function test3()
+{
+ // Now, with session storage still changed, try the window.open()
+ // path, make sure it doesn't overwrite the session storage.
+ gRunningTests++;
+ window.open('javascript:window.opener.finish(sessionStorage["testItem"]);window.close();',
+ "testWindow");
+}
+
+var gTests = [test1, test2, test3];
+runNextTest();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug459848.html b/dom/tests/mochitest/bugs/test_bug459848.html
new file mode 100644
index 000000000..4bcdca898
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug459848.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=459848
+-->
+<head>
+ <title>Test for Bug 459848</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=459848">Mozilla Bug 459848</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 459848 **/
+
+var ifr1, irf2;
+var doc1, doc2;
+
+function testDocument(d) {
+ d.documentElement.setAttribute("onload", "this.setAttribute('didRun', 'true');");
+ var e = d.createEvent("Events");
+ e.initEvent("load", true, true);
+ d.documentElement.dispatchEvent(e);
+}
+
+function testDoc2() {
+ testDocument(doc2);
+ isnot(doc2.documentElement.getAttribute("didRun"), "true",
+ "Shouldn't have run an event listener");
+ SimpleTest.finish();
+}
+
+function startTest() {
+ var ifr1 = document.getElementById('iframe1');
+ var ifr2 = document.getElementById('iframe2');
+ doc1 = ifr1.contentDocument;
+ doc2 = ifr2.contentDocument;
+
+ testDocument(doc1);
+ is(doc1.documentElement.getAttribute("didRun"), "true",
+ "Should have run an event listener");
+
+ ifr2.parentNode.removeChild(ifr2);
+ setTimeout(testDoc2, 0);
+}
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(startTest);
+
+</script>
+</pre>
+<iframe id="iframe1"></iframe>
+<iframe id="iframe2"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug465263.html b/dom/tests/mochitest/bugs/test_bug465263.html
new file mode 100644
index 000000000..cd5610191
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug465263.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=465263
+-->
+<head>
+ <title>Test for Bug 465263</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=465263">Mozilla Bug 465263</a>
+<p id="display">
+ <iframe src="http://mochi.test:8888"></iframe>
+ <iframe src="http://mochi.test:8888"></iframe>
+ <iframe src="http://mochi.test:8888"></iframe>
+ <iframe src="http://mochi.test:8888"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 465263 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ window.frames[0].location.hash = '';
+ is(window.frames[0].location.href, "http://mochi.test:8888/#",
+ "Should have '#' in href now");
+ window.frames[1].location.hash = '#';
+ is(window.frames[1].location.href, "http://mochi.test:8888/#",
+ "Should have only one '#' in href");
+ window.frames[2].location.hash = 'foo';
+ is(window.frames[2].location.href, "http://mochi.test:8888/#foo",
+ "Should have '#foo' in href");
+ window.frames[3].location.hash = '#foo';
+ is(window.frames[3].location.href, "http://mochi.test:8888/#foo",
+ "Should have only one '#' in href here too");
+ SimpleTest.finish();
+});
+
+
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug479143.html b/dom/tests/mochitest/bugs/test_bug479143.html
new file mode 100644
index 000000000..03db4ddea
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug479143.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=479143
+-->
+<head>
+ <title>Test for Bug 411103</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479143">Mozilla Bug 479143</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+ SimpleTest.waitForExplicitFinish();
+
+ setTimeout(function() {
+ if ("showModalDialog" in window) {
+ var interval = setInterval(function() { var i = 0; i++; }, 10);
+
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "test_bug479143.html", false);
+ xhr.send(null);
+
+ window.showModalDialog("javascript:" +
+ "setTimeout(function() { window.close(); }, 1000);",
+ null);
+
+ clearInterval(interval);
+ }
+
+ ok(true, "did not crash");
+
+ SimpleTest.finish();
+ }, 0);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug484775.html b/dom/tests/mochitest/bugs/test_bug484775.html
new file mode 100644
index 000000000..2fdb16051
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug484775.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=484775
+-->
+<head>
+ <title>Test for Bug 484775</title>
+ <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484775">Mozilla Bug 484775</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 484775 **/
+
+var expectedTarget = null;
+var expectedType = null;
+var eventCount = 0;
+
+function listener(evt) {
+ ++eventCount;
+ is(evt.type, expectedType, "Wrong event type!");
+ is(evt.target, expectedTarget, "Wrong event target!");
+}
+
+expectedType = "TestEvent";
+var event = document.createEvent("Event");
+event.initEvent(expectedType, true, true);
+is(event.type, expectedType, "Wrong event type after initEvent!");
+
+var attr = document.createAttribute("attribute");
+expectedTarget = attr;
+attr.addEventListener(expectedType, listener, false);
+attr.dispatchEvent(event);
+is(eventCount, 1, "Should have fired an event!");
+attr.removeEventListener(expectedType, listener, false);
+
+var df = document.createDocumentFragment();
+expectedTarget = df;
+df.addEventListener(expectedType, listener, false);
+df.dispatchEvent(event);
+is(eventCount, 2, "Should have fired an event!");
+df.removeEventListener(expectedType, listener, false);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug492925.html b/dom/tests/mochitest/bugs/test_bug492925.html
new file mode 100644
index 000000000..162f0a361
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug492925.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=492925
+-->
+<head>
+ <title>Test for Bug 492925</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <style>
+ @media tv, print {
+ #div2 {
+ overflow: hidden;
+ }
+ }
+ </style>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=492925">Mozilla Bug 492925</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 492925 **/
+
+var sheet = document.styleSheets[1];
+var rule = sheet.cssRules[0];
+var media = rule.media;
+
+is(media.mediaText, "tv, print", "Unexpected media string");
+is(media[0], "tv", "[0] should be 'tv'");
+is(media[1], "print", "[1] should be 'print'");
+is(media.item(0), "tv", ".item(0) should be 'tv'");
+is(media.item(1), "print", ".item(1) should be 'print'");
+
+
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug49312.html b/dom/tests/mochitest/bugs/test_bug49312.html
new file mode 100644
index 000000000..e47faab59
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug49312.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=49312
+-->
+<head>
+ <title>Test for Bug 49312</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script>
+ // Hack to set things up so that parent.fakeOpener works the same way for
+ // both test subframes.
+ var framesToLoad = 2;
+ function subframeLoaded(win) {
+ is(win.location.href
+ .replace(/iframe_bug49312\.html$/, "test_bug49312.html"),
+ window.location.href,
+ "Unexpected subframe href");
+ if (win == opened) {
+ opened.close();
+ }
+ if (--framesToLoad == 0) {
+ SimpleTest.finish();
+ }
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=49312">Mozilla Bug 49312</a>
+<p id="display">
+ <iframe src="javascript:'<script>location=\'iframe_bug49312.html\'</script>'"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 49312 **/
+SimpleTest.waitForExplicitFinish();
+var opened = window.open("javascript:'<script>location=\\\'iframe_bug49312.html\\\'</" + "script>'", "", "width=100,height=100")
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug495219.html b/dom/tests/mochitest/bugs/test_bug495219.html
new file mode 100644
index 000000000..98cd530a3
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug495219.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=495219
+-->
+<head>
+ <title>Test for Bug 495219</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=495219">Mozilla
+ Bug 495219</a>
+<iframe onload="this.style.display='none'"></iframe>
+<script type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+window.onload = function () {
+ is(window.frames[0].innerWidth, 0, "width should be zero");
+ is(window.frames[0].innerHeight, 0, "height should be zero");
+ SimpleTest.finish();
+}
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug504862.html b/dom/tests/mochitest/bugs/test_bug504862.html
new file mode 100644
index 000000000..713165bc3
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug504862.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=504862
+-->
+<head>
+ <title>Test for Bug 504862</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504862">Mozilla Bug 504862</a>
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 504862 **/
+SimpleTest.waitForExplicitFinish();
+function onMsgRcv(event)
+{
+ is(event.data, "args: undefined", "Unexpected cross origin dialog arguments.");
+}
+
+function runTest() {
+ if ("showModalDialog" in window) {
+ window.addEventListener("message", onMsgRcv, false);
+
+ var result = window.showModalDialog("file_bug504862.html", "my args");
+ // NB: We used to clear returnValue on each navigation, but now we do a
+ // security check on access, so we can safely make returnValue live on
+ // the browsing context, per spec.
+ is(result, 3, "window sees previous dialog documents return value.");
+
+ result = window.showModalDialog("http://test1.example.com/tests/dom/tests/mochitest/bugs/file_bug504862.html", "my args");
+
+ is(result, undefined, "Able to see return value from cross origin dialog.");
+ } else {
+ ok(true, "nothing to do in e10s mode");
+ }
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug529328.html b/dom/tests/mochitest/bugs/test_bug529328.html
new file mode 100644
index 000000000..81eb62e81
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug529328.html
@@ -0,0 +1,122 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=529328
+-->
+<head>
+ <title>Test for Bug 529328</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529328">Mozilla Bug 529328</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+/** Test for Bug 529328 **/
+function testDOMTokenList() {
+ is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList[0], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList[1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(0), null, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(1), null, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
+
+ document.body.className = "a b";
+ is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList[0], "a", "Wrong value for in bounds access (DOMTokenList)");
+ is(document.body.classList[1], "b", "Wrong value for in bounds access (DOMTokenList)");
+ is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
+ is(document.body.classList.item(0), "a", "Wrong value for in bounds access (DOMTokenList)");
+ is(document.body.classList.item(1), "b", "Wrong value for in bounds access (DOMTokenList)");
+ is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
+}
+
+function testDOMStringList() {
+ is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets[0], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets[1], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(0), null, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(1), null, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
+
+ var s = document.createElement("style");
+ s.title = "a";
+ document.head.appendChild(s);
+ s = document.createElement("style");
+ s.title = "b";
+ document.head.appendChild(s);
+
+ is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets[0], "a", "Wrong value for in bounds access (DOMStringList)");
+ is(document.styleSheetSets[1], "b", "Wrong value for in bounds access (DOMStringList)");
+ is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(0), "a", "Wrong value for in bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(1), "b", "Wrong value for in bounds access (DOMStringList)");
+ is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
+}
+
+function testMediaList() {
+ var s = document.createElement("style");
+ document.head.appendChild(s);
+ is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media[0], undefined, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media[1], undefined, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
+ is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media.item(0), null, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media.item(1), null, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
+
+ s.setAttribute("media", "a, b");
+
+ is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media[0], "a", "Wrong value for in bounds access (MediaList)");
+ is(s.sheet.media[1], "b", "Wrong value for in bounds access (MediaList)");
+ is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
+ is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
+ is(s.sheet.media.item(0), "a", "Wrong value for in bounds access (MediaList)");
+ is(s.sheet.media.item(1), "b", "Wrong value for in bounds access (MediaList)");
+ is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
+}
+
+function testCSSStyleDeclaration() {
+ var s = document.createElement("span");
+
+ is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style[0], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style[1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(0), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+
+ s.setAttribute("style", "color: blue; z-index: 42;");
+
+ is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style[0], "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
+ is(s.style[1], "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
+ is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+ is(s.style.item(0), "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
+ is(s.style.item(1), "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
+ is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
+}
+
+testDOMTokenList();
+testDOMStringList();
+testMediaList();
+testCSSStyleDeclaration();
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug531176.html b/dom/tests/mochitest/bugs/test_bug531176.html
new file mode 100644
index 000000000..2525d5b63
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug531176.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=531176
+-->
+<head>
+ <title>Test for Bug 531176</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=531176">Mozilla Bug 531176</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 531176 **/
+
+var errorCount = 0;
+function errorHandler(msg, filename, linenr) {
+ is(msg, "SyntaxError: expected expression, got ';'", "Wrong error!");
+ is(filename, String(window.location), "Wrong filename!");
+ is(linenr, 1, "Wrong linenr!");
+ ++errorCount;
+}
+
+window.onerror = errorHandler;
+document.body.setAttribute("onclick", "var x=;");
+// Force eager compilation
+document.body.onclick;
+is(errorCount, 1, "Error handler should have been called! (1)");
+
+function recursiveHandler(msg, filename, linenr) {
+ is(msg, "SyntaxError: expected expression, got ';'", "Wrong error!");
+ is(filename, String(window.location), "Wrong filename!");
+ is(linenr, 1, "Wrong linenr!");
+ ++errorCount;
+ document.body.setAttribute("onclick", "var z=;");
+}
+
+window.onerror = recursiveHandler;
+document.body.setAttribute("onclick", "var y=;");
+// Force eager compilation
+document.body.onclick;
+is(errorCount, 2, "Error handler should have been called! (2)");
+
+// Check that error handler works even after recursion error.
+document.body.setAttribute("onclick", "var foo=;");
+// Force eager compilation
+document.body.onclick;
+is(errorCount, 3, "Error handler should have been called! (3)");
+
+window.onerror = function() { ++errorCount; };
+</script>
+<script>
+var foo =;
+</script>
+<script>
+is(errorCount, 4, "Error handler should have been called! (4)");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug531542.html b/dom/tests/mochitest/bugs/test_bug531542.html
new file mode 100644
index 000000000..40b5c452b
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug531542.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=531542
+-->
+<head>
+ <title>Test for Bug 531542</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=531542">Mozilla Bug 531542</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 531542 **/
+
+var negativeTimeoutFired = false;
+function negativeTimeout()
+{
+ negativeTimeoutFired = true;
+}
+function testFinished()
+{
+ ok(negativeTimeoutFired, "Timeout with negative delay should fire.");
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+setTimeout(negativeTimeout, -1);
+setTimeout(testFinished, 0);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug534149.html b/dom/tests/mochitest/bugs/test_bug534149.html
new file mode 100644
index 000000000..9c9506045
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug534149.html
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=534149
+-->
+<head>
+ <title>Test for Bug 534149</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149">Mozilla Bug 534149</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 534149 **/
+function getIDs(iframe) {
+ var win = iframe.contentWindow;
+ // Force inner creation
+ win.document;
+
+ var util = SpecialPowers.getDOMWindowUtils(win);
+ return [util.outerWindowID, util.currentInnerWindowID];
+}
+
+var i1 = document.createElement("iframe");
+var i2 = document.createElement("iframe");
+
+document.body.appendChild(i1);
+var [i1outer, i1inner] = getIDs(i1);
+
+document.body.appendChild(i2);
+var [i2outer, i2inner] = getIDs(i2);
+
+is(i1inner, i1outer + 1, "For frame 1, inner should come right after outer");
+is(i2inner, i2outer + 1, "For frame 2, inner should come right after outer");
+is(i2outer, i1inner + 1, "Frame 2 comes right after frame 1");
+
+var innerWindowDestroyID;
+var outerWindowDestroyID;
+
+var outerObserver = {
+ observe: function(id) {
+ outerWindowDestroyID =
+ SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+ }
+};
+var innerObserver = {
+ observe: function(id) {
+ innerWindowDestroyID =
+ SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+ }
+};
+
+function removeFrame(iframe) {
+ SpecialPowers.addObserver(outerObserver, "outer-window-destroyed", false);
+ SpecialPowers.addObserver(innerObserver, "inner-window-destroyed", false);
+
+ iframe.parentNode.removeChild(iframe);
+}
+
+removeFrame(i1);
+SimpleTest.waitForExplicitFinish();
+SimpleTest.executeSoon(function() {
+ is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed");
+ is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed");
+ SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed");
+ SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed");
+ SimpleTest.finish();
+});
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug541530.html b/dom/tests/mochitest/bugs/test_bug541530.html
new file mode 100644
index 000000000..1ce8ff1b4
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug541530.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=541530
+-->
+<head>
+ <title>Test for Bug 411103</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=541530">Mozilla Bug 541530</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+var orig = window;
+window = {};
+
+var origLocation = location;
+
+ok(window === orig, "can't override window");
+ok(window.location === location, "properties are properly aliased");
+ok(document.location === location, "properties are properly aliased");
+
+var canDefine = false;
+try {
+ this.__defineGetter__.call(this, 'bar', function() {});
+ this.__defineSetter__.call(this, 'bar', function() {});
+ canDefine = true;
+} catch (e) {}
+ok(canDefine, "Should have access to __defineGetter__ and __defineSetter__");
+
+try {
+ this.__defineGetter__('window', function() {});
+ ok(false, "should not be able to defineGetter(window)");
+} catch (e) {
+}
+
+try {
+ this.__defineGetter__.call(window, 'location', function(){});
+ ok(false, "should not be able to defineGetter(window.location)");
+} catch (e) {
+}
+
+try {
+ this.__defineGetter__.call(window.location, 'href', function(){});
+ ok(false, "shouldn't be able to override location.href");
+} catch (e) {
+ ok(/shadow/.exec(e.message) ||
+ /can't redefine non-configurable/.exec(e.message),
+ "Should be caught by the anti-shadow mechanism.");
+}
+
+// Try deleting the property.
+delete window.location.href;
+ok(typeof window.location.href !== 'undefined',
+ "shouldn't be able to delete the inherited property");
+delete Object.getPrototypeOf(window.location).href;
+ok(typeof window.location.href !== 'undefined',
+ "shouldn't be able to delete the property off of the prototype");
+
+this.__defineGetter__.call(Object.getPrototypeOf(window.location), 'href', function(){});
+ok(true, "should be able to define things on the prototype");
+
+try {
+ this.__defineSetter__.call(window.location, 'href', function(){});
+ ok(false, "overrode a setter for location.href?");
+} catch (e) {
+ ok(/shadow/.exec(e.message) ||
+ /can't redefine non-configurable/.exec(e.message),
+ "Should be caught by the anti-shadow mechanism.");
+}
+
+try {
+ this.__defineGetter__.call(document, 'location', function(){});
+ ok(false, "shouldn't be able to override document.location");
+} catch (e) {
+}
+
+ok(window === orig, "can't override window");
+ok(window.location === origLocation, "properties are properly aliased");
+ok(document.location === origLocation, "properties are properly aliased");
+
+location.href = 'javascript:ok(true, "was able to set location.href through a watchpoint")';
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug545314.html b/dom/tests/mochitest/bugs/test_bug545314.html
new file mode 100644
index 000000000..87fcd4f58
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug545314.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=545314
+-->
+<head>
+ <title>Test for Bug 545314</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=545314">Mozilla Bug 545314</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe id="ifr"></iframe>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 545314 **/
+var frame = window.frames[0];
+frame.location.assign("http://localhost:8888/");
+ok(true, "location.assign didn't throw");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug548828.html b/dom/tests/mochitest/bugs/test_bug548828.html
new file mode 100644
index 000000000..3e2cba806
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug548828.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=548828
+-->
+<head>
+ <title>Test for Bug 548828</title>
+ <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548828">Mozilla Bug 548828</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 548828 **/
+ var head = document.getElementsByTagName("head")[0];
+ is(document.head, head, "document.head and document.getElementsByTagName(\"head\")[0] should match");
+ document.head = "";
+ is(document.head, head, "document.head reassigned");
+ document.head = document.createElement("head");
+ is(document.head, head, "new element created with the name \"head\"");
+ document.documentElement.appendChild(document.createElement("head"));
+ is(document.head, head, "new child named head appended to document");
+ var head2 = document.createElement("head");
+ document.documentElement.insertBefore(head2, head);
+ is(document.head, head2, "new head inserted before existing head");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug558973.html b/dom/tests/mochitest/bugs/test_bug558973.html
new file mode 100644
index 000000000..836ff5da2
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug558973.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=558973
+-->
+<head>
+ <title>Test for Bug 558973</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=558973">Mozilla Bug 558973</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 558973 **/
+
+var child = document.createTextNode("a");
+
+var text = document.createTextNode("a");
+var exception = "";
+var exceptionCode = 0;
+try {
+ text.appendChild(child);
+}
+catch (e) {
+ exception = e.name;
+ exceptionCode = e.code;
+}
+is(exception, "HierarchyRequestError",
+ "Expected HierarchyRequestError");
+is(exceptionCode, DOMException.HIERARCHY_REQUEST_ERR,
+ "Expected DOMException.HIERARCHY_REQUEST_ERR");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug562433.html b/dom/tests/mochitest/bugs/test_bug562433.html
new file mode 100644
index 000000000..1500ee113
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug562433.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=562433
+-->
+<head>
+ <title>Test for Bug 562433</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=562433">Mozilla Bug 562433</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 562433 **/
+
+var w = window.open("");
+
+// The new window's location.host and location.hostname must be the empty
+// string (instead of throwing an exception)
+
+is(w.location.host, "", 'w.location.host should be ""');
+is(w.location.hostname, "", 'w.location.hostname should be ""');
+
+w.close();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug563487.html b/dom/tests/mochitest/bugs/test_bug563487.html
new file mode 100644
index 000000000..09e2a0f99
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug563487.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=563487
+-->
+<head>
+ <!-- Put this before the mochi* stuff, since that adds various listeners -->
+ <script>
+ var exception = null;
+ try {
+ window.removeEventListener("foo", function() {}, false);
+ } catch (e) {
+ exception = e;
+ }
+ </script>
+ <title>Test for Bug 563487</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=563487">Mozilla Bug 563487</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 563487 **/
+is(exception, null, "removeEventListener threw");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug581072.html b/dom/tests/mochitest/bugs/test_bug581072.html
new file mode 100644
index 000000000..9590a6e63
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug581072.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=581072
+-->
+<head>
+ <title>Test for Bug 581072</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=581072">Mozilla Bug 581072</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+/** Test for Bug 581072 **/
+var longTimerFired = false;
+
+// Set up a one-hour timeout
+setTimeout(function() { longTimerFired = true; }, 3600000);
+
+// Trigger suspend and resume timeouts
+(function() {
+ var utils = SpecialPowers.getDOMWindowUtils(window);
+ utils.suspendTimeouts();
+ utils.resumeTimeouts();
+})()
+
+// Now set up another timeout which should fire before the one-hour one
+setTimeout(function() {
+ is(longTimerFired, false, "One-hour timer should not fire before our 0ms one");
+ SimpleTest.finish();
+}, 0);
+
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug583225.html b/dom/tests/mochitest/bugs/test_bug583225.html
new file mode 100644
index 000000000..a174d589b
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug583225.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=583225
+-->
+<head>
+ <title>Test for Bug 583225</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583225">Mozilla Bug 583225</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 583225 **/
+
+function clicked()
+{
+ ok(true, "Event fired on DocumentFragment.");
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+var docFragment = document.createDocumentFragment();
+docFragment.foo = "foo";
+docFragment.addEventListener("click", clicked, false);
+var event = document.createEvent('MouseEvent');
+event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false,
+ false, false, 0, docFragment);
+docFragment.dispatchEvent(event);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug585240.html b/dom/tests/mochitest/bugs/test_bug585240.html
new file mode 100644
index 000000000..8dbb9d723
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug585240.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=585240
+-->
+<head>
+ <title>Test for Bug 585240</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=585240">Mozilla Bug 585240</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 585240 **/
+
+ SimpleTest.waitForExplicitFinish();
+
+ window.onmessage = function(event) {
+ ok(true, "message event should fire!");
+ SimpleTest.finish();
+ }
+ window.postMessage("hello", "*");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug585819.html b/dom/tests/mochitest/bugs/test_bug585819.html
new file mode 100644
index 000000000..60824e7d9
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug585819.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=585819
+-->
+<head>
+ <title>Test for Bug 585819</title>
+ <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=585819">Mozilla Bug 585819</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 585819 **/
+
+var range = document.createRange();
+range.setStartBefore(document.body);
+var fragment = range.createContextualFragment("<span></span>");
+is(fragment.firstChild.localName, "span", "We don't want tag inference here!");
+
+var iframeDoc = document.getElementsByTagName("iframe")[0].contentDocument;
+var root = iframeDoc.documentElement;
+is(root.localName, "html", "Wrong root.");
+root.innerHTML = "<span></span>";
+is(root.firstChild.localName, "head", "We want inference here!");
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug593174.html b/dom/tests/mochitest/bugs/test_bug593174.html
new file mode 100644
index 000000000..370d40b79
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug593174.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=593174
+-->
+<head>
+ <title>Test for Bug 593174</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=593174">Mozilla Bug 593174</a>
+
+<script>
+
+SimpleTest.waitForExplicitFinish();
+
+var loadCount = 0;
+var popup = null;
+
+const kOriginalLocation = location.href;
+
+function iframeLoaded(identifier) {
+ loadCount++;
+ dump("iframeLoaded. loadCount=" + loadCount +
+ " identifier='" + identifier + "'\n");
+
+ var iframe = document.getElementById('iframe');
+ var iframeCw = iframe.contentWindow;
+
+ if (loadCount == 1) {
+ // Test 1: Navigate iframe1. This page should be the referer.
+ // We'll get a callback from the inner page when its iframe finishes
+ // loading, so get rid of the onload listener on our iframe.
+
+ // Change this page's URI using replaceState; the referrer should be this
+ // new value, not our original location.
+ history.replaceState('', '', Math.random());
+
+ iframe.onload = null;
+ iframeCw.location = 'file_bug593174_2.html';
+ }
+ else if (loadCount == 2) {
+ // Test 1: Check that this page is the referer.
+ is(iframeCw.document.referrer, String(document.location), 'outer iframe referrer');
+
+ // Test 2: file_bug593174_2.html itself contains an iframe, whose src is a
+ // data: uri. Call into that inner iframe and have it set its
+ // document.location. The new document's referrer should be
+ // file_bug593174_2.html.
+
+ // We'll get a call to iframeLoaded when this finishes.
+ iframeCw.navigateInnerIframe();
+ }
+ else if (loadCount == 3) {
+ is(iframeCw.getInnerIframeReferrer(), String(iframeCw.location), 'inner iframe referrer');
+
+ // Now do the test again, this time with a popup.
+ popup = window.open('file_bug593174_1.html');
+ popup.onload = iframeLoaded('popup/outer');
+ }
+ else if (loadCount == 4) {
+ history.replaceState('', '', Math.random());
+
+ popup.onload = null;
+ popup.location = 'file_bug593174_2.html';
+ }
+ else if (loadCount == 5) {
+ is(popup.document.referrer, String(document.location), 'popup referrer after replaceState');
+ popup.navigateInnerIframe();
+ }
+ else if (loadCount == 6) {
+ is(popup.getInnerIframeReferrer(), String(popup.location), 'popup/inner iframe referrer');
+ popup.close();
+ history.replaceState('', '', kOriginalLocation);
+ SimpleTest.finish();
+ }
+}
+
+</script>
+
+<iframe onload='iframeLoaded("outer")' id='iframe' src='file_bug593174_1.html'></iframe>
+
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug597809.html b/dom/tests/mochitest/bugs/test_bug597809.html
new file mode 100644
index 000000000..71fb8ac78
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug597809.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=597809
+-->
+<head>
+ <title>Test for Bug 597809</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=597809">Mozilla Bug 597809</a>
+<p id="display"></p>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 597809 **/
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.addCategoryEntry("JavaScript-global-property", "testSNSM", "@mozilla.org/xmlextras/xmlhttprequest;1",
+ false, true);
+
+SimpleTest.executeSoon(function () {
+ ok(window.testSNSM, "testSNSM should return an object");
+ // The category entry must be removed before finishing the test,
+ // otherwise it will affect all following tests in the test suite.
+ SpecialPowers.deleteCategoryEntry("JavaScript-global-property", "testSNSM", false);
+ SimpleTest.finish();
+});
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug61098.html b/dom/tests/mochitest/bugs/test_bug61098.html
new file mode 100644
index 000000000..4c6ce967d
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -0,0 +1,339 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=61098
+-->
+<head>
+ <title>Test for Bug 61098</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/MockObjects.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runtests();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=61098">Mozilla Bug 61098</a>
+<p id="display">
+</p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+</pre>
+<script class="testbody" type="text/javascript">
+/** Test for Bug 61098 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var mockPromptServiceRegisterer, mockPromptFactoryRegisterer;
+
+var promptState;
+
+function registerMockPromptService()
+{
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var XPCOMUtils = SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm").XPCOMUtils;
+ var Ci = SpecialPowers.Ci;
+
+ function MockPrompt(aDOMWindow) {
+ this.domWindow = aDOMWindow;
+ }
+
+ MockPrompt.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]),
+
+ domWindow : null,
+
+ _toggleModalState: function()
+ {
+ // The real prompt service puts the window into a modal state
+ // immediately before showing a modal prompt, and leaves the modal state
+ // when the prompt is dismissed by the user. This mock prompt doesn't
+ // show anything to the user, so we only need to enter and immediately
+ // leave the modal state -- this is done to trigger the necessary
+ // accounting for triggering the "stop showing more prompts" code for
+ // abusive pages.
+ var winUtils = SpecialPowers.getDOMWindowUtils(this.domWindow);
+ winUtils.enterModalState();
+ winUtils.leaveModalState();
+ },
+
+ alert: function(aDialogTitle, aText)
+ {
+ this._toggleModalState();
+ promptState = {method: "alert",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText
+ };
+ },
+
+ alertCheck: function(aDialogTitle, aText, aCheckMsg, aCheckState)
+ {
+ this._toggleModalState();
+ promptState = {method: "alertCheck",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText,
+ checkMsg: aCheckMsg,
+ checkState: aCheckState
+ };
+
+ SpecialPowers.wrap(aCheckState).value = true;
+ },
+
+ confirm: function(aDialogTitle, aText)
+ {
+ this._toggleModalState();
+ promptState = {method: "confirm",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText
+ };
+
+ return true;
+ },
+
+ confirmCheck: function(aDialogTitle, aText, aCheckMsg, aCheckState)
+ {
+ this._toggleModalState();
+ promptState = {method: "confirmCheck",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText,
+ checkMsg: aCheckMsg,
+ checkState: aCheckState
+ };
+
+ SpecialPowers.wrap(aCheckState).value = true;
+
+ return true;
+ },
+
+ confirmEx: function(aDialogTitle, aText, aButtonFlags,
+ aButton0Title, aButton1Title, aButton2Title,
+ aCheckMsg, aCheckState)
+ {
+ this._toggleModalState();
+ promptState = {method: "confirmCheck",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText,
+ checkMsg: aCheckMsg,
+ checkState: aCheckState
+ };
+
+ if (aCheckMsg != null)
+ SpecialPowers.wrap(aCheckState).value = true;
+
+ return 0;
+ },
+
+ prompt: function(aDialogTitle, aText, aValue, aCheckMsg,
+ aCheckState)
+ {
+ this._toggleModalState();
+ promptState = {method: "prompt",
+ parent: this.domWindow,
+ title: aDialogTitle,
+ msg: aText,
+ checkMsg: aCheckMsg,
+ checkState: aCheckState
+ };
+
+ if (aCheckMsg != null)
+ SpecialPowers.wrap(aCheckState).value = true;
+
+ return true;
+ },
+ };
+
+
+ // Override the prompt service with our own so that we can test
+ // modal dialogs
+
+ function MockPromptService()
+ {
+ }
+
+ MockPromptService.prototype = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptFactory, Ci.nsIPromptService]),
+
+ getPrompt: function(aDOMWindow, aIID)
+ {
+ return new MockPrompt(aDOMWindow);
+ },
+
+ alert: function(aParent, aDialogTitle, aText)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.alert(aDialogTitle, aText);
+ },
+
+ alertCheck: function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.alertCheck(aDialogTitle, aText, aCheckMsg, aCheckState);
+ },
+
+ confirm: function(aParent, aDialogTitle, aText)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.confirm(aDialogTitle, aText);
+ },
+
+ confirmCheck: function(aParent, aDialogTitle, aText, aCheckMsg,
+ aCheckState)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.confirmCheck(aDialogTitle, aText, aCheckMsg, aCheckState);
+ },
+
+ confirmEx: function(aParent, aDialogTitle, aText, aButtonFlags,
+ aButton0Title, aButton1Title, aButton2Title,
+ aCheckMsg, aCheckState)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.confirmEx(aDialogTitle, aText, aButtonFlags,
+ aButton0Title, aButton1Title, aButton2Title,
+ aCheckMsg, aCheckState);
+ },
+
+ prompt: function(aParent, aDialogTitle, aText, aValue, aCheckMsg,
+ aCheckState)
+ {
+ var prompt = new MockPrompt(aParent);
+ return prompt.prompt(aDialogTitle, aText, aValue, aCheckMsg, aCheckState);
+ },
+
+ };
+
+ mockPromptServiceRegisterer =
+ new MockObjectRegisterer("@mozilla.org/embedcomp/prompt-service;1",
+ MockPromptService);
+ mockPromptFactoryRegisterer =
+ new MockObjectRegisterer("@mozilla.org/prompter;1",
+ MockPromptService);
+
+ mockPromptServiceRegisterer.register();
+ mockPromptFactoryRegisterer.register();
+};
+
+var expectedState;
+
+function runtests()
+{
+ SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3]]},
+ runtestsInner);
+}
+
+function runtestsInner()
+{
+ registerMockPromptService();
+
+ // Test that alert() works normally and then gets blocked on the
+ // second call.
+ w = window.open();
+ w.alert("alert message 1");
+ is (promptState.method, "alert", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong alert parent");
+ is (promptState.msg, "alert message 1", "Wrong alert message");
+ promptState = void(0);
+
+ w.alert("alert message 2");
+ is (promptState.method, "alertCheck", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong alert parent");
+ is (promptState.msg, "alert message 2", "Wrong alert message");
+ promptState = void(0);
+
+ try {
+ w.alert("alert message 3");
+ } catch(e) {
+ is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
+ }
+
+ is (promptState, void(0), "Wrong prompt state after blocked alert()");
+
+ w.close();
+
+ // Test that confirm() works normally and then gets blocked on the
+ // second call.
+ w = window.open();
+ w.confirm("confirm message 1");
+ is (promptState.method, "confirm", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong confirm parent");
+ is (promptState.msg, "confirm message 1", "Wrong confirm message");
+ promptState = void(0);
+
+ w.confirm("confirm message 2");
+ is (promptState.method, "confirmCheck", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong confirm parent");
+ is (promptState.msg, "confirm message 2", "Wrong confirm message");
+ promptState = void(0);
+
+ try {
+ w.confirm("confirm message 3");
+ } catch(e) {
+ is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
+ }
+
+ is (promptState, void(0), "Wrong prompt state after blocked confirm()");
+
+ w.close();
+
+ // Test that prompt() works normally and then gets blocked on the
+ // second call.
+ w = window.open();
+ w.prompt("prompt message 1");
+ is (promptState.method, "prompt", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong prompt parent");
+ is (promptState.msg, "prompt message 1", "Wrong prompt message");
+ is (promptState.checkMsg, null, "Wrong dialog value");
+ promptState = void(0);
+
+ w.prompt("prompt message 2");
+ is (promptState.method, "prompt", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong prompt parent");
+ is (promptState.msg, "prompt message 2", "Wrong prompt message");
+ is (promptState.checkMsg, "Prevent this page from creating additional dialogs", "Wrong dialog value");
+ promptState = void(0);
+
+ try {
+ w.prompt("prompt message 3");
+ } catch(e) {
+ is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
+ }
+
+ is (promptState, void(0), "Wrong prompt state after blocked prompt()");
+
+ w.close();
+
+ // Test that showModalDialog() works normally and then gets blocked
+ // on the second call.
+ if (window.showModalDialog) {
+ w = window.open();
+ w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>")
+ is (promptState, void(0), "Wrong prompt state");
+
+ try {
+ w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>")
+ ok(false, "showModalDialog call should throw an exception");
+ } catch(e) {
+ is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception");
+ }
+ is (promptState.method, "confirm", "Wrong prompt method called");
+ is (promptState.parent, w, "Wrong confirm parent");
+ is (promptState.msg, "Prevent this page from creating additional dialogs",
+ "Wrong confirm message");
+ promptState = void(0);
+
+ w.close();
+ }
+
+ mockPromptFactoryRegisterer.unregister();
+ mockPromptServiceRegisterer.unregister();
+
+ SimpleTest.finish();
+}
+
+</script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug612267.html b/dom/tests/mochitest/bugs/test_bug612267.html
new file mode 100644
index 000000000..fc55e54f4
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug612267.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=612267
+-->
+<head>
+ <title>Test for Bug 393974</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=612267">Mozilla Bug 612267</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+Window.prototype.test = 'PASS';
+is(window.test, 'PASS', "setting Window.prototype affects window.__proto__");
+is(test, 'PASS', "setting Window.prototype affects the inner window lookup for sure");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug617296.html b/dom/tests/mochitest/bugs/test_bug617296.html
new file mode 100644
index 000000000..9e5a2a3e1
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug617296.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=617296
+-->
+<head>
+ <title>Test for Bug 617296</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=617296">Mozilla Bug 617296</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 617296 **/
+var URL = 5;
+is(URL, 5, "window.URL should be replaceable");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug620947.html b/dom/tests/mochitest/bugs/test_bug620947.html
new file mode 100644
index 000000000..71977c417
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug620947.html
@@ -0,0 +1,31 @@
+<!-- This test must be in quirks mode so it has a document.all -->
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=620947
+-->
+<head>
+ <title>Test for Bug 620947</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620947">Mozilla Bug 620947</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 620947 **/
+is(-1 in document.all, false, "shouldn't be there");
+is(document.all[-1], undefined, "shouldn't be able to get it");
+
+
+
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug622361.html b/dom/tests/mochitest/bugs/test_bug622361.html
new file mode 100644
index 000000000..b9d10cb21
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug622361.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+<script>
+var w;
+var counter = 0;
+
+function doNext()
+{
+ counter++;
+ postMessage("ohai", "*");
+}
+
+function boom(event)
+{
+ switch (counter)
+ {
+ case 1:
+ w = window.open("data:text/html,1");
+ doNext();
+ return;
+ case 2:
+ w.location = "data:text/html,2";
+ function next()
+ {
+ w.history.back();
+ doNext();
+ }
+ setTimeout(next, 5000);
+ return;
+ case 3:
+ localStorage.setItem("key", "value");
+ w.history.forward();
+ doNext();
+ return;
+ case 4:
+ w.close();
+ ok(true, "Test complete");
+ SimpleTest.finish();
+ }
+}
+
+window.addEventListener("message", boom, false);
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+</script>
+</head>
+<body onload="doNext();"></body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug633133.html b/dom/tests/mochitest/bugs/test_bug633133.html
new file mode 100644
index 000000000..2d5f11661
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug633133.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=633133
+-->
+<head>
+ <title>Test for Bug 633133</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633133">Mozilla Bug 633133</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <div id='foo'></div>
+ <div name='bar'></div>
+ <select id="select" onchange="var foo = 'bar';">
+ <option>option1</option>
+ <option>option2</option>
+ </select>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 633133 **/
+
+var divCollection = document.getElementsByTagName('div');
+
+ok("foo" in divCollection, "'foo' should be in the div collection");
+ok("bar" in divCollection, "'bar' should be in the div collection");
+ok(!("" in divCollection), "empty string shouldn't be in the div collection");
+ok(!("foobar" in divCollection), "'foobar' shouldn't be in the div collection");
+
+var select = $('select');
+is(select[0].text, "option1", "select elements work");
+Math.sin();
+ok(1 in select, "in works");
+is(select[1].text, "option2", "can get it too");
+ok(!(2 in select), "in works for elements out of range");
+is(select[2], undefined, "can get them too and they're undefined");
+isnot(select.onchange, undefined, "select.onchange shouldn't be undefined");
+is(typeof(select.onchange), 'function', "select.onchange should be a function");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug641552.html b/dom/tests/mochitest/bugs/test_bug641552.html
new file mode 100644
index 000000000..ab76c74a3
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug641552.html
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=641552
+-->
+<head>
+ <title>Test for Bug 641552</title>
+ <script type="application/javascript" src="/MochiKit/packed.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=641552">Mozilla Bug 641552</a>
+<p id="display"></p>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 641552 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var contractId = "@mozilla.org/xmlextras/xmlhttprequest;1";
+var categoryEntries = [
+ {category: "JavaScript-global-property", entry: "randomname", contractId: contractId},
+];
+
+function addCategoryEntries(func) {
+ for (var categoryEntry of categoryEntries) {
+ SpecialPowers.addCategoryEntry(categoryEntry.category, categoryEntry.entry, categoryEntry.contractId,
+ false, true);
+ }
+ SimpleTest.executeSoon(func);
+}
+
+function removeCategoryEntries(func) {
+ for (var categoryEntry of categoryEntries) {
+ SpecialPowers.deleteCategoryEntry(categoryEntry.category, categoryEntry.entry, false);
+ }
+ SimpleTest.executeSoon(func);
+}
+
+function checkNamesPresent() {
+ ok(window.randomname, "window.randomname should return an object");
+}
+
+function checkNamesAbsent() {
+ ok(!window.randomname, "window.randomname should return undefined");
+}
+
+// Ensure the initial state
+checkNamesAbsent();
+
+addCategoryEntries(function test1() {
+ ok(window.randomname, "window.randomname should return an object");
+
+ delete window.randomname;
+
+ // The delete opertor should have no effect as long as the category entry is registered.
+ checkNamesPresent();
+
+ removeCategoryEntries(test2);
+});
+
+function test2() {
+ // The object should be cached on the global/navigator object once accessed.
+ checkNamesPresent();
+
+ delete window.randomname;
+
+ // Now the delete opertor should have the effect.
+ checkNamesAbsent();
+
+ addCategoryEntries(function() {
+ removeCategoryEntries(test3);
+ });
+}
+
+function test3() {
+ // The object should not be cached until the first access.
+ checkNamesAbsent();
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug642026.html b/dom/tests/mochitest/bugs/test_bug642026.html
new file mode 100644
index 000000000..635c4c5db
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug642026.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=642026
+
+/// Copyright (c) 2009 Microsoft Corporation
+///
+/// Redistribution and use in source and binary forms, with or without modification, are permitted provided
+/// that the following conditions are met:
+/// * Redistributions of source code must retain the above copyright notice, this list of conditions and
+/// the following disclaimer.
+/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
+/// the following disclaimer in the documentation and/or other materials provided with the distribution.
+/// * Neither the name of Microsoft nor the names of its contributors may be used to
+/// endorse or promote products derived from this software without specific prior written permission.
+///
+/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+/// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+/// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+/// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+/// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+/// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+-->
+<head>
+ <title>Test for Bug 642026</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=642026">Mozilla Bug 642026</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 642026 **/
+
+var expResult = ["NaN", "Infinity", "undefined", "eval", "parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "Object", "Function", "Array", "String", "Boolean", "Number", "Date", "Date", "RegExp", "Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Math", "JSON"];
+
+var result = Object.getOwnPropertyNames(window);
+var result1 = {};
+for (var p in result) {
+ result1[result[p]] = true;
+}
+
+ok(expResult.every(c => result1[c]), "all of the standard classes have been enumerated");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug648465.html b/dom/tests/mochitest/bugs/test_bug648465.html
new file mode 100644
index 000000000..2a6afdf43
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug648465.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=648465
+-->
+<head>
+ <title>Test for Bug 648465</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=648465">
+ Mozilla Bug 648465</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 648465 **/
+var w = window.open('about:blank');
+try {
+ is(w.fullScreen, false, "can access non-allAccess properties of w");
+} finally {
+ w.close();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug654137.html b/dom/tests/mochitest/bugs/test_bug654137.html
new file mode 100644
index 000000000..bbbb0bb08
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug654137.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=654137
+-->
+<head>
+ <title>Test for Bug 654137</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=654137">Mozilla Bug 654137</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+/** Test for Bug 654137 **/
+var prev = window.top;
+top = "Fail";
+is(top, prev, "top should not have been replaced");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug664737.html b/dom/tests/mochitest/bugs/test_bug664737.html
new file mode 100644
index 000000000..447c9ac64
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug664737.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=664737
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 664737</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=664737">Mozilla Bug 664737</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 664737 **/
+function isUndefined(name) {
+ try {
+ var rv = history[name];
+ is(rv, undefined, "No value found for history." + name);
+ } catch (e) {
+ ok(false, "Accessing history." + name + " threw: " + e);
+ }
+}
+
+isUndefined("current");
+isUndefined("previous");
+isUndefined("next");
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug665548.html b/dom/tests/mochitest/bugs/test_bug665548.html
new file mode 100644
index 000000000..a48255cd1
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug665548.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=665548
+-->
+<head>
+ <title>Test for Bug 665548</title>
+ <script type="application/javascript" src="/MochiKit/packed.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=665548">Mozilla Bug 665548</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe name='location'></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 665548 **/
+
+isnot(window.location, window.frames[0],
+ "window.location shouldn't be the frame named location");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug684544.html b/dom/tests/mochitest/bugs/test_bug684544.html
new file mode 100644
index 000000000..885e2e900
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug684544.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=
+-->
+<head>
+ <title>Test for Bug </title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug **/
+
+var f = document.createElement("iframe");
+document.body.appendChild(f);
+var win = f.contentWindow;
+
+// Set location once to make sure it's resolved
+win.location = "data:text/html,1";
+
+// Now try to make the location object go away.
+f.parentNode.removeChild(f);
+
+// Check that location is now null. If it's not, the test needs changing
+// (e.g. to use window.close() so that it's null).
+is("location" in win, true, "Should still have a location property");
+is(win.location, null, "There should be no location object now");
+
+// Just set the location. This should not crash but throw an exception.
+var noException;
+try {
+ win.location = "data:text/html,2";
+ noException = true;
+}
+catch(e) {
+ noException = false;
+}
+todo(noException, "Shouldn't throw when setting location.");
+
+// And check that we didn't override the slot in the process.
+is(typeof(win.location), "object", "Location should not have become a string");
+is(win.location, null,
+ "There should be no location object for real after the set");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug691707.html b/dom/tests/mochitest/bugs/test_bug691707.html
new file mode 100644
index 000000000..6e3d8ba11
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug691707.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=691707
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 691707</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691707">Mozilla Bug 691707</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 691707 **/
+
+var nodeList = document.body.childNodes;
+var properties = [];
+for (let i in nodeList) {
+ properties.push(i);
+}
+for (var j = 1; j < nodeList.length; ++j)
+ ok(properties.indexOf("" + j) >= 0, "Enumerating hit all numeric properties");
+ok(properties.indexOf("item") >= 0, "Enumerating hit 'item' from the prototype");
+ok(properties.indexOf("length") >= 0, "Enumerating hit 'length' from the prototype");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug698061.html b/dom/tests/mochitest/bugs/test_bug698061.html
new file mode 100644
index 000000000..c8a4fbfe5
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug698061.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=698061
+-->
+<head>
+ <title>Test for Bug 698061</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=698061">Mozilla Bug 698061</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 698061 **/
+
+var d = document.createElement("div");
+d.innerHTML = "<span>hello </span><span>world</span>";
+
+var imported = document.importNode(d);
+is(imported.childNodes.length, 0, "Should not have cloned child nodes with no deep arg!");
+is(imported.textContent, "", "Should not have cloned text with no deep arg!");
+
+imported = document.importNode(d, true);
+is(imported.childNodes.length, 2, "Should have cloned child nodes!");
+is(imported.textContent, "hello world", "Should have cloned text!");
+
+imported = document.importNode(d, false);
+is(imported.childNodes.length, 0, "Shouldn't have cloned child nodes!");
+is(imported.textContent, "", "Shouldn't have cloned text!");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug698551.html b/dom/tests/mochitest/bugs/test_bug698551.html
new file mode 100644
index 000000000..70a002bb9
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug698551.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=698551
+-->
+<head>
+ <title>Test for Bug 698551</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=698551">Mozilla Bug 698551</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 698551 **/
+var l = document.getElementsByTagName("body");
+var it = Object.getPrototypeOf(l).item;
+Object.defineProperty(Object.getPrototypeOf(l), "item",
+{
+ get: function() { return it; },
+});
+Object.defineProperty(Object.getPrototypeOf(l), "foopy",
+{
+ get: function() { return this[0]; },
+});
+is(l.foopy, document.body,
+ "Should end up with the body correctly when getting via [0]");
+is(l.item(0), document.body,
+ "Should end up with the body correctly when getting via .item(0)");
+is(l.length, 1, "Should have one body");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug707749.html b/dom/tests/mochitest/bugs/test_bug707749.html
new file mode 100644
index 000000000..18d197e1e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug707749.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=707749
+-->
+<head>
+ <title>Test for Bug 707749</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=707749 ">Mozilla Bug 707749 </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 707749 **/
+SimpleTest.waitForExplicitFinish();
+function loaded() {
+ $('ifr').contentDocument.open();
+ $('ifr').contentDocument.close();
+ ok(true, "Don't throw an exception from contentDocument.open()");
+ SimpleTest.finish();
+}
+
+</script>
+<iframe id="ifr" onload="loaded()" src="data:text/html,<script>navigator</script>"></iframe>
+</pre>
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_bug735237.html b/dom/tests/mochitest/bugs/test_bug735237.html
new file mode 100644
index 000000000..e1a25a425
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug735237.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=735237
+-->
+<head>
+ <title>Test for Bug 735237</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=735237">Mozilla Bug 735237</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 735237 **/
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_showModalDialog", true]]}, function() {
+ var caughtException = false;
+ try {
+ window.showModalDialog("http://example.com/");
+ } catch (e) {
+ caughtException = true;
+ }
+ ok(caughtException, "showModalDialog should throw an exception");
+ SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug739038.html b/dom/tests/mochitest/bugs/test_bug739038.html
new file mode 100644
index 000000000..2cbbf3654
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug739038.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=739038
+-->
+<head>
+ <title>Test for Bug 739038</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=739038">Mozilla Bug 739038</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 739038 **/
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_print", true]]}, function() {
+ var caughtException = false;
+ try {
+ window.print();
+ } catch (e) {
+ caughtException = true;
+ }
+ ok(caughtException, "window.print should throw an exception");
+ SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug740811.html b/dom/tests/mochitest/bugs/test_bug740811.html
new file mode 100644
index 000000000..7e6dcc4fe
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug740811.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=740811
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 740811</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=740811">Mozilla Bug 740811</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 740811 **/
+is(Object.getPrototypeOf(SVGElement.prototype), Element.prototype,
+ "Bogus proto for SVGElement");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug743615.html b/dom/tests/mochitest/bugs/test_bug743615.html
new file mode 100644
index 000000000..39e978dda
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug743615.html
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=743615
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 743615</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="utils_bug743615.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=743615">Mozilla Bug 743615</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+<canvas id="c" width="200" height="200"><canvas>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for structured cloning ImageData. **/
+
+SimpleTest.waitForExplicitFinish();
+window.addEventListener('message', windowMessage);
+startTest();
+
+function startTest() {
+ // Make an ImageData.
+ var ctx = document.getElementById('c').getContext('2d');
+ ctx.fillStyle = 'rgb(';
+ ctx.fillRect(30, 30, 50, 50);
+
+ // Make a blank ImageData.
+ var imageData = ctx.createImageData(200, 200);
+ is(imageData.data.length, imageData.width * imageData.height * 4,
+ 'right size for data');
+
+ // Write some things into it.
+ var pattern = makePattern(imageData.data.length, 42, 7);
+ setPattern(imageData, pattern);
+ ok(checkPattern(imageData, pattern), 'Can read it back before sending');
+
+ // PostMessage it to ourselves.
+ window.postMessage({ imageData: imageData,
+ pattern: pattern,
+ dataRef: imageData.data }, '*');
+}
+
+function windowMessage(evt) {
+ // Check the pattern we received.
+ var imageData = evt.data.imageData;
+ var pattern = evt.data.pattern;
+ ok(checkPattern(imageData, pattern),
+ 'postMessage from self worked correctly');
+
+ // We're not spec compliant on this yet.
+ todo_is(imageData.data, evt.data.dataRef,
+ 'Should have backrefs for imagedata buffer');
+
+ // Make a new pattern, and send it to a worker.
+ pattern = makePattern(imageData.data.length, 4, 3);
+ setPattern(imageData, pattern);
+ var worker = new Worker('worker_bug743615.js');
+ worker.onmessage = workerMessage;
+ worker.postMessage( {imageData: imageData, pattern: pattern });
+}
+
+function workerMessage(evt) {
+ // Relay the results of the worker-side tests.
+ is(evt.data.statusMessage, 'PASS', evt.data.statusMessage);
+
+ // Test what the worker sent us.
+ ok(checkPattern(evt.data.imageData, evt.data.pattern),
+ 'postMessage from worker worked correctly');
+
+ // All done.
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug750051.html b/dom/tests/mochitest/bugs/test_bug750051.html
new file mode 100644
index 000000000..181233a41
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug750051.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=750051
+-->
+<head>
+ <title>Test for Bug 750051</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=750051">Mozilla Bug 750051</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 750051 **/
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_find", true]]}, function() {
+ var caughtException = false;
+ try {
+ window.find();
+ } catch (e) {
+ caughtException = true;
+ }
+ ok(caughtException, "window.find should throw an exception");
+ SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug755320.html b/dom/tests/mochitest/bugs/test_bug755320.html
new file mode 100644
index 000000000..9cbbc4b62
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug755320.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=755320
+-->
+<head>
+ <title>Test for Bug 755320</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=755320">Mozilla Bug 755320</a>
+
+<script type="text/javascript">
+
+/** Test for Bug 755320 **/
+
+SimpleTest.waitForExplicitFinish();
+
+function finish() {
+ ok(true, "Got onload for iframe.");
+ SimpleTest.finish();
+}
+</script>
+
+<!-- remote="true" should be ignored on vanilla iframes. -->
+<iframe remote="true" onload='finish()' src="data:text/html,It worked."></iframe>
+
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug777628.html b/dom/tests/mochitest/bugs/test_bug777628.html
new file mode 100644
index 000000000..f272fcb3e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug777628.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=777628
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 743615</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="utils_bug743615.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777628">Mozilla Bug 777628</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for structured cloning ImageData from another scope. **/
+
+// Set up an ImageData in another scope.
+var doc = document.getElementById('ifr').contentDocument;
+var canvas = doc.createElement('canvas');
+canvas.width = 200;
+canvas.height = 200;
+doc.body.appendChild(canvas);
+var ctx = canvas.getContext('2d');
+ctx.fillStyle = 'rgb(';
+ctx.fillRect(30, 30, 50, 50);
+var imageData = ctx.createImageData(200, 200);
+
+// Clone it.
+window.postMessage({ imageData: imageData }, '*');
+ok(true, "Handled cross-compartment imagedata without throwing/crashing!");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug809290.html b/dom/tests/mochitest/bugs/test_bug809290.html
new file mode 100644
index 000000000..71df15ea3
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug809290.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=809290
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 809290</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=809290">Mozilla Bug 809290</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/*
+ * Test for Bug 809290.
+ *
+ * This test used to check that the referrer was the entry settings object.
+ * Due to spec changes, we now need to check that the referrer is the incumbent
+ * settings object.
+ */
+SimpleTest.waitForExplicitFinish();
+
+var gNotifyCount = 0;
+var base = window.location.href.replace(/test_bug.*/, '');
+function notifyReferrer(referrer) {
+ ++gNotifyCount;
+ if (gNotifyCount == 1) {
+ is(referrer, base + 'file_bug809290_b1.html', "Referrer should come from the incumbent script settings object (1)");
+ document.getElementById('ifr').setAttribute('src', 'file_bug809290_b2.html');
+ } else {
+ is(gNotifyCount, 2, "notify count");
+ is(referrer, base + 'file_bug809290_b2.html', "Referrer should come from the the incumbent script settings object (2)");
+ SimpleTest.finish();
+ }
+}
+
+function go() {
+ var ifr = document.getElementById('ifr');
+ ifr.onload = null;
+ ifr.contentWindow.innerLoad();
+}
+
+</script>
+</pre>
+<iframe id="ifr" src="file_bug809290_b1.html" onload="go();"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug817476.html b/dom/tests/mochitest/bugs/test_bug817476.html
new file mode 100644
index 000000000..f76bb5125
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug817476.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=817476
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 817476</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=817476">Mozilla Bug 817476</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 817476 **/
+function getNewWindow() {
+ var ifr = document.createElement("iframe");
+ $("content").appendChild(ifr);
+ return ifr.contentWindow;
+}
+
+// Test getting .screen before .Screen
+var win = getNewWindow();
+is(Object.getPrototypeOf(win.screen), win.Screen.prototype,
+ "protos must match (1)");
+is(win.Screen.prototype.toString(), "[object ScreenPrototype]",
+ "proto must be WebIDL (1)");
+
+// Test getting Screen before .screen
+var win = getNewWindow();
+is(win.Screen.prototype, Object.getPrototypeOf(win.screen),
+ "protos must match (2)");
+is(win.Screen.prototype.toString(), "[object ScreenPrototype]",
+ "proto must be WebIDL (2)");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug823173.html b/dom/tests/mochitest/bugs/test_bug823173.html
new file mode 100644
index 000000000..15748786c
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug823173.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=823173
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 823173</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=823173">Mozilla Bug 823173</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 823173 **/
+try {
+ ok(!(navigator instanceof Window), "navigator is not an instance of Window");
+} catch (e) {
+ ok(false, "instanceof tests should not throw");
+}
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug848088.html b/dom/tests/mochitest/bugs/test_bug848088.html
new file mode 100644
index 000000000..0f5c6f28f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug848088.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=848088
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 848088</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 848088 **/
+
+function test(loopFor, setExpandoAt)
+{
+ var list = document.getElementsByTagName("audio");
+ delete list.length;
+ var shouldHaveExpando = false;
+ var realLength = list.length;
+ for (var i = 0; i < loopFor; ++i) {
+ if (i == setExpandoAt) {
+ // Add an expando that shadows.
+ Object.defineProperty(list, "length", { value: "a" });
+ shouldHaveExpando = true;
+ }
+ var hasExpando = (list.length != realLength);
+ if (shouldHaveExpando != hasExpando) {
+ return false;
+ }
+ }
+ return true;
+}
+
+ok(test(200000, 100000), "Correctly detected expando on DOM list object");
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=848088">Mozilla Bug 848088</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug850517.html b/dom/tests/mochitest/bugs/test_bug850517.html
new file mode 100644
index 000000000..140611c75
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug850517.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=850517
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 850517</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for live updating of named child resolution. **/
+ SimpleTest.waitForExplicitFinish();
+
+ function go() {
+ var ifrA = $('a');
+ var ifrB = $('b');
+ var sb = new SpecialPowers.Cu.Sandbox('http://www.example.com');
+ sb.win = window;
+ sb.childA = ifrA.contentWindow;
+ sb.childB = ifrB.contentWindow;
+ SpecialPowers.setWrapped(sb, 'is', SpecialPowers.wrap(is));
+ SpecialPowers.setWrapped(sb, 'ok', SpecialPowers.wrap(ok));
+ is(window.theoneandonly.frameElement, ifrA, "Named child resolution works");
+ SpecialPowers.Cu.evalInSandbox('is(win.theoneandonly, childA, "Named child resolution works via Xray");', sb);
+ ifrA.removeAttribute('name');
+ is(typeof window.theoneandonly, 'undefined', "Revocation works");
+ SpecialPowers.Cu.evalInSandbox('try { win.theoneandonly; ok(false, "Should have thrown"); } ' +
+ 'catch (e) {ok(!!/denied/.exec(e) && !!/theoneandonly/.exec(e), "Revocation works via Xray");};', sb);
+ ifrB.setAttribute('name', 'theoneandonly');
+ is(window.theoneandonly.frameElement, ifrB, "Another mule kicking in the same old stall");
+ SpecialPowers.Cu.evalInSandbox('is(win.theoneandonly, childB, "Another mule via Xray");', sb);
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body onload="go();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=850517">Mozilla Bug 850517</a>
+<p id="display"></p>
+<iframe id="a" name="theoneandonly"></iframe>
+<iframe id="b"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug857555.html b/dom/tests/mochitest/bugs/test_bug857555.html
new file mode 100644
index 000000000..889ed6147
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug857555.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=857555
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 857555</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 857555 **/
+ SimpleTest.waitForExplicitFinish();
+
+ addLoadEvent(function() {
+ is(content, $("t").contentWindow, "'content' as iframe name should work");
+ is(sidebar, $("u").contentWindow, "'sidebar' as iframe name should work");
+ SimpleTest.finish();
+ });
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=857555">Mozilla Bug 857555</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe name="content" id="t"></iframe>
+ <iframe name="sidebar" id="u"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug862540.html b/dom/tests/mochitest/bugs/test_bug862540.html
new file mode 100644
index 000000000..d86683669
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug862540.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=862540
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 862540</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 862540 **/
+ window.status = 5;
+ is(window.status, "5", "Should be able to get 5");
+
+ window.status = { toString: function() { return "foo"; } };
+ ok(window.status === "foo", "Should be coercing window.status to string");
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=862540">Mozilla Bug 862540</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug876098.html b/dom/tests/mochitest/bugs/test_bug876098.html
new file mode 100644
index 000000000..66292cb89
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug876098.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=876098
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 876098</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 876098 **/
+ var div = document.createElement("div");
+ // count has to be large enough to trigger ion-compilation
+ var count = 2000;
+ // Separate function to make sure nothing weird we do block the ion-compile
+ (function() {
+ for (var i = 0; i < count; ++i) {
+ var span = document.createElement("span");
+ span.x = "foo";
+ div.appendChild(span);
+ }
+ })();
+
+ SpecialPowers.gc();
+
+ function allHaveProp() {
+ var kids = div.childNodes;
+ for (var i = 0; i < count; ++i) {
+ if (kids[i].x != "foo") {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ ok(allHaveProp(), "All spans should have the property we added");
+
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=876098">Mozilla Bug 876098</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_bug927901.html b/dom/tests/mochitest/bugs/test_bug927901.html
new file mode 100644
index 000000000..8bc0eba1e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug927901.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=927901
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 927901</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 927901 **/
+ SimpleTest.waitForExplicitFinish();
+
+ var counter = 0;
+ window.onmessage = function(e) {
+ ++counter;
+ is(e.data, "pass", "Accessing window.crypto.getRandomValues in the iframe should have succeeded!");
+ if (counter == 1) {
+ document.getElementById("testiframe").src =
+ "http://mochi.test:8888/tests/dom/tests/mochitest/bugs/file_bug927901.html "
+ } else if (counter == 2) {
+ SimpleTest.finish();
+ }
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=927901">Mozilla Bug 927901</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+<iframe id="testiframe" src="http://test1.example.org:8000/tests/dom/tests/mochitest/bugs/file_bug927901.html"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_devicemotion_multiple_listeners.html b/dom/tests/mochitest/bugs/test_devicemotion_multiple_listeners.html
new file mode 100644
index 000000000..fcf345ead
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_devicemotion_multiple_listeners.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=673472
+-->
+<head>
+ <title>Test for Bug 673472</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <base href="http://mochi.test:8888/tests/dom/tests/mochitest/bugs/">
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=673472">Mozilla Bug 673472</a>
+<pre id="test">
+<script type="application/javascript">
+
+function f() {
+try {
+ var ifr = document.getElementById('i');
+ if (ifr.contentWindow.document.location == 'about:blank') {
+ ifr.parentNode.removeChild(ifr);
+ ok(true, "no crash received");
+ SimpleTest.executeSoon(SimpleTest.finish);
+ }
+} catch(e) {
+ok(false, e);
+}
+}
+
+SimpleTest.waitForExplicitFinish();
+</script>
+</pre>
+<iframe src="devicemotion_outer.html" onload="f()" id=i></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_domparser_after_blank.html b/dom/tests/mochitest/bugs/test_domparser_after_blank.html
new file mode 100644
index 000000000..d821384a8
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_domparser_after_blank.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head><meta charset=utf-8>
+ <title>Test for creating DOMParser() after docoment.write() blanks the page</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=820841">Mozilla Bug 820841</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 820841 **/
+
+function startTest() {
+ document.getElementById("testFrame")
+ .setAttribute("src", "iframe_domparser_after_blank.html");
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(startTest);
+
+
+</script>
+</pre>
+<iframe id="testFrame">
+</body>
+</html>
+
diff --git a/dom/tests/mochitest/bugs/test_errorReporting.html b/dom/tests/mochitest/bugs/test_errorReporting.html
new file mode 100644
index 000000000..8ca001f9a
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_errorReporting.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1070842
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1070842</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for error reporting behavior. **/
+ SimpleTest.waitForExplicitFinish();
+
+ function testErrorReportingHelper(f, rgxp, preventDefault) {
+ return new Promise(function(resolve, reject) {
+ window.addEventListener('error', function l(e) {
+ window.removeEventListener('error', l);
+ ok(rgxp.test(e.message), "Should get message matching " + rgxp + ". Got: " + e.message);
+ var expectedMessages;
+ if (preventDefault) {
+ e.preventDefault();
+ expectedMessages = [];
+ } else {
+ expectedMessages = [{message: rgxp}];
+ }
+ SimpleTest.monitorConsole(resolve, expectedMessages, /* forbidUnexpectedMsgs = */ true);
+ setTimeout(SimpleTest.endMonitorConsole.bind(SimpleTest), 0);
+ });
+
+ // Notify the test harness to avoid treating the next exception as a test failure.
+ SimpleTest.expectUncaughtException();
+
+ // Invoke the function async so that the exception doesn't get eaten by
+ // the Promise machinery.
+ setTimeout(f, 0);
+ });
+ }
+ function testErrorReporting(f, rgxp) {
+ return new Promise(function(resolve, reject) {
+ testErrorReportingHelper.bind(null, f, rgxp, false)().then(
+ testErrorReportingHelper.bind(null, f, rgxp, true)).then(
+ resolve);
+ });
+ }
+
+ function go() {
+ var otherWin = $('emptyFrame').contentWindow;
+ var clickMe = $('clickMe');
+ testErrorReporting.bind(null, () => { throw Error("Simple Error") }, /Simple Error/)().then(
+ testErrorReporting.bind(null, () => otherWin.eval('throw Error("Cross Global Error")'), /Cross Global Error/)).then(
+ testErrorReporting.bind(null, () => clickMe.dispatchEvent(new MouseEvent('click')), /thrwan/)).then(
+ testErrorReporting.bind(null, () => { clickMe.setAttribute('onclick', ' '); /* Make sure we recompile. */
+ clickMe.setAttribute('onclick', '?');
+ clickMe.onclick; }, /SyntaxError/)).then(
+ SimpleTest.finish.bind(SimpleTest));
+ }
+
+ </script>
+</head>
+<body onload="go();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1070842">Mozilla Bug 1070842</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+<button id="clickMe" onclick="thrwan.error;">Click Me</button>
+<iframe id="emptyFrame"></iframe>
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_onerror_message.html b/dom/tests/mochitest/bugs/test_onerror_message.html
new file mode 100644
index 000000000..591928cd8
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_onerror_message.html
@@ -0,0 +1,99 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=743049
+-->
+<head>
+ <meta charset="UTF-8">
+ <title>Test for Bug 743049</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=743049">Mozilla Bug 743049</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <iframe id="frame"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+"use strict";
+
+/** Test for Bug 743049 **/
+
+var expected = [
+{ name: "Error", message: "foo", filename: String(location), lineNumber: 45 },
+{ name: "Error", message: "foo", filename: "bar", lineNumber: 123 },
+{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "DuckError", message: "foo", filename: "bar", lineNumber: 123 },
+{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "", message: "foo", filename: "baz", lineNumber: 123 },
+{ name: "", message: "uncaught exception: [object Object]" },
+{ name: "InvalidStateError", message: "XMLHttpRequest state must not be LOADING or DONE.", filename: String(location), lineNumber: 62 },
+{ name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 64 },
+{ name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 66 }
+];
+
+var counter = 0;
+var origin = location.protocol + "//" + location.host;
+postMessage(counter, origin);
+window.onmessage = function(e) {
+ if (e.origin !== origin)
+ return;
+ try {
+ if (e.data == 0) {
+ throw new Error("foo");
+ } else if (e.data == 1) {
+ throw new Error("foo","bar",123);
+ } else if (e.data == 2) {
+ throw {};
+ } else if (e.data == 3) {
+ throw {name:"DuckError",message:"foo",filename:"bar",lineNumber:123};
+ } else if (e.data == 4) {
+ throw {name:"DuckError",filename:"bar",lineNumber:123};
+ } else if (e.data == 5) {
+ throw {message:"foo",fileName:"baz",lineNumber:123};
+ } else if (e.data == 6) {
+ throw {name:3,message:4,lineNumber:123};
+ } else if (e.data == 7) {
+ var x = new XMLHttpRequest();
+ x.open("GET", location, false);
+ var a = x.send();
+ x.responseType = "arraybuffer";
+ } else if (e.data == 8) {
+ throw new ReferenceError("xxx is not defined");
+ } else if (e.data == 9) {
+ new xxx;
+ } else {
+ SimpleTest.finish();
+ return;
+ }
+ } catch (e) {
+ if (e instanceof Error || typeof e.message=="string" &&
+ ("filename" in e || "fileName" in e) && "lineNumber" in e) {
+ is(e.message, expected[counter].message, counter + " catch message");
+ is(e.filename || e.fileName, expected[counter].filename, counter + " catch filename");
+ is(e.lineNumber, expected[counter].lineNumber, counter + " catch lineno");
+ } else {
+ is("uncaught exception: " + e, expected[counter].message, counter + " catch message");
+ is(undefined, expected[counter].filename, counter + " catch filename");
+ is(undefined, expected[counter].lineNumber, counter + " catch lineno");
+ }
+ throw e;
+ }
+ ok(false, counter + " Error should be thrown or test should finish");
+};
+window.onerror = function(message, filename, lineno) {
+ is(message, Error.prototype.toString.call(expected[counter]), counter + " onerror message");
+ is(filename, expected[counter].filename || "", counter + " onerror filename");
+ is(lineno, expected[counter].lineNumber || 0, counter + " onerror lineno");
+ postMessage(++counter, origin);
+ return true;
+};
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_protochains.html b/dom/tests/mochitest/bugs/test_protochains.html
new file mode 100644
index 000000000..0e6149126
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_protochains.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=817420
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 817420</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=817420">Mozilla Bug 817420</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 817420 **/
+is(Object.getPrototypeOf(HTMLElement.prototype), Element.prototype,
+ "Must have correct proto chain for HTMLElement.prototype");
+is(Object.getPrototypeOf(document.createElementNS(null, "x")),
+ Element.prototype,
+ "Must have correct proto chain for random element");
+is(Object.getPrototypeOf(document.createElement("noSuchElementName")),
+ HTMLUnknownElement.prototype,
+ "Must have correct proto chain for random HTML element");
+
+// And check that it's really working as it should
+function checkPropPresent(propName, objList, expected)
+{
+ for (obj of objList) {
+ is(propName in obj,
+ expected,
+ obj + " should " + (expected ? "" : "not ") + "have the property");
+ }
+}
+var objList = [ Element.prototype,
+ HTMLElement.prototype,
+ document.createElementNS(null, "x"),
+ document.createElement("noSuchElementName"),
+ document.body ]
+checkPropPresent("somePropertyThatBetterNeverExist", objList, false);
+Element.prototype.somePropertyThatBetterNeverExist = 1;
+checkPropPresent("somePropertyThatBetterNeverExist", objList, true);
+
+objList = [ HTMLElement.prototype,
+ document.createElement("noSuchElementName"),
+ document.body ]
+checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, false);
+HTMLElement.prototype.someOtherPropertyThatBetterNeverExist = 1;
+checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, true);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_resize_move_windows.html b/dom/tests/mochitest/bugs/test_resize_move_windows.html
new file mode 100644
index 000000000..0762e9231
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_resize_move_windows.html
@@ -0,0 +1,378 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=565541
+-->
+<head>
+ <title>Test for Bug 565541</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565541">Mozilla Bug 565541</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 565541 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var previousX, previousY, previousWidth, previousHeight;
+
+["innerWidth", "innerHeight", "screenX", "screenY", "outerWidth",
+ "outerHeight"].map(function(name) {
+ window[name+"Getter"] = Object.getOwnPropertyDescriptor(window, name).get;
+});
+
+function backValues()
+{
+ previousX = window.screenX;
+ previousY = window.screenY;
+ previousWidth = window.innerWidth;
+ previousHeight = window.innerHeight;
+}
+
+function restoreValues()
+{
+ window.screenX = previousX;
+ window.screenY = previousY;
+ window.innerWidth = previousWidth;
+ window.innerHeight = previousHeight;
+}
+
+function getNewWidth(aWindow)
+{
+ return (aWindow.innerWidth > (screen.width / 2)) ? 100 : screen.width;
+}
+
+function getNewHeight(aWindow)
+{
+ return (aWindow.innerHeight > (screen.height / 2)) ? 100 : screen.height;
+}
+
+function getNewX(aWindow)
+{
+ return (aWindow.screenX > ((screen.width - aWindow.outerWidth) / 2))
+ ? 0 : screen.width - aWindow.outerWidth;
+}
+
+function getNewY(aWindow)
+{
+ return (aWindow.screenY > ((screen.height - aWindow.outerHeight) / 2))
+ ? 0 : screen.height - aWindow.outerHeight;
+}
+
+/**
+ * hitEventLoop is called when we want to check something but we can't rely on
+ * an event or a specific number of event loop hiting.
+ * This method can be called by specifying a condition, a test (using SimpleTest
+ * API), how many times the event loop has to be hitten and what to call next.
+ * If times < 0, the event loop will be hitten as long as the condition isn't
+ * true or the test doesn't time out.
+ */
+function hitEventLoop(condition, test, times) {
+ return new Promise(function(resolve, reject) {
+ function doMagic() {
+ if (condition() || times == 0) {
+ test();
+ resolve();
+ return;
+ }
+
+ setTimeout(doMagic, 0, condition, test, times - 1);
+ }
+
+ doMagic();
+ });
+}
+
+function checkChangeIsDisabled(aWindow) {
+ // We want to check that nothing has changed. Having a high value would take
+ // too much time. Worse thing that could happen is random green.
+ var hits = 5;
+
+ function getProp(propName) {
+ return window[propName + "Getter"].call(aWindow);
+ }
+
+ var originalWidth = getProp("innerWidth");
+ var originalHeight = getProp("innerHeight");
+
+ var originalX = getProp("screenX");
+ var originalY = getProp("screenY");
+
+ var oWidth = getProp("outerWidth");
+ var oHeight = getProp("outerHeight");
+
+ function changeCondition() {
+ return aWindow.innerWidth != originalWidth ||
+ aWindow.innerHeight != originalHeight ||
+ aWindow.screenX != originalX || aWindow.screenY != originalY ||
+ aWindow.outerWidth != oWidth || aWindow.outerHeight != oHeight;
+ }
+
+ function changeTest() {
+ is(getProp("innerWidth"), originalWidth,
+ "Window width shouldn't have changed");
+ is(getProp("innerHeight"), originalHeight,
+ "Window height shouldn't have changed");
+ is(getProp("screenX"), originalX,
+ "Window x position shouldn't have changed");
+ is(getProp("screenY"), originalY,
+ "Window y position shouldn't have changed");
+ is(getProp("outerWidth"), oWidth,
+ "Window outerWidth shouldn't have changed");
+ is(getProp("outerHeight"), oHeight,
+ "Window outerHeight shouldn't have changed");
+ }
+
+ /**
+ * Size changes.
+ */
+ var newWidth = getNewWidth(aWindow);
+ var newHeight = getNewHeight(aWindow);
+
+ aWindow.innerWidth = newWidth;
+ aWindow.innerHeight = newHeight;
+
+ aWindow.resizeTo(newWidth, newHeight);
+
+ aWindow.resizeBy(newWidth - aWindow.innerWidth,
+ newHeight - aWindow.innerHeight);
+
+ aWindow.sizeToContent();
+
+ /**
+ * Position checks.
+ */
+ var newX = getNewX(aWindow);
+ var newY = getNewY(aWindow);
+
+ aWindow.screenX = newX;
+ aWindow.screenY = newY;
+
+ aWindow.moveTo(newX, newY);
+
+ aWindow.moveBy(newX - aWindow.screenX,
+ newY - aWindow.screenY);
+
+ /**
+ * Outer width/height checks.
+ */
+ aWindow.outerWidth *= 2;
+ aWindow.outerHeight *= 2;
+
+ // We did a lot of changes. Now, we are going to wait and see if something
+ // happens.
+ // NOTE: if this happens to fail, you will have to check manually which
+ // operation has been accepted.
+ return hitEventLoop(changeCondition, changeTest, hits);
+}
+
+function checkChangeIsEnabled(aWindow, aNext)
+{
+ // Something should happen. We are not going to go to the next test until
+ // it does.
+ var hits = -1;
+
+ var prevWidth;
+ var prevHeight;
+
+ var prevX;
+ var prevY;
+
+ var oWidth;
+ var oHeight;
+
+ function sizeChangeCondition() {
+ return aWindow.innerWidth != prevWidth && aWindow.innerHeight != prevHeight;
+ }
+
+ function sizeChangeTest() {
+ isnot(aWindow.innerWidth, prevWidth, "Window width should have changed");
+ isnot(aWindow.innerHeight, prevHeight, "Window height should have changed");
+
+ prevWidth = aWindow.innerWidth;
+ prevHeight = aWindow.innerHeight;
+ }
+
+ function posChangeCondition() {
+ // With GTK, sometimes, only one dimension changes.
+ if (navigator.platform.indexOf('Linux') != -1) {
+ return aWindow.screenX != prevX || aWindow.screenY != prevY;
+ }
+ return aWindow.screenX != prevX && aWindow.screenY != prevY;
+ }
+
+ function posChangeTest() {
+ // With GTK, sometimes, only one dimension changes.
+ if (navigator.platform.indexOf('Linux') != -1) {
+ // With GTK, sometimes, aWindow.screenX changes during two calls.
+ // So we call it once and save the returned value.
+ var x = aWindow.screenX;
+ var y = aWindow.screenY;
+ if (x != prevX) {
+ isnot(x, prevX, "Window x position should have changed");
+ }
+ if (y != prevY) {
+ isnot(y, prevY, "Window y position should have changed");
+ }
+ } else {
+ isnot(aWindow.screenX, prevX, "Window x position should have changed");
+ isnot(aWindow.screenY, prevY, "Window y position should have changed");
+ }
+
+ prevX = aWindow.screenX;
+ prevY = aWindow.screenY;
+ }
+
+ function outerChangeCondition() {
+ return aWindow.outerWidth != oWidth && aWindow.outerHeight != oHeight;
+ }
+
+ function outerChangeTest() {
+ isnot(aWindow.outerWidth, oWidth, "Window outerWidth should have changed");
+ isnot(aWindow.outerHeight, oHeight, "Window outerHeight should have changed");
+ }
+
+ /**
+ * Size checks.
+ */
+ prevWidth = aWindow.innerWidth;
+ prevHeight = aWindow.innerHeight;
+ aWindow.innerWidth = getNewWidth(aWindow);
+ aWindow.innerHeight = getNewHeight(aWindow);
+
+ hitEventLoop(sizeChangeCondition, sizeChangeTest, hits)
+ .then(function() {
+ aWindow.resizeTo(getNewWidth(aWindow), getNewHeight(aWindow));
+ return hitEventLoop(sizeChangeCondition, sizeChangeTest, hits);
+ })
+ .then(function () {
+ aWindow.resizeBy(getNewWidth(aWindow) - aWindow.innerWidth,
+ getNewHeight(aWindow) - aWindow.innerHeight);
+ return hitEventLoop(sizeChangeCondition, sizeChangeTest, hits);
+ })
+ .then(function() {
+ aWindow.sizeToContent();
+ return hitEventLoop(sizeChangeCondition, sizeChangeTest, hits);
+ })
+ .then(function() {
+ /**
+ * Position checks.
+ */
+ prevX = aWindow.screenX;
+ prevY = aWindow.screenY;
+
+ aWindow.screenX = getNewX(aWindow);
+ aWindow.screenY = getNewY(aWindow);
+ return hitEventLoop(posChangeCondition, posChangeTest, hits);
+ })
+ .then(function() {
+ prevX = aWindow.screenX;
+ prevY = aWindow.screenY;
+
+ aWindow.moveTo(getNewX(aWindow), getNewY(aWindow));
+ return hitEventLoop(posChangeCondition, posChangeTest, hits);
+ })
+ .then(function() {
+ prevX = aWindow.screenX;
+ prevY = aWindow.screenY;
+
+ aWindow.moveBy(getNewX(aWindow) - aWindow.screenX,
+ getNewY(aWindow) - aWindow.screenY);
+ return hitEventLoop(posChangeCondition, posChangeTest, hits);
+ })
+ .then(function() {
+ /**
+ * Outer width/height checks.
+ */
+ oWidth = aWindow.outerWidth;
+ oHeight = aWindow.outerHeight;
+
+ aWindow.outerWidth = oWidth * 2;
+ aWindow.outerHeight = oHeight * 2;
+ return hitEventLoop(outerChangeCondition, outerChangeTest, hits);
+ })
+ .then(function() {
+ let origWidth = oWidth;
+ let origHeight = oHeight;
+
+ oWidth = aWindow.outerWidth;
+ oHeight = aWindow.outerHeight;
+
+ aWindow.outerWidth = origWidth;
+ aWindow.outerHeight = origHeight;
+ return hitEventLoop(outerChangeCondition, outerChangeTest, hits);
+ })
+ .then(aNext);
+}
+
+SpecialPowers.pushPrefEnv({"set": [["dom.disable_window_move_resize", false]]}, function() {
+SimpleTest.waitForFocus(function() {
+ if (screen.width <= 200 || screen.height <= 200) {
+ todo(false, "The screen needs to be bigger than 200px*200px to run this test.");
+ SimpleTest.finish();
+ return;
+ }
+
+ backValues();
+
+ // The current window can't change it's own size and position.
+ checkChangeIsDisabled(window).then(function() {
+ // We create a window and check that it can change its own size and position.
+ // However, passing size/position parameters to window.open should work.
+ var w = window.open("data:text/html,<script>" +
+ "function check(next) {" +
+ " var is_range = function(aTest, aValue, aRange, aMsg) {" +
+ " window.opener.ok(aTest < aValue + aRange && aTest > aValue - aRange, aMsg);" +
+ " };" +
+ " is_range(window.innerWidth, 170, 5, 'parameter width should be taken into account');" +
+ " is_range(window.innerHeight, 170, 5, 'parameter height should be taken into account');" +
+ " is_range(window.screenX, 65, 5, 'parameter screenX should be taken into account');" +
+ " is_range(window.screenY, 65, 5, 'parameter screenY should be taken into account');" +
+ " window.opener.checkChangeIsEnabled(window, next);" +
+ "} <\/script>", '',
+ 'width=170,height=170,screenX=65,screenY=65');
+
+ SimpleTest.waitForFocus(function() {
+ w.check(function() {
+ // The current window can change the size and position of the created one.
+ checkChangeIsEnabled(w, function() {
+ w.close();
+
+ // If we call window.open with an empty string as a third parameter,
+ // by default, it will create a new tab instead of a new window.
+ // In that case, we shouldn't allow the caller to change the size/position.
+ w = window.open("data:text/html,<script>" +
+ "function check(next) {" +
+ " window.opener.checkChangeIsDisabled(window).then(next);" +
+ "} <\/script>", '', '');
+
+ SimpleTest.waitForFocus(function() {
+ w.check(function() {
+
+ // The current window can't change the size and position of the new tab.
+ checkChangeIsDisabled(w).then(function() {
+ w.close();
+
+ restoreValues();
+ SimpleTest.finish();
+ });
+ });
+ }, w, false);
+ });
+ })
+ }, w, false);
+ });
+});
+}); // SpecialPowers.pushPrefEnv()
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html b/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html
new file mode 100644
index 000000000..90767e6fb
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=764240
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 764240</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=764240">Mozilla Bug 764240</a>
+<p id="display"></p>
+<div id="content">
+ <button onclick="test();">run test</button>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 764240 **/
+
+SimpleTest.waitForExplicitFinish();
+
+// Error margin allowed for the window's size. Windows has varying minimum
+// sizes depending on the os due to outer window chrome. Unix is given 5
+// pixels to protect against minor variances.
+var epsilon = navigator.platform.indexOf("Win") == -1 ? 5 : 20;
+
+// Windows 8 has a minimum 122 pixel inner window width due to
+// outer window chrome.
+var isWin8 = (navigator.userAgent.indexOf("Windows NT 6.2") != -1);
+
+var innerWidthMin = (isWin8 ? 120 : 100);
+var innerWidthMax = (isWin8 ? 125 : 100);
+
+var isExecuted = false;
+
+function test() {
+ var w = window.open('data:text/html,null', null, 'width=300,height=300');
+
+ SimpleTest.waitForFocus(function() {
+ w.onresize = function() {
+
+ if (w.innerWidth > 300 - epsilon || isExecuted) {
+ return;
+ }
+
+ isExecuted = true;
+
+ ok(w.innerWidth + epsilon >= innerWidthMin && w.innerWidth - epsilon <= innerWidthMax,
+ "innerWidth should be between " + innerWidthMin + " and " + innerWidthMax + " but it was: " + w.innerWidth);
+ ok(w.innerHeight + epsilon >= 100 && w.innerHeight - epsilon <= 100,
+ "innerHeight should be around 100" + " but it was: " + w.innerHeight);
+
+ w.close();
+
+ SimpleTest.waitForFocus(function() {
+ SimpleTest.finish();
+ });
+ };
+ w.sizeToContent();
+ }, w);
+}
+
+SimpleTest.waitForFocus(function() {
+ synthesizeMouseAtCenter(document.getElementsByTagName('button')[0], {});
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_toJSON.html b/dom/tests/mochitest/bugs/test_toJSON.html
new file mode 100644
index 000000000..c24e6921f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_toJSON.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=760851
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 760851</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 760851 **/
+ SimpleTest.waitForExplicitFinish();
+
+ // We need to skip all the interface constants.
+ var keysToSkip = ["TYPE_NAVIGATE", "TYPE_RELOAD", "TYPE_RESERVED",
+ "TYPE_BACK_FORWARD"];
+
+ // Testing window.performance is sufficient, because checkAttributesMatch is
+ // recursive, so window.performance.navigation and window.performance.timing
+ // get tested as well.
+ var toTest = [window.performance];
+
+ // The event handler has to be initialized or else jsonObj will be undefined
+ window.performance.onresourcetimingbufferfull = function() {};
+
+ function checkAttributesMatch(obj, jsonObj) {
+ if (typeof(obj) !== "object") {
+ throw "Expected obj to be of type \"object\". Test failed.";
+ }
+ if (typeof(jsonObj) !== "object") {
+ is(false, "Expected object " + jsonObj + " to be of type object, but gotten otherwise");
+ }
+ for (key in obj) {
+ if (typeof(obj[key]) === "function" || keysToSkip.indexOf(key) > -1)
+ continue;
+ if (typeof(obj[key]) === "object") {
+ checkAttributesMatch(obj[key], jsonObj[key]);
+ continue;
+ }
+ is(jsonObj[key], obj[key], "values for " + obj + " key " + key + " should match");
+ }
+ }
+
+ function runTest() {
+ toTest.forEach(function(testObj) {
+ var jsonCopy = JSON.parse(JSON.stringify(testObj));
+ checkAttributesMatch(testObj, jsonCopy);
+ });
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body onload="runTest();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=760851">Mozilla Bug 760851</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <p></p>
+ <p></p>
+ <p></p>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/test_window_bar.html b/dom/tests/mochitest/bugs/test_window_bar.html
new file mode 100644
index 000000000..966125906
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_window_bar.html
@@ -0,0 +1,97 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=642338
+-->
+<head>
+ <title>Test for Bug 642338</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=642338">Mozilla Bug 642338</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/* Test that the following window properties work:
+
+ menubar
+ toolbar
+ locationbar
+ personalbar
+ statusbar
+ scrollbars
+
+*/
+
+var numWindows = 0;
+
+/* Called when our popup loads. */
+function testWindow(w)
+{
+
+ // If dom.disable_window_open_feature.X is true, then we can't disable
+ // feature X when we call window.open from content. So to check that our popup
+ // has the right bars shown, we need to check that it obeys first the pref
+ // and then the arguments to window.open, if applicable.
+
+ function checkFeature(feature, prefname) {
+ if (prefname === undefined)
+ prefname = feature;
+
+ if (SpecialPowers.getBoolPref('dom.disable_window_open_feature.' + prefname)) {
+ is(w[feature].visible, true, feature + ' should always be true.');
+ }
+ else {
+ // w.location.search == '?true' if we expect the bars to be on, and
+ // '?false' otherwise. By default, no bars are enabled, so '?default'
+ // can be handled the same way as '?false'.
+ var enabled = w.location.search == '?true';
+ is(w[feature].visible, enabled, feature + ' should follow window.open settings.');
+ }
+ }
+
+ checkFeature('menubar');
+ checkFeature('toolbar');
+ checkFeature('personalbar');
+ checkFeature('statusbar', 'status');
+ checkFeature('locationbar', 'location');
+
+ w.close();
+
+ numWindows++;
+ if (numWindows == 3) {
+ // We're done!
+ SimpleTest.finish();
+ }
+
+}
+
+SimpleTest.waitForExplicitFinish();
+
+// These will call back into testWindow when they open.
+
+var allBarsWindow =
+ window.open('file_window_bar.html?true', 'all-bars',
+ 'menubar=yes,toolbar=yes,location=yes,' +
+ 'personalbar=yes,status=yes,scrollbars=yes',
+ true);
+
+var noBarsWindow =
+ window.open('file_window_bar.html?false', 'no-bars',
+ 'menubar=no,toolbar=no,location=no,' +
+ 'personalbar=no,status=no,scrollbars=no',
+ false);
+
+var defaultWindow =
+ window.open('file_window_bar.html?default', 'default-bars',
+ 'width=500,height=500', false);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/bugs/utils_bug260264.js b/dom/tests/mochitest/bugs/utils_bug260264.js
new file mode 100644
index 000000000..07b98ea7e
--- /dev/null
+++ b/dom/tests/mochitest/bugs/utils_bug260264.js
@@ -0,0 +1,60 @@
+const ALLOW_ACTION = SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION;
+const DENY_ACTION = SpecialPowers.Ci.nsIPermissionManager.DENY_ACTION;
+const UNKNOWN_ACTION = SpecialPowers.Ci.nsIPermissionManager.UNKNOWN_ACTION;
+const PROMPT_ACTION = SpecialPowers.Ci.nsIPermissionManager.PROMPT_ACTION;
+
+/**
+ * Dispatches |handler| to |element|, as if fired in response to |event|.
+ */
+function send(element, event, handler) {
+ function unique_handler() { return handler.apply(this, arguments) }
+ element.addEventListener(event, unique_handler, false);
+ try { sendMouseEvent({ type: event }, element.id) }
+ finally { element.removeEventListener(event, unique_handler, false) }
+}
+
+/**
+ * Because it's not nice to leave popup windows open after the tests are
+ * finished, we need a foolproof way to close some/all window.opened windows.
+ */
+(function(originalOpen) {
+ var wins = [];
+ (window.open = function() {
+ var win = originalOpen.apply(window, arguments);
+ if (win)
+ wins[wins.length] = win;
+ return win;
+ }).close = function(n) {
+ var promises = [];
+ if (arguments.length < 1)
+ n = wins.length;
+ while (n --> 0) {
+ var win = wins.pop();
+ if (win) {
+ let openedWindowID =
+ SpecialPowers.getDOMWindowUtils(win).outerWindowID;
+ promises.push((function(openedWindow) {
+ return new Promise(function(resolve) {
+ let observer = {
+ observe(subject) {
+ let wrapped = SpecialPowers.wrap(subject);
+ let winID = wrapped.QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
+ if (winID == openedWindowID) {
+ SpecialPowers.removeObserver(observer, "outer-window-destroyed");
+ SimpleTest.executeSoon(resolve);
+ }
+ }
+ };
+
+ SpecialPowers.addObserver(observer, "outer-window-destroyed", false);
+ });
+ })(win));
+ win.close();
+ } else {
+ promises.push(Promise.resolve());
+ break;
+ }
+ }
+ return Promise.all(promises);
+ };
+})(window.open);
diff --git a/dom/tests/mochitest/bugs/utils_bug743615.js b/dom/tests/mochitest/bugs/utils_bug743615.js
new file mode 100644
index 000000000..9a6f4af86
--- /dev/null
+++ b/dom/tests/mochitest/bugs/utils_bug743615.js
@@ -0,0 +1,25 @@
+function makePattern(len, start, inc) {
+ var pattern = [];
+ while(len) {
+ pattern.push(start);
+ start = (start + inc) % 256;
+ --len;
+ }
+ return pattern;
+}
+
+function setPattern(imageData, pattern) {
+ if (pattern.length != imageData.data.length)
+ throw Error('Invalid pattern');
+ for (var i = 0; i < pattern.length; ++i)
+ imageData.data[i] = pattern[i];
+}
+
+function checkPattern(imageData, pattern) {
+ if (pattern.length != imageData.data.length)
+ throw Error('Invalid pattern');
+ for (var i = 0; i < pattern.length; ++i)
+ if (imageData.data[i] != pattern[i])
+ return false;
+ return true;
+}
diff --git a/dom/tests/mochitest/bugs/worker_bug743615.js b/dom/tests/mochitest/bugs/worker_bug743615.js
new file mode 100644
index 000000000..22c9f239f
--- /dev/null
+++ b/dom/tests/mochitest/bugs/worker_bug743615.js
@@ -0,0 +1,38 @@
+importScripts('utils_bug743615.js');
+
+self.onmessage = function onMessage(evt) {
+ // Check the pattern that was sent.
+ var imageData = evt.data.imageData;
+ var pattern = evt.data.pattern;
+ var statusMessage = checkPattern(imageData, pattern)
+ ? 'PASS' : 'Got corrupt typed array in worker';
+
+ // Check against the interface object.
+ if (!(imageData instanceof ImageData))
+ statusMessage += ", Bad interface object in worker";
+
+ // Check the getters.
+ if (imageData.width * imageData.height != imageData.data.length / 4) {
+ statusMessage += ", Bad ImageData getters in worker: "
+ statusMessage += [imageData.width, imageData.height].join(', ');
+ }
+
+ // Make sure that writing to .data is a no-op when not in strict mode.
+ var origData = imageData.data;
+ var threw = false;
+ try {
+ imageData.data = [];
+ imageData.width = 2;
+ imageData.height = 2;
+ } catch(e) { threw = true; }
+ if (threw || imageData.data !== origData)
+ statusMessage = statusMessage + ", Should silently ignore sets";
+
+
+
+ // Send back a new pattern.
+ pattern = makePattern(imageData.data.length, 99, 2);
+ setPattern(imageData, pattern);
+ self.postMessage({ statusMessage: statusMessage, imageData: imageData,
+ pattern: pattern });
+}