diff options
Diffstat (limited to 'dom/tests/mochitest/bugs')
147 files changed, 7897 insertions, 0 deletions
diff --git a/dom/tests/mochitest/bugs/bug289714.sjs b/dom/tests/mochitest/bugs/bug289714.sjs new file mode 100644 index 0000000000..ac0f1d1f47 --- /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 0000000000..bc6f6a9031 --- /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 0000000000..fde456a36a --- /dev/null +++ b/dom/tests/mochitest/bugs/bug346659-opener-echoer.html @@ -0,0 +1,6 @@ +<script> + var testNum = decodeURIComponent(window.location.search.substring(1)); + window.opener.opener.postMessage(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 0000000000..d9d6128047 --- /dev/null +++ b/dom/tests/mochitest/bugs/bug346659-opener.html @@ -0,0 +1,9 @@ +<body onload="postBack();"> + <script> + function postBack() { + var s = decodeURIComponent(window.location.search.substring(1)); + 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 0000000000..3096153725 --- /dev/null +++ b/dom/tests/mochitest/bugs/bug346659-parent-echoer.html @@ -0,0 +1,5 @@ +<script> + var testNum = decodeURIComponent(window.location.search.substring(1)); + window.parent.opener.postMessage(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 0000000000..7d675cf20e --- /dev/null +++ b/dom/tests/mochitest/bugs/bug346659-parent.html @@ -0,0 +1,11 @@ +<body onload="postBack();"> + <script> + var childWin; + function postBack() { + childWin = window.frames[0]; + var s = decodeURIComponent(window.location.search.substring(1)); + 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 0000000000..2173e9e6d8 --- /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 0000000000..e8f7d578b9 --- /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 0000000000..c3ceb858b4 --- /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 0000000000..43bcb6028a --- /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/file1_bug414291.html b/dom/tests/mochitest/bugs/file1_bug414291.html new file mode 100644 index 0000000000..0d8be9d052 --- /dev/null +++ b/dom/tests/mochitest/bugs/file1_bug414291.html @@ -0,0 +1 @@ +<html><body onload='close(); opener.result0 = 1;'> diff --git a/dom/tests/mochitest/bugs/file2_bug414291.html b/dom/tests/mochitest/bugs/file2_bug414291.html new file mode 100644 index 0000000000..fdb590c807 --- /dev/null +++ b/dom/tests/mochitest/bugs/file2_bug414291.html @@ -0,0 +1 @@ +<html><body onload='close(); opener.result2 = 2;'> diff --git a/dom/tests/mochitest/bugs/file3_bug414291.html b/dom/tests/mochitest/bugs/file3_bug414291.html new file mode 100644 index 0000000000..e9095f76e1 --- /dev/null +++ b/dom/tests/mochitest/bugs/file3_bug414291.html @@ -0,0 +1 @@ +<html><body onload='close(); returnValue = 3;'> 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 0000000000..ec455fcf22 --- /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 0000000000..080b016d7c --- /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()' srcdoc=' + <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 0000000000..3a3863a61c --- /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 0000000000..83c6f894c1 --- /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 0000000000..2d8c135e95 --- /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_bug873229.js b/dom/tests/mochitest/bugs/file_bug873229.js new file mode 100644 index 0000000000..e2be3f08a2 --- /dev/null +++ b/dom/tests/mochitest/bugs/file_bug873229.js @@ -0,0 +1,6 @@ +// This is a script that will let you get an exception thrown by +// calling bar() with no arguments, say. +var foo = "Some string"; +function bar(x) { + x.trySomething(); +} diff --git a/dom/tests/mochitest/bugs/file_bug927901.html b/dom/tests/mochitest/bugs/file_bug927901.html new file mode 100644 index 0000000000..907b0d96c6 --- /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 0000000000..edc004ad10 --- /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 0000000000..ca105f950d --- /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 0000000000..ee9240e3ae --- /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 0000000000..70478e69af --- /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_resize_move_windows_1.html b/dom/tests/mochitest/bugs/file_resize_move_windows_1.html new file mode 100644 index 0000000000..ebeb993b90 --- /dev/null +++ b/dom/tests/mochitest/bugs/file_resize_move_windows_1.html @@ -0,0 +1,20 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Helper file for test_resize_move_windows.html</title> +</head> +<body> +<script> +function check(next) { + var is_range = function(aTest, aValue, aRange, aMsg) { + window.opener.ok(aTest < aValue + aRange && aTest > aValue - aRange, aMsg + `: ${aTest} vs. ${aValue}`); + }; + 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> +</body> +</html> diff --git a/dom/tests/mochitest/bugs/file_resize_move_windows_2.html b/dom/tests/mochitest/bugs/file_resize_move_windows_2.html new file mode 100644 index 0000000000..7b8764fa7e --- /dev/null +++ b/dom/tests/mochitest/bugs/file_resize_move_windows_2.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Helper file for test_resize_move_windows.html</title> +</head> +<body> +<script> +function check(next) { + window.opener.checkChangeIsDisabled(window).then(next); +} +</script> +</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 0000000000..59b2c16014 --- /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 0000000000..11258fde4e --- /dev/null +++ b/dom/tests/mochitest/bugs/grandchild_bug260264.html @@ -0,0 +1,18 @@ +<html> + <head> + <script 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 0000000000..2721c5c781 --- /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 0000000000..3a922b9b21 --- /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_bug430276-2.html b/dom/tests/mochitest/bugs/iframe_bug430276-2.html new file mode 100644 index 0000000000..0d495cc979 --- /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 0000000000..703eb5dd55 --- /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 0000000000..fd69442bee --- /dev/null +++ b/dom/tests/mochitest/bugs/iframe_bug440572.html @@ -0,0 +1,23 @@ +<html> +<body> +<script> + +var success = 0; + +try { + parent[name].success = 1; + parent.postMessage({ + from: name, + result: success ? "success" : "failure" + }, "http://mochi.test:8888"); +} catch (e) { + parent.postMessage({ + from: name, + result: 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 0000000000..e1df2f6ded --- /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 0000000000..f373393772 --- /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.toml b/dom/tests/mochitest/bugs/mochitest.toml new file mode 100644 index 0000000000..7484ce06c0 --- /dev/null +++ b/dom/tests/mochitest/bugs/mochitest.toml @@ -0,0 +1,325 @@ +[DEFAULT] +tags = "condprof" +prefs = ["dom.window.sizeToContent.enabled=true"] +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_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_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", + "test1_bug369306.html", + "test2_bug369306.html", + "test1_bug622361.html", + "test2_bug622361.html", + "file1_bug414291.html", + "file2_bug414291.html", +] + +["test_DOMWindowCreated_chromeonly.html"] + +["test_bug42976.html"] + +["test_bug49312.html"] +fail-if = ["xorigin"] + +["test_bug61098.html"] + +["test_bug132255.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug159849.html"] + +["test_bug260264.html"] +skip-if = ["os == 'android'"] + +["test_bug260264_nested.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug265203.html"] + +["test_bug289714.html"] +fail-if = ["xorigin"] + +["test_bug291377.html"] + +["test_bug304459.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug308856.html"] + +["test_bug327891.html"] + +["test_bug333983.html"] + +["test_bug335976.xhtml"] + +["test_bug342448.html"] + +["test_bug345521.html"] + +["test_bug346659.html"] +skip-if = [ + "os == 'android' && debug", + "http3", + "http2", +] + +["test_bug369306.html"] +skip-if = ["condprof"] #: "The focus should not have been changed with URL=test2_bug369306.htm" + +["test_bug370098.html"] + +["test_bug377539.html"] + +["test_bug384122.html"] + +["test_bug389366.html"] + +["test_bug393974.html"] + +["test_bug394769.html"] + +["test_bug396843.html"] + +["test_bug400204.html"] + +["test_bug404748.html"] + +["test_bug414291.html"] +tags = "openwindow" + +["test_bug430276.html"] + +["test_bug440572.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug456151.html"] + +["test_bug458091.html"] +skip-if = ["os == 'android'"] # Bug 1525959 + +["test_bug459848.html"] + +["test_bug465263.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug484775.html"] + +["test_bug492925.html"] + +["test_bug495219.html"] + +["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_bug612267.html"] + +["test_bug617296.html"] + +["test_bug620947.html"] + +["test_bug622361.html"] + +["test_bug633133.html"] + +["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_bug740811.html"] + +["test_bug743615.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_bug873229.html"] +support-files = ["file_bug873229.js"] +skip-if = [ + "http3", + "http2", +] + +["test_bug876098.html"] + +["test_bug927901.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug1022869.html"] + +["test_bug1112040.html"] + +["test_bug1160342_marquee.html"] + +["test_bug1171215.html"] +support-files = ["window_bug1171215.html"] +skip-if = [ + "http3", + "http2", +] + +["test_bug1530292.html"] + +["test_bug1551425_reference_to_childnodes_nodelist_keeps_childnodes_alive.html"] + +["test_bug1774135.html"] +skip-if = [ + "http3", + "http2", +] + +["test_devicemotion_multiple_listeners.html"] +skip-if = [ + "os == 'android'", # Bug 1780219 + "http3", + "http2", +] + +["test_domparser_after_blank.html"] + +["test_errorReporting.html"] + +["test_instanceof_error_message.html"] + +["test_navigator_buildID.html"] +skip-if = [ + "http3", + "http2", +] + +["test_no_find_showDialog.html"] +skip-if = ["os == 'android'"] # Bug 1358633 - window.find doesn't work for Android + +["test_onerror_message.html"] + +["test_postmessage.html"] +skip-if = [ + "xorigin", # JavaScript error: http://mochi.xorigin-test:8888/tests/SimpleTest/TestRunner.js, line 157: SecurityError: Permission denied to access property "wrappedJSObject" on cross-origin object + "http3", + "http2", +] + +["test_protochains.html"] + +["test_resize_move_windows.html"] +skip-if = [ + "os == 'android'", # Windows can't change size and position on Android + "os == 'linux'", # Bug 1781569, Bug 1661132 + "os == 'mac'", # Bug 1781569 +] +support-files = [ + "file_resize_move_windows_1.html", + "file_resize_move_windows_2.html", +] + +["test_sizetocontent_clamp.html"] +skip-if = [ + "os == 'android'", #Windows can't change size on Android +] + +["test_toJSON.html"] + +["test_window_bar.html"] diff --git a/dom/tests/mochitest/bugs/test1_bug369306.html b/dom/tests/mochitest/bugs/test1_bug369306.html new file mode 100644 index 0000000000..f1c58929eb --- /dev/null +++ b/dom/tests/mochitest/bugs/test1_bug369306.html @@ -0,0 +1 @@ +<script>opener.focus();</script> diff --git a/dom/tests/mochitest/bugs/test1_bug622361.html b/dom/tests/mochitest/bugs/test1_bug622361.html new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/dom/tests/mochitest/bugs/test1_bug622361.html @@ -0,0 +1 @@ +1 diff --git a/dom/tests/mochitest/bugs/test2_bug369306.html b/dom/tests/mochitest/bugs/test2_bug369306.html new file mode 100644 index 0000000000..f4a5b5ac46 --- /dev/null +++ b/dom/tests/mochitest/bugs/test2_bug369306.html @@ -0,0 +1 @@ +<script>blur();</script> diff --git a/dom/tests/mochitest/bugs/test2_bug622361.html b/dom/tests/mochitest/bugs/test2_bug622361.html new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/dom/tests/mochitest/bugs/test2_bug622361.html @@ -0,0 +1 @@ +2 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 0000000000..fef6714523 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_DOMWindowCreated_chromeonly.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<head> + <title>DOMWindowCreated not visible in content</title> + <script 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"); }); + window.addEventListener("DOMDocElementInserted", function() { ok(false, "DOMDocElementInserted should not have fired"); }); + </script> + + <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 0000000000..da618d48cd --- /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 src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <iframe srcdoc="<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 0000000000..69680a8b93 --- /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 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 0000000000..6fa2f8997b --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug1160342_marquee.html @@ -0,0 +1,288 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1160342 +--> +<head> + <title>Test for Bug 411103</title> + <script 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"); + x.behavior = 'invalid'; + is(x.behavior, "scroll", "Wrong behavior value"); + is(x.getAttribute('behavior'), "invalid", "Wrong behavior attribute"); + x.behavior = 'Slide'; + is(x.behavior, "slide", "Wrong behavior value"); + is(x.getAttribute('behavior'), "Slide", "Wrong behavior attribute"); + x.behavior = 'invalid'; + is(x.behavior, "scroll", "Wrong behavior value"); + x.behavior = null; + is(x.behavior, "scroll", "Wrong behavior value"); + x.behavior = undefined; + is(x.behavior, "scroll", "Wrong behavior value"); + is(x.getAttribute('behavior'), 'undefined', "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, -1, "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 = -0.123 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 = 0 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, 6, "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 scrollamount attribute"); + x.scrollAmount = -2; + is(x.scrollAmount, 6, "Wrong scrollAmount value"); + is(x.getAttribute('scrollamount'), "6", "Wrong scrollamount attribute"); + x.scrollAmount = 'invalid'; + is(x.scrollAmount, 0, "Wrong scrollAmount value"); + is(x.getAttribute('scrollamount'), "0", "Wrong scrollamount attribute"); + x.scrollAmount = 1; + x.scrollAmount = null; + is(x.scrollAmount, 0, "Wrong scrollAmount value"); + is(x.getAttribute('scrollamount'), "0", "Wrong scrollamount attribute"); + x.scrollAmount = '2'; + is(x.scrollAmount, 2, "Wrong scrollAmount value"); + is(x.getAttribute('scrollamount'), "2", "Wrong scrollamount 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, 85, "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"); + x.scrollDelay = -2; + is(x.scrollDelay, 85, "Wrong scrollDelay value"); + is(x.getAttribute('scrolldelay'), "85", "Wrong scrolldelay attribute"); + x.scrollDelay = 'invalid'; + is(x.scrollDelay, 0, "Wrong scrollDelay value"); + is(x.getAttribute('scrolldelay'), "0", "Wrong scrolldelay attribute"); + x.scrollDelay = null; + is(x.scrollDelay, 0, "Wrong scrollDelay value"); + is(x.getAttribute('scrolldelay'), "0", "Wrong scrolldelay attribute"); + x.scrollDelay = -1; + is(x.scrollDelay, 85, "Wrong scrollDelay value"); + is(x.getAttribute('scrolldelay'), "85", "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"); + x.direction = 1; + is(x.direction, "left", "Wrong direction value"); + is(x.getAttribute('direction'), "1", "Wrong direction attribute"); + x.direction = null; + is(x.direction, "left", "Wrong direction value"); + is(x.getAttribute('direction'), "null", "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 0000000000..edd4f5d824 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug1171215.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1022869 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1022869</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="text/javascript"> + + SimpleTest.waitForExplicitFinish(); + + /** Test for Bug 1022869 **/ + async function startTest() { + // Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5) + // Acquire storage access permission here so that the storage used to + // hold cookies with the opened windows works in xorigin tests. Otherwise, + // the iframe containing this page is isolated from first-party storage + // access, which denies access to the same cookie store + if (isXOrigin) { + SpecialPowers.wrap(document).notifyUserGestureActivation(); + await SpecialPowers.addPermission( + "storageAccessAPI", + true, + window.location.href + ); + await SpecialPowers.wrap(document).requestStorageAccess(); + } + // Initialize our cookie. + document.cookie = "a=b"; + + let w = window.open("window_bug1171215.html"); + onmessage = e => { + if (e.data.type == "finish") { + w.close(); + SpecialPowers.clearUserPref("network.cookie.sameSite.laxByDefault"); + SimpleTest.finish(); + return; + } + + if (e.data.type == "info") { + info(e.data.msg); + return; + } + + if (e.data.type == "test") { + ok(e.data.test, e.data.msg); + return; + } + + ok(false, "Unknown message"); + }; + } + + // Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default" + SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", 1], ["network.cookie.sameSite.laxByDefault", false]] }) + .then(startTest); + + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022869">Mozilla Bug 1022869</a> +</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 0000000000..31a4016285 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug132255.html @@ -0,0 +1,39 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=132255 +--> +<head> + <title>Test for Bug 132255</title> + <script 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(/\?.*/, "") + .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_bug1530292.html b/dom/tests/mochitest/bugs/test_bug1530292.html new file mode 100644 index 0000000000..3761c21cd1 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug1530292.html @@ -0,0 +1,47 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1530292 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1530292</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + + /** Test for Bug 1530292 **/ + SimpleTest.waitForExplicitFinish(); + addLoadEvent(() => { + // This is really a crashtest, but we need some cross-origin (and hence + // cross-compartment) windows to test it, so can't use the crashtest + // harness. + try { + ({} instanceof frames[0]); + ok(false, "Should have thrown for same-process window"); + } catch (e) { + is(e.message, "frames[0] is not a function", "frames[0] is not a function"); + } + try { + ({} instanceof frames[1]); + ok(false, "Should have thrown for maybe other-process window"); + } catch (e) { + is(e.message, "frames[1] is not a function", "frames[1] is not a function"); + } + SimpleTest.finish(); + }); + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1530292">Mozilla Bug 1530292</a> +<p id="display"></p> +<div id="content" style="display: none"> + <!-- Cross-origin but same-site; must be same-process --> + <iframe src="//test1.mochi.test:8888/tests/dom/tests/mochitest/bugs/file_empty.html"></iframe> + <!-- Completely cross-origin; might be cross-process --> + <iframe src="//example.org/tests/dom/tests/mochitest/bugs/file_empty.html"></iframe> +</div> +<pre id="test"> +</pre> +</body> +</html> diff --git a/dom/tests/mochitest/bugs/test_bug1551425_reference_to_childnodes_nodelist_keeps_childnodes_alive.html b/dom/tests/mochitest/bugs/test_bug1551425_reference_to_childnodes_nodelist_keeps_childnodes_alive.html new file mode 100644 index 0000000000..be2e297f17 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug1551425_reference_to_childnodes_nodelist_keeps_childnodes_alive.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1551425 +--> +<head> + <meta charset="utf-8"> + <title> + Test for bug 1551425: check reference to childNodes' NodeList keeps the + child nodes alive. + </title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1551425">Mozilla bug 1551425</a> +<p id="display"></p> +<div id="content" style="display: none"> + <div id="d"><div>d2</div></div> +</div> + +<pre id="test"> + <script> + var d = document.getElementById("d"); + + // Get childNodes, don't keep reference to parent. + var childNodes = d.cloneNode(true).childNodes; + + // Trigger GC to remove the cloned node. + SpecialPowers.gc(); + + is(childNodes.length, 1); + is(childNodes[0].textContent, "d2"); + </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 0000000000..0cb1c07bdf --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug159849.html @@ -0,0 +1,44 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=159849 +--> +<head> + <title>Test for Bug 159849</title> + <script 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"); +// Intentionally testing the 'with' statement. +/* eslint-disable-next-line no-with */ +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_bug1774135.html b/dom/tests/mochitest/bugs/test_bug1774135.html new file mode 100644 index 0000000000..6d511e75ec --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug1774135.html @@ -0,0 +1,114 @@ +<!DOCTYPE HTML> +<html> +<meta charset="utf-8"> +<title>Test for Bug 1774135</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> +<style> + .split { + width: 299px; + display: flex; + background: red; /* so we can see if it's visible. It should NOT be visible */ + } + .split>* { + flex: 1 1 auto; + height: 50px; + } + .left { + background: pink; + } + .middle { + background: lightgreen; + } + .right { + background: lightblue; + } +</style> +<script> + function WidthTracker(observed) { + this._observer = new ResizeObserver(this._handleNotification.bind(this)); + this._observed = observed; + } + + WidthTracker.prototype = { + _handleNotification(entries) { + for (let entry of entries) { + this._elemToWidth.set( + entry.target, + entry.devicePixelContentBoxSize[0].inlineSize + ); + } + for (let elem of this._observed) { + if (!this._elemToWidth.has(elem)) { + return; + } + } + // Note(dshin): Wait a tick - we need to let the resize observer loop exit + // and avoid resize loop error. + const resolve = this._resolve; + const result = new Map(this._elemToWidth); + this._observer.disconnect(); + delete this._resolve; + delete this._elemToWidth; + window.requestAnimationFrame(function() { + resolve(result); + }); + }, + start() { + this._elemToWidth = new Map(); + for (const elem of this._observed) { + this._observer.observe(elem); + } + return new Promise(res => { this._resolve = res; }); + }, + }; + async function run_test(tracker, container, children, relativeZoom) { + SpecialPowers.setFullZoom(window, relativeZoom); + let result = await tracker.start(Array.from(children).concat([container])); + let observedChildrenWidths = 0; + for (const child of children) { + observedChildrenWidths += result.get(child); + } + let containerWidth = result.get(container); + is(observedChildrenWidths, containerWidth, "Combined widths of children == container width"); + } + + const originalZoom = SpecialPowers.getFullZoom(window); + let tracker; + let container; + let children; + + const zoomsToTest = [ + 300, + 240, + 200, + 170, + 150, + 133, + 120, + 110, + 100, + 90, + 80, + 67, + 50, + 30, + ]; + + add_task(async () => { + container = document.querySelector('.split'); + children = document.querySelectorAll('.split>*'); + tracker = new WidthTracker(Array.from(children).concat([container])); + }); + for (let i = 0; i < zoomsToTest.length; ++i) { + let relativeZoom = originalZoom * zoomsToTest[i] / 100; + add_task(async () => { await run_test(tracker, container, children, relativeZoom); }); + } + add_task(async () => { SpecialPowers.setFullZoom(window, originalZoom); }); +</script> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1774135">Mozilla Bug 1774135</a> +<div class="split"> + <div class="left"></div> + <div class="middle"></div> + <div class="right"></div> +</div> diff --git a/dom/tests/mochitest/bugs/test_bug260264.html b/dom/tests/mochitest/bugs/test_bug260264.html new file mode 100644 index 0000000000..9259320b4b --- /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 src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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.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") }; + +add_task(async function check_sanity() { + await new Promise(resolve => setTimeout(resolve, 200)); + + await SpecialPowers.pushPermissions([{'type': 'popup', 'remove': true, 'context': document}]); + ok(await SpecialPowers.testPermission('popup', UNKNOWN_ACTION, document), 'popup value should have UNKNOWN permission'); + + await SpecialPowers.pushPermissions([{'type': 'popup', 'allow': true, 'context': document}]); + ok(await SpecialPowers.testPermission('popup', ALLOW_ACTION, document), 'popup value should have ALLOW permission'); + + await SpecialPowers.pushPrefEnv({"set": [["dom.disable_open_during_load", true], + ["dom.popup_allowed_events", "click mouseup"], + ["dom.popup_maximum", 3]]}); + + // Note: UNKNOWN_ACTION is the same as DENY_ACTION. + await SpecialPowers.pushPermissions([{'type': 'popup', 'allow': DENY_ACTION, 'context': document}]); +}); + +add_task(async function run_tests() { + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + await window.open.close(); + + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}); +}); + +add_task(async 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); + + await window.open.close(1); + send(a, "mouseup", checkOpened); + send(a, "mouseup", checkBlocked); + send(a, "mouseup", checkBlocked); + + await window.open.close(); + ok(count > 0, "Windows left open by previous tests?"); + while (count --> 0) { + send(a, "mouseup", checkOpened); + } + send(a, "mouseup", checkBlocked); + + await window.open.close(); + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 2]]}); +}); + +add_task(async function run_tests3() { + send(a, "mouseover", checkBlocked); + + await window.open.close(); + await SpecialPowers.pushPermissions([{'type': 'popup', 'allow': ALLOW_ACTION, 'context': document}]); + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}); +}); + +add_task(async function run_tests4() { + var count; + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + + await window.open.close(); + send(a, "mouseup", checkOpened); + send(a, "mouseup", checkOpened); + send(a, "mouseup", checkOpened); + send(a, "mouseup", checkOpened); + + await window.open.close(); + for (count = 0, n = 0; n < 3; n++) { + send(a, "mouseover", function() { if (window.open("http://example.com")) count++ }); + } + send(a, "mouseover", checkBlocked); + + await window.open.close(1); + send(a, "mouseover", checkOpened); + send(a, "mouseover", checkBlocked); + send(a, "mouseover", checkBlocked); + + await window.open.close(); + ok(count > 0, "Windows left open by previous tests?"); + while (count --> 0) { + send(a, "mouseover", checkOpened); + } + send(a, "mouseover", checkBlocked); + + await window.open.close(); + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events", "click"]]}); +}); + +add_task(async function run_tests5() { + await SpecialPowers.pushPermissions([{'type': 'popup', 'allow': DENY_ACTION, 'context': document}]); +}); + +add_task(async function run_tests6() { + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + + await window.open.close(); + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 2]]}); +}); + +add_task(async function run_tests7() { + send(a, "mouseup", checkBlocked); + + await window.open.close(); + send(a, "mouseover", checkBlocked); + + await window.open.close(); + await SpecialPowers.pushPermissions([{'type': 'popup', 'allow': ALLOW_ACTION, 'context': document}]); + await SpecialPowers.pushPrefEnv({"set": [["dom.popup_maximum", 3]]}); +}); + +add_task(async function run_tests8() { + var count; + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + send(a, "click", checkOpened); + + await window.open.close(); + for (count = 0, n = 0; n < 3; n++) { + send(a, "mouseup", function() { if (window.open("http://example.com")) count++ }); + } + send(a, "mouseup", checkBlocked); + + await window.open.close(1); + send(a, "mouseup", checkOpened); + send(a, "mouseup", checkBlocked); + send(a, "mouseup", checkBlocked); + + await window.open.close(); + ok(count > 0, "Windows left open by previous tests?"); + while (count --> 0) { + send(a, "mouseup", checkOpened); + } + send(a, "mouseup", checkBlocked); + + await window.open.close(); + for (count = 0, n = 0; n < 3; n++) { + send(a, "mouseover", function() { if (window.open("http://example.com")) count++ }); + } + send(a, "mouseover", checkBlocked); + + await window.open.close(1); + send(a, "mouseover", checkOpened); + send(a, "mouseover", checkBlocked); + send(a, "mouseover", checkBlocked); + + await window.open.close(); + ok(count > 0, "Windows left open by previous tests?"); + while (count --> 0) { + send(a, "mouseover", checkOpened); + } + send(a, "mouseover", checkBlocked); + + await window.open.close(); +}); + +</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 0000000000..1021220275 --- /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 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(aNext) { + setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); + }, + report: should_not_have_blocked + }, + { event: "mouseup", + setup(aNext) { + setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext); + }, + report: should_not_have_blocked + }, + { event: "mouseup", + setup(aNext) { + setupPP("click", ALLOW_ACTION, ALLOW_ACTION, aNext); + }, + report: should_not_have_blocked + }, + { event: "mouseup", + setup(aNext) { + setupPP("click", DENY_ACTION, DENY_ACTION, aNext); + }, + report: should_have_blocked + }, + { event: "mouseover", + setup(aNext) { + setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); + }, + report: should_have_blocked + }, + { event: "mouseover", + setup(aNext) { + setupPP("click mouseup", ALLOW_ACTION, ALLOW_ACTION, aNext); + }, + report: should_not_have_blocked + }, + { event: "click", + setup(aNext) { + setupPP("click mouseup", DENY_ACTION, DENY_ACTION, aNext); + }, + report: should_not_have_blocked + }, + { event: "click", + setup(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 0000000000..94f56c0164 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug265203.html @@ -0,0 +1,108 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=265203 +--> +<head> + <title>Test for Bug 265203</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + expectedResult = [ $("a1").firstChild, 7, $("a2") ] + nextTest = test2; + testFocus(); +} +function test2() { + $("a3").focus(); + expectedResult = [ $("a3"), 0, $("a3") ] + nextTest = test3; + testFocus(); +} +function test3() { + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + expectedResult = [ $("a3").firstChild, 7, $("a3") ] + nextTest = SimpleTest.finish; + testFocus(); +} + +function startTest() { + if (gTestStarted) + return; + gTestStarted = true; + SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true]]}, 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 0000000000..11d28347ef --- /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 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 0000000000..321fdf7571 --- /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 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_bug304459.html b/dom/tests/mochitest/bugs/test_bug304459.html new file mode 100644 index 0000000000..766ae4a284 --- /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 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); + +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 0000000000..b954a63a1c --- /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 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 0000000000..4e2e95ea61 --- /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 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 0000000000..c3ace11dbc --- /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 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 0000000000..d219f7115c --- /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 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 srcdoc="<html xmlns='http://www.w3.org/1999/xhtml'><body> <input> </body></html>" style="width: 95%; height: 150px;"></iframe> + +<div id="rootish" style="background: yellow"> + <div> + <input/> + </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("input"); + 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 0000000000..5fd35c1f0f --- /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 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 0000000000..8a396f0d1e --- /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 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 0000000000..20684fa32d --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug346659.html @@ -0,0 +1,207 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=346659 +--> +<head> + <title>Test for Bug 346659</title> + <script 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); +} + +/** + * This function sets up the test according to the data it receives. If the data + * is a JSON string, it will use the object parsed from that to determine how to + * set up the test. + */ +async function handleCmd(evt) { + var cmd; + try { + cmd = JSON.parse(evt.data); + } catch (e) { + // Not json, so it should be a test result. We don't need to set up test. + return false; + } + + if ("load" in cmd) { + var testNum = cmd.load; + + // Set up the testing window property and get necessary information from it. + // We use SpecialPowers.spawn() here since the testing window could be cross + // origin. + var { isOpenerTest, location } = + await SpecialPowers.spawn(wins[testNum], [testNum], testNum => { + var win = content.wrappedJSObject; + win.childWin.x = testNum; + + return { + isOpenerTest: win.childWin.opener == win, + location: content.location.href, + }; + }); + + // Get the test location according to the test. + if (isOpenerTest) { + if ("xsite" in cmd) { + var loc = r(window.location.href, "bug346659-opener-echoer.html?" + testNum); + } else { + var loc = r(location, "bug346659-opener-echoer.html?" + testNum); + } + } else { + if ("xsite" in cmd) { + var loc = r(window.location.href, "bug346659-parent-echoer.html?" + testNum); + } else { + var loc = r(location, "bug346659-parent-echoer.html?" + testNum); + } + } + + // Trigger the loading on the child window of the testing window. + await SpecialPowers.spawn(wins[testNum], [loc], loc => { + content.wrappedJSObject.childWin.location.href = loc; + }); + wins[testNum] = null; + } else if ("write" in cmd) { + var testNum = cmd.write; + + try { + // Set up the test on the testing window. + await SpecialPowers.spawn(wins[testNum], [testNum], testNum => { + var win = content.wrappedJSObject; + win.childWin.x = testNum; + + // Test document.write(). + if (win.childWin.opener == win) { + win.childWin.document.write(` + <script> + window.opener.opener.postMessage("${testNum} - " + window.x, "http://mochi.test:8888/"); + window.opener.close(); + window.close(); + <` + '/script>'); + } else { + win.childWin.document.write(` + <script> + window.parent.opener.postMessage("${testNum} - " + window.x, "http://mochi.test:8888/"); + window.parent.close(); + <` + '/script>'); + } + }); + } catch (e) { + if (e.name != "SecurityError" || e.code != 18) { + throw e; + } + // Security error on cross-site write() is fine + await SpecialPowers.spawn(wins[testNum], [], () => { + var win = content.wrappedJSObject; + if (win.childWin.opener == win) { + win.childWin.close(); + } + }); + + handleTestEnd(); + } + wins[testNum] = null; + } + return true; +} + +async function messageReceiver(evt) { + // First try to detect a load/write command + if (await 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, "6", "Props on new window's child should not 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); + +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"); + +SpecialPowers.pushPrefEnv({"set": [["dom.security.https_first", false]]}, function() { + 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_bug369306.html b/dom/tests/mochitest/bugs/test_bug369306.html new file mode 100644 index 0000000000..596a74f3bb --- /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 src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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); + w.addEventListener("blur", failHandler); + + aAction(w); + + SimpleTest.executeSoon(function () { + originatingWindow.removeEventListener("focus", failHandler); + w.removeEventListener("blur", failHandler); + + 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); + w.addEventListener("blur", failHandler); + + /** + * 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); + w.removeEventListener("blur", failHandler); + + 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("test1_bug369306.html", test4); +} + +function test4() +{ + focusShouldNotChange2("test2_bug369306.html", 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 0000000000..29614a4372 --- /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 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 0000000000..50148e77b5 --- /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 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()" srcdoc="<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 0000000000..81dc3907e0 --- /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 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 0000000000..82d493c5ea --- /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 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_bug393974.html b/dom/tests/mochitest/bugs/test_bug393974.html new file mode 100644 index 0000000000..fe14355bf6 --- /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 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 0000000000..73bff1b07b --- /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 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 0000000000..bd9dede189 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug396843.html @@ -0,0 +1,240 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=396843 +--> +<head> + <title>Test for Bug 396843</title> + <script 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", "Unknown") +HTML_TAG("area", "Area") +HTML_TAG("b", "Span") +HTML_TAG("base", "Shared") +HTML_TAG("basefont", "Span") +HTML_TAG("bdi", "") +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", "Embed") +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.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 0000000000..0364ec4008 --- /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 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 0000000000..1e9b33427b --- /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 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_bug414291.html b/dom/tests/mochitest/bugs/test_bug414291.html new file mode 100644 index 0000000000..f87b5e0dc5 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug414291.html @@ -0,0 +1,28 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=414291 +--> +<head> + <title>Test for Bug 414291</title> + <script 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; + +window.open("file1_bug414291.html", "w1"); +is(result1, 0, "window should not be opened either as modal or loaded synchronously."); + +window.open("file2_bug414291.html", "w2", "modal=yes"); +is(result2, 0, "window should not be opened either as modal or data loaded synchronously."); + +</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 0000000000..d5f66d456c --- /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 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 srcdoc="<meta http-equiv='Content-Language' content='ja-JP'><base href='http://www.mozilla.org'><p>asdf"></iframe>; + <iframe id=htmlquirks srcdoc="<html><meta charset=ISO-8859-2><body><div></div></body></html>"></iframe> + <iframe id=htmlstd srcdoc="<!DOCTYPE html><html><meta charset=ISO-8859-3><body><div></div></body></html>"></iframe> + <iframe id=textplain srcdoc="<meta charset=ISO-8859-4>asdf%0Azxcv%0A"></iframe> + <iframe id=xhtmlstd srcdoc="<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><meta charset=ISO-8859-5><body><div></div></body></html>"></iframe> + <iframe id=xmlstd srcdoc="<meta charset=ISO-8859-6><svg xmlns="http://www.w3.org/2000/svg" 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 0000000000..907ab0795e --- /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 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_bug440572.html b/dom/tests/mochitest/bugs/test_bug440572.html new file mode 100644 index 0000000000..f89f78f2ba --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug440572.html @@ -0,0 +1,54 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=440572 +--> +<head> + <title>Test for Bug 440572</title> + <script 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=440572">Mozilla Bug 440572</a> + +<script class="testbody" type="text/javascript"> + +/** Test for Bug 440572 **/ + +var messages = new Map(); + +function receiveMessage(e) +{ + is(e.origin, "http://example.org", "wrong sender!"); + messages.set(e.data.from, e.data.result); + // Runtests after receiving the right number of messages. + if (messages.size == 4) { + runtests(); + } +} + +window.addEventListener("message", receiveMessage); + +function runtests() +{ + is(messages.get("test"), "success", "test in frame failed."); + is(messages.get("dump"), "success", '"dump" in frame failed.'); + is(messages.get("open"), "success", '"open" in frame failed.'); + isnot(messages.get("close"), "success", "parent[\"close\"] 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="dump" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe> +<br> +<iframe name="open" src="http://example.org:80/tests/dom/tests/mochitest/bugs/iframe_bug440572.html"></iframe> +<br> +<iframe name="close" 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 0000000000..7b0cb22776 --- /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 src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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); +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); +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; }); +} 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 0000000000..2bb6bc5404 --- /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 src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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" rel="opener" href="javascript:window.opener.finish(sessionStorage['testItem']);window.close();">Javascript Link</a> +<a id="testlink2" target="_blank" rel="opener" 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) { + 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 0000000000..495711fdb7 --- /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 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.remove(); + 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 0000000000..a7c95b5177 --- /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 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_bug484775.html b/dom/tests/mochitest/bugs/test_bug484775.html new file mode 100644 index 0000000000..31edf0447e --- /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 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); +attr.dispatchEvent(event); +is(eventCount, 1, "Should have fired an event!"); +attr.removeEventListener(expectedType, listener); + +var df = document.createDocumentFragment(); +expectedTarget = df; +df.addEventListener(expectedType, listener); +df.dispatchEvent(event); +is(eventCount, 2, "Should have fired an event!"); +df.removeEventListener(expectedType, listener); + +</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 0000000000..d7a067611f --- /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 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 0000000000..14e6d56287 --- /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 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 0000000000..8fd04862e9 --- /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 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_bug529328.html b/dom/tests/mochitest/bugs/test_bug529328.html new file mode 100644 index 0000000000..231234f4db --- /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 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 0000000000..f091c0d475 --- /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 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 0000000000..89dcd702a4 --- /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 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 0000000000..8c1a8b7e4d --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug534149.html @@ -0,0 +1,85 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=534149 +--> +<head> + <title>Test for Bug 534149</title> + <script 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; + + let wgc = SpecialPowers.wrap(win).windowGlobalChild; + return [wgc.outerWindowId, wgc.innerWindowId]; +} + +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 = null; +var outerWindowDestroyID = null; + +var outerObserver = { + observe(id) { + outerWindowDestroyID = + SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data; + SpecialPowers.removeObserver(outerObserver, "outer-window-destroyed"); + maybeContinueTest(); + } +}; +var innerObserver = { + observe(id) { + innerWindowDestroyID = + SpecialPowers.wrap(id).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data; + SpecialPowers.removeObserver(innerObserver, "inner-window-destroyed"); + maybeContinueTest(); + } +}; + +function removeFrame(iframe) { + SpecialPowers.addObserver(outerObserver, "outer-window-destroyed"); + SpecialPowers.addObserver(innerObserver, "inner-window-destroyed"); + + iframe.remove(); +} + +function maybeContinueTest() { + if (innerWindowDestroyID != null && + outerWindowDestroyID != null) { + is(innerWindowDestroyID, i1inner, "inner window of frame 1 should be destroyed"); + is(outerWindowDestroyID, i1outer, "outer window of frame 1 should be destroyed"); + SimpleTest.finish(); + } +} + +removeFrame(i1); +SimpleTest.waitForExplicitFinish(); + +</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 0000000000..f43dba8aa9 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug541530.html @@ -0,0 +1,94 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=541530 +--> +<head> + <title>Test for Bug 411103</title> + <script 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; +/* eslint-disable no-useless-call */ +try { + this.__defineGetter__.call(this, 'bar', function() {}); + this.__defineSetter__.call(this, 'bar', function() {}); + canDefine = true; +} catch (e) {} +/* eslint-enable no-useless-call */ +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 0000000000..09bf74fb4e --- /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 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 0000000000..83602e6637 --- /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 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 0000000000..9208e3c587 --- /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 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 0000000000..e7fa9da4e7 --- /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 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 0000000000..eeb90bc961 --- /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() {}); + } catch (e) { + exception = e; + } + </script> + <title>Test for Bug 563487</title> + <script 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 0000000000..3878bed0a7 --- /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 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 0000000000..2923bc52bd --- /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 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); +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 0000000000..829f4684ae --- /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 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 0000000000..7efe8fc800 --- /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 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 0000000000..8c24aaf06a --- /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 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_bug61098.html b/dom/tests/mochitest/bugs/test_bug61098.html new file mode 100644 index 0000000000..9502a28749 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug61098.html @@ -0,0 +1,370 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=61098 +--> +<head> + <title>Test for Bug 61098</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script 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; + +var promptState; + +function registerMockPromptService() +{ + var { XPCOMUtils } = SpecialPowers.ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" + ); + var Ci = SpecialPowers.Ci; + + function MockPrompt(aDOMWindow) { + this.domWindow = SpecialPowers.unwrap(aDOMWindow); + } + + MockPrompt.prototype = { + QueryInterface(iid) { + if (iid.equals(Ci.nsIPrompt)) { + return this; + } + throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; + }, + + domWindow : null, + + _toggleModalState() + { + // 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(aDialogTitle, aText) + { + this._toggleModalState(); + promptState = {method: "alert", + parent: SpecialPowers.unwrap(this.domWindow), + title: aDialogTitle, + msg: aText + }; + }, + + alertCheck(aDialogTitle, aText, aCheckMsg, aCheckState) + { + this._toggleModalState(); + promptState = {method: "alertCheck", + parent: SpecialPowers.unwrap(this.domWindow), + title: aDialogTitle, + msg: aText, + checkMsg: aCheckMsg, + checkState: aCheckState + }; + + SpecialPowers.wrap(aCheckState).value = true; + }, + + confirm(aDialogTitle, aText) + { + this._toggleModalState(); + promptState = {method: "confirm", + parent: SpecialPowers.unwrap(this.domWindow), + title: aDialogTitle, + msg: aText + }; + + return true; + }, + + confirmCheck(aDialogTitle, aText, aCheckMsg, aCheckState) + { + this._toggleModalState(); + promptState = {method: "confirmCheck", + parent: SpecialPowers.unwrap(this.domWindow), + title: aDialogTitle, + msg: aText, + checkMsg: aCheckMsg, + checkState: aCheckState + }; + + SpecialPowers.wrap(aCheckState).value = true; + + return true; + }, + + confirmEx(aDialogTitle, aText, aButtonFlags, + aButton0Title, aButton1Title, aButton2Title, + aCheckMsg, aCheckState) + { + this._toggleModalState(); + promptState = {method: "confirmCheck", + parent: SpecialPowers.unwrap(this.domWindow), + title: aDialogTitle, + msg: aText, + checkMsg: aCheckMsg, + checkState: aCheckState + }; + + if (aCheckMsg != null) + SpecialPowers.wrap(aCheckState).value = true; + + return 0; + }, + + prompt(aDialogTitle, aText, aValue, aCheckMsg, + aCheckState) + { + this._toggleModalState(); + promptState = {method: "prompt", + parent: SpecialPowers.unwrap(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(iid) { + if (iid.equals(Ci.nsIPromptFactory) || iid.equals(Ci.nsIPromptService)) { + return this; + } + throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; + }, + + getPrompt(aDOMWindow, aIID) + { + return SpecialPowers.wrapCallbackObject(new MockPrompt(aDOMWindow)); + }, + + alert(aParent, aDialogTitle, aText) + { + var prompt = new MockPrompt(aParent); + return prompt.alert(aDialogTitle, aText); + }, + + alertCheck(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) + { + var prompt = new MockPrompt(aParent); + return prompt.alertCheck(aDialogTitle, aText, aCheckMsg, aCheckState); + }, + + confirm(aParent, aDialogTitle, aText) + { + var prompt = new MockPrompt(aParent); + return prompt.confirm(aDialogTitle, aText); + }, + + confirmCheck(aParent, aDialogTitle, aText, aCheckMsg, + aCheckState) + { + var prompt = new MockPrompt(aParent); + return prompt.confirmCheck(aDialogTitle, aText, aCheckMsg, aCheckState); + }, + + confirmEx(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(aParent, aDialogTitle, aText, aValue, aCheckMsg, + aCheckState) + { + var prompt = new MockPrompt(aParent); + return prompt.prompt(aDialogTitle, aText, aValue, aCheckMsg, aCheckState); + }, + + }; + + mockPromptServiceRegisterer = + new MockObjectRegisterer("@mozilla.org/prompter;1", + MockPromptService); + mockPromptServiceRegisterer.register(); +}; + +var expectedState; + +function runtests() +{ + SpecialPowers.pushPrefEnv({'set': [["dom.successive_dialog_time_limit", 3]]}, + runtestsInner); +} + +async 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(); + + // Then check that alert() gets blocked with a new window, because + // dialogs are disabled/enabled on basis of browsing context groups. + w = window.open(); + + try { + w.alert("alert message 4"); + } catch(e) { + is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception"); + } + + is (promptState, void(0), "Wrong prompt state after blocked alert()"); + + // Reset the state and enable the dialogs again. + SpecialPowers.DOMWindowUtils.enableDialogs(); + SpecialPowers.DOMWindowUtils.resetDialogAbuseState(); + + // Test that confirm() works normally and then gets blocked on the + // second call. + 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(); + + // Then check that confirm() gets blocked with a new window, because + // dialogs are disabled/enabled on basis of browsing context groups. + w = window.open(); + + try { + w.confirm("confirm message 4"); + } catch(e) { + is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception"); + } + + is (promptState, void(0), "Wrong prompt state after blocked prompt()"); + + // Reset the state and enable the dialogs again. + SpecialPowers.DOMWindowUtils.enableDialogs(); + SpecialPowers.DOMWindowUtils.resetDialogAbuseState(); + + // Test that prompt() works normally and then gets blocked on the + // second call. + 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(); + + // Then check that prompt() gets blocked with a new window, because + // dialogs are disabled/enabled on basis of browsing context groups. + w = window.open(); + + try { + w.prompt("prompt message 4"); + } catch(e) { + is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception"); + } + + is (promptState, void(0), "Wrong prompt state after blocked prompt()"); + + w.close(); + + // Reset the state and enable the dialogs again. + SpecialPowers.DOMWindowUtils.enableDialogs(); + SpecialPowers.DOMWindowUtils.resetDialogAbuseState(); + + 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 0000000000..65e3660be1 --- /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 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 0000000000..23f0ebf14b --- /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 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 0000000000..fdca09af24 --- /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 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 0000000000..a8855fc853 --- /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 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("test1_bug622361.html"); + doNext(); + return; + case 2: + w.location = "test2_bug622361.html"; + 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); +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 0000000000..19c61dbfee --- /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 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_bug642026.html b/dom/tests/mochitest/bugs/test_bug642026.html new file mode 100644 index 0000000000..6f24b2120c --- /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 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 0000000000..4ea76555ae --- /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 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 0000000000..1a1c739764 --- /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 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 0000000000..423004b2fc --- /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 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 0000000000..9d31b32c0a --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug665548.html @@ -0,0 +1,28 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=665548 +--> +<head> + <title>Test for Bug 665548</title> + <script 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 0000000000..d069db1969 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug684544.html @@ -0,0 +1,54 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id= +--> +<head> + <title>Test for Bug </title> + <script 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.remove(); + +// 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"); +ok(!!win.location, "Location should not be null"); + +// 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; +} +ok(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"); +ok(!!win.location, "Location should not be null"); + +</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 0000000000..c567cbefad --- /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 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.includes("" + j), "Enumerating hit all numeric properties"); +ok(properties.includes("item"), "Enumerating hit 'item' from the prototype"); +ok(properties.includes("length"), "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 0000000000..f023ca0ad8 --- /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 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 0000000000..a6b73b4efd --- /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 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() { return it; }, +}); +Object.defineProperty(Object.getPrototypeOf(l), "foopy", +{ + get() { 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 0000000000..b3243ce83f --- /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 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()" srcdoc="<script>navigator</script>"></iframe> +</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 0000000000..cf614de0c8 --- /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 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 0000000000..19dbb233dd --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug743615.html @@ -0,0 +1,83 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=743615 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 743615</title> + <script 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, + 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'); + + 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, 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_bug755320.html b/dom/tests/mochitest/bugs/test_bug755320.html new file mode 100644 index 0000000000..4dcfe8e840 --- /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 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 0000000000..8a00cbd1df --- /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 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 }, '*'); +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 0000000000..f6ac91dff6 --- /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 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 0000000000..1be29166a3 --- /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 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 Screen]", + "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 Screen]", + "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 0000000000..bd2c2fa96e --- /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 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 0000000000..24c43c421a --- /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 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 0000000000..82b209966f --- /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 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.wrapFor(is, sb)); + SpecialPowers.setWrapped(sb, 'ok', SpecialPowers.wrapFor(ok, sb)); + 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 0000000000..b72d1573e4 --- /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 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 0000000000..27e77dc0ef --- /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 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() { 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_bug873229.html b/dom/tests/mochitest/bugs/test_bug873229.html new file mode 100644 index 0000000000..c245275159 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug873229.html @@ -0,0 +1,83 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=873229 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 873229</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 873229 **/ + SimpleTest.waitForExplicitFinish(); + addLoadEvent(function() { + // We're going to need to be tricky: we want to trigger onerror without + // getting an exception thrown in our face. Use event dispatch! + var f = $("f").contentWindow; + is(typeof(bar), "function", "bar should be a function"); + is(typeof(f.bar), "function", "bar should be a function in the subframe"); + var string; + var url; + var line; + + var oldOnerror = window.onerror; + + // Now we have to be very careful to not trigger any errors we don't + // expect! + var errorCount = 0; + + window.onerror = function(exceptionString, exceptionURL, exceptionLine) { + string = exceptionString; + url = exceptionURL; + line = exceptionLine; + ++errorCount; + } + + document.documentElement.onclick = function() { + bar(); + }; + string = "FAIL"; + url = "FAIL"; + line = "FAIL"; + document.documentElement.dispatchEvent(new Event("click")); + is(string, "Script error.", "Did not sanitize string"); + is(url, + "http://example.com/tests/dom/tests/mochitest/bugs/file_bug873229.js", + "Should not sanitize URL"); + is(line, 0, "Did not sanitize line"); + + document.documentElement.onclick = function() { + f.bar(); + }; + string = "FAIL"; + url = "FAIL"; + line = "FAIL"; + document.documentElement.dispatchEvent(new Event("click")); + is(string, "Script error.", "Did not sanitize string in iframe"); + is(url, + "http://example.com/tests/dom/tests/mochitest/bugs/file_bug873229.js", + "Should not sanitize URL in iframe"); + is(line, 0, "Did not sanitize line in iframe"); + + document.documentElement.onclick = null; + + is(errorCount, 2, "Should have had two exceptions"); + window.onerror = oldOnerror; + SimpleTest.finish(); + }); + + </script> + <script src="http://example.com/tests/dom/tests/mochitest/bugs/file_bug873229.js"></script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=873229">Mozilla Bug 873229</a> +<p id="display"></p> +<div id="content" style="display: none"> +<iframe id="f" srcdoc="<script src='http://example.com/tests/dom/tests/mochitest/bugs/file_bug873229.js'></script>"></iframe> +</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 0000000000..4c4fa41a57 --- /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 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 0000000000..c012a062db --- /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 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 0000000000..7b0b8ff731 --- /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 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.remove(); + 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 0000000000..d8ea6e09f9 --- /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 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 0000000000..aa299c98cc --- /dev/null +++ b/dom/tests/mochitest/bugs/test_errorReporting.html @@ -0,0 +1,72 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1070842 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1070842</title> + <script 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(e) { + 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); + }, {once: true}); + + // 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_instanceof_error_message.html b/dom/tests/mochitest/bugs/test_instanceof_error_message.html new file mode 100644 index 0000000000..05dfa602f7 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_instanceof_error_message.html @@ -0,0 +1,111 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1530413 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1530413</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + add_task(() => { + var Cu = SpecialPowers.Cu; + try { + // Test case 1 + ({} instanceof {}); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "({}) is not a function", "We should get a correct error message when calling instanceof"); + } + // Test case 2 + try { + ({} instanceof document); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "document is not a function", "We should get a correct error message when calling instanceof"); + } + // Test case 3 + try { + ({} instanceof new Proxy(document, {})); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "(new Proxy(...)) is not a function", "We should get a correct error message when calling instanceof"); + } + // Test case 4 - Verify invoking instanceof on an object from a different compartment yields the same error + var sandbox = SpecialPowers.unwrap(Cu.Sandbox(this, { sameZoneAs: this, freshCompartment: true, wantXrays: false })); + sandbox.window = window; + sandbox.crossCompartmentObject = {}; // object created in the test compartment + try { + Cu.evalInSandbox("({} instanceof window);", sandbox); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "window is not a function", "We should get a correct error message when calling instanceof"); + } + + // Test case 5 - Verify we get the same error when the LHS is an object created in a different compartment + try { + Cu.evalInSandbox("(crossCompartmentObject instanceof window);", sandbox); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "window is not a function", "We should get a correct error message when calling instanceof"); + } + + // Test case 6 - Test that we are correctly wrapping the window into sandbox's compartment + window[Symbol.hasInstance] = function(instance) { + instance.window = this; + return true; + } + var x = Cu.evalInSandbox("(crossCompartmentObject instanceof window);", sandbox); + ok(x, "Symbol.hasInstance for window should return true"); + is(sandbox.crossCompartmentObject.window, window, "We shouldn't leak the window"); + delete window[Symbol.hasInstance]; + Cu.nukeSandbox(sandbox); + + // Test case 7 - Test instanceof with RHS being a same-origin Xray to a Window + sandbox = SpecialPowers.unwrap(Cu.Sandbox(this, { sameZoneAs: this, freshCompartment: true})); + sandbox.window = window; + sandbox.crossCompartmentObject = {}; + + window[Symbol.hasInstance] = function(instance) { + instance.window = this; + return true; + } + try { + Cu.evalInSandbox("(crossCompartmentObject instanceof window);", sandbox); + ok(false, "Should throw a type error"); + } catch (e) { + is(e.message, "window is not a function", + "We should get a correct error thrown when the RHS of instanceof is an Xray to a Window."); + } + delete window[Symbol.hasInstance]; + Cu.nukeSandbox(sandbox); + + // Test case 8 - Test instanceof with RHS being a same-origin Xray waiver + sandbox = SpecialPowers.unwrap(Cu.Sandbox(this, { sameZoneAs: this, freshCompartment: true})); + sandbox.window = window; + sandbox.crossCompartmentObject = {}; + sandbox.waiveXrays = SpecialPowers.wrapFor(Cu.waiveXrays, sandbox); + + window[Symbol.hasInstance] = function(instance) { + instance.window = this; + return true; + } + Cu.evalInSandbox("(crossCompartmentObject instanceof waiveXrays(window));", sandbox); + ok(x, "Symbol.hasInstance for window should return true"); + is(sandbox.crossCompartmentObject.window, window, + "The window pointed to by the crossCompartmentObject should be the same as the window in our compartment"); + delete window[Symbol.hasInstance]; + Cu.nukeSandbox(sandbox); + }); + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1530413">Mozilla Bug 1530413</a> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +</pre> +</body> +</html>
\ No newline at end of file diff --git a/dom/tests/mochitest/bugs/test_navigator_buildID.html b/dom/tests/mochitest/bugs/test_navigator_buildID.html new file mode 100644 index 0000000000..231bd99c23 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_navigator_buildID.html @@ -0,0 +1,93 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=583181 +--> +<head> + <title>Test for Bug 583181</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/ChromeTask.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body onload="onLoad()"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583181">Mozilla Bug 583181</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script class="testbody" type="text/javascript"> +"use strict"; + +SimpleTest.waitForExplicitFinish(); + +const LEGACY_BUILD_ID = 20181001000000; + +// +// Access navigator.buildID from unprivileged web content. +// +var isOK = false; +try { + var contentBuildID = navigator.buildID; + isOK = true; +} catch (ex) { +} +ok(isOK, "navigator.buildID should never throw"); +is(typeof(contentBuildID), "string", "navigator.buildID should be a string"); +is(+contentBuildID, LEGACY_BUILD_ID, + "navigator.buildID should be spoofed in content"); + +async function onLoad() { + // + // Access navigator.buildID from chrome. + // + let chromeBuildID = await ChromeTask.spawn(null, () => { + const browser = Services.wm.getMostRecentBrowserWindow(); + return browser.navigator.buildID; + }); + + ok(+chromeBuildID > LEGACY_BUILD_ID, + `navigator.buildID should be exposed in chrome - got "${chromeBuildID}"`); + + // + // Access navigator.buildID from mozilla.org. + // + let mozillaBuildID = await getMozillaBuildID(); + + ok(+mozillaBuildID > LEGACY_BUILD_ID, + `navigator.buildID should be exposed on mozilla.org ` + + `- got "${mozillaBuildID}"`); + is(chromeBuildID, mozillaBuildID, + "navigator.buildID should be the same in chrome and on mozilla.org"); + + // + // Access navigator.buildID from mozilla.org when resisting fingerprinting. + // + await SpecialPowers.pushPrefEnv( + {"set": [["privacy.resistFingerprinting", true]]}); + + let resistBuildID = await getMozillaBuildID(); + + is(+resistBuildID, LEGACY_BUILD_ID, + "navigator.buildID should be spoofed on mozilla.org when " + + "resisting fingerprinting"); + + SimpleTest.finish(); +} + +async function getMozillaBuildID() { + let iframe = document.getElementById("mozillaIFrame"); + + await new Promise(resolve => { + iframe.addEventListener("load", resolve, { once: true }); + SpecialPowers.spawn(iframe, [], () => this.content.location.reload()); + }); + + return SpecialPowers.spawn( + iframe, [], () => this.content.wrappedJSObject.navigator.buildID); +} +</script> +</pre> +<iframe id="mozillaIFrame" src="https://www.mozilla.org/" /> +</body> +</html> diff --git a/dom/tests/mochitest/bugs/test_no_find_showDialog.html b/dom/tests/mochitest/bugs/test_no_find_showDialog.html new file mode 100644 index 0000000000..5cfa36ebc0 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_no_find_showDialog.html @@ -0,0 +1,88 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1348409</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <iframe src="about:blank"></iframe> + <script type="text/javascript"> + + async function checkForFindDialog() { + let chromeScript = SpecialPowers.loadChromeScript(_ => { + /* eslint-env mozilla/chrome-script */ + addMessageListener("test:check", () => { + let sawFind = false; + let findDialog = Services.wm.getMostRecentWindow("findInPage"); + if (findDialog) { + findDialog.close(); + sawFind = true; + } + + return sawFind; + }); + + }); + + let sawFind = await chromeScript.sendQuery("test:check"); + chromeScript.destroy(); + return sawFind; + } + + function ensureFinished(chromeScript) { + return new Promise(resolve => { + chromeScript.addMessageListener("test:disarm:done", (sawWindow) => { + resolve(sawWindow); + }); + chromeScript.sendAsyncMessage("test:disarm"); + }); + } + + function doWraparoundFind(findString, showDialog) { + let result = window.find(findString, + false /* aCaseSensitive */, + false /* aBackwards*/, + true /* aWrapAround */, + false /* aWholeWord */, + false /* aSearchInFrames */, + showDialog /* aShowInDialog */) + // Collapse selection so that we can do another find outside + // of the selection result. + document.getSelection().collapseToStart(); + return result; + } + + function startTest() { + add_task(async function() { + ok(doWraparoundFind("text to search for", false), + "Found the text in the document body."); + + // We're asking for the dialog now. We should just ignore that request. + ok(doWraparoundFind("fhqwhgads", true), + "Should return true and not show a dialog if the string exists in the page."); + ok(!doWraparoundFind(null, true), + "Should return false and not show a dialog if we pass a null string."); + ok(!doWraparoundFind("", true), + "Should return false and not show a dialog if we pass an empty string."); + + // Double check to ensure that the parent didn't open a find dialog + let sawWindow = await checkForFindDialog(); + ok(!sawWindow, "Should never have seen the dialog."); + }); + } + </script> +</head> +<body onload="startTest()"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1348409">Mozilla Bug 1348409</a> + +<p> + Here's some text to search for: fhqwhgads! A hovercraft full of eels! +</p> + +<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_onerror_message.html b/dom/tests/mochitest/bugs/test_onerror_message.html new file mode 100644 index 0000000000..476c02d978 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_onerror_message.html @@ -0,0 +1,97 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=743049 +--> +<head> + <meta charset="UTF-8"> + <title>Test for Bug 743049</title> + <script 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]", filename: location.href, lineNumber: 80 }, +{ name: "DuckError", message: "foo", filename: "bar", lineNumber: 123 }, +{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 }, +{ name: "", message: "foo", filename: "baz", lineNumber: 123 }, +{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 }, +{ name: "InvalidStateError", message: "XMLHttpRequest.responseType setter: Cannot set 'responseType' property on XMLHttpRequest after 'send()' (when its state is 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"); + } + 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, counter + " onerror lineno"); + postMessage(++counter, origin); + return true; +}; + +SimpleTest.waitForExplicitFinish(); + +</script> +</pre> +</body> +</html> diff --git a/dom/tests/mochitest/bugs/test_postmessage.html b/dom/tests/mochitest/bugs/test_postmessage.html new file mode 100644 index 0000000000..8dee4ec4a5 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_postmessage.html @@ -0,0 +1,65 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1574017</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/ChromeTask.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + async function waitForErrorMessage(err) { + return ChromeTask.spawn(err, async err => { + await new Promise(resolve => { + let console = Services.console; + console.reset(); + console.registerListener(function listener(aMessage) { + var sourceName = `http://mochi.test:8888/tests/dom/tests/mochitest/bugs/test_postmessage.html`; + if ( + aMessage.message.includes(err) && + aMessage instanceof Ci.nsIScriptError && + aMessage.sourceName == sourceName + ) { + console.unregisterListener(listener); + resolve(); + } + }); + }); + }); + } + add_task(async function testNoCallerURI() { + var Cu = SpecialPowers.Cu; + var princ = SpecialPowers.wrap(window.document).nodePrincipal; + var sandbox = Cu.Sandbox(princ, { sameZoneAs: this }); + SpecialPowers.unwrap(sandbox).win = window.frames.diffDomain; + var err = `Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://example.com’) does not match the recipient window’s origin (‘https://example.org’).`; + let consolePromise = waitForErrorMessage(err); + Cu.evalInSandbox( + 'win.postMessage("We should not be able to post this message", "https://example.com");', + sandbox + ); + await consolePromise; + ok(true, "Error message was logged correctly to the console"); + Cu.nukeSandbox(sandbox); + }); + add_task(async function testWithWindowID() { + var err = `Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://example.ru’) does not match the recipient window’s origin (‘https://example.org’).`; + let consolePromise = waitForErrorMessage(err); + window.frames.diffDomain.postMessage( + "The window should not receive this", + "https://example.ru" + ); + await consolePromise; + ok(true, "Error message was logged correctly to the console"); + }); + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1574017">Mozilla Bug 1574017</a> +<p id="display"></p> +<div id="content" style="display: none"> +</div> +<pre id="test"> +</pre> +<iframe id="diffDomain" name="diffDomain" src="https://example.org/tests/dom/tests/mochitest/bugs/file_empty.html"></iframe> +</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 0000000000..62be36d118 --- /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 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 0000000000..11b2d90f21 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_resize_move_windows.html @@ -0,0 +1,349 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=565541 +--> +<head> + <title>Test for Bug 565541</title> + <script 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> + +/** 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.outerWidth; + previousHeight = window.outerHeight; +} + +function restoreValues() +{ + window.moveTo(previousX, previousY); + window.resizeTo(previousWidth, 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 hit and what to call next. + * If times < 0, the event loop will be hit 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; + } + + times--; + setTimeout(doMagic, 0); + } + + 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.resizeTo(newWidth, newHeight); + + aWindow.resizeBy(newWidth - aWindow.innerWidth, + newHeight - aWindow.innerHeight); + + aWindow.sizeToContent(); + + /** + * Position checks. + */ + var newX = getNewX(aWindow); + var newY = getNewY(aWindow); + + aWindow.moveTo(newX, newY); + + aWindow.moveBy(newX - aWindow.screenX, + newY - aWindow.screenY); + + /** + * Outer width/height checks. + */ + aWindow.resizeTo(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) +{ + info(`checkChangeIsEnabled start`); + // 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.outerWidth != prevWidth && aWindow.outerHeight != prevHeight; + } + + function sizeChangeTest() { + isnot(aWindow.outerWidth, prevWidth, "Window width should have changed"); + isnot(aWindow.outerHeight, prevHeight, "Window height should have changed"); + + prevWidth = aWindow.outerWidth; + prevHeight = aWindow.outerHeight; + } + + function posChangeCondition() { + // With GTK, sometimes, only one dimension changes. + if (navigator.platform.includes('Linux')) { + 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.includes('Linux')) { + // 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.outerWidth; + prevHeight = aWindow.outerHeight; + + aWindow.resizeTo(getNewWidth(aWindow), 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.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.resizeTo(oWidth * 2, oHeight * 2); + return hitEventLoop(outerChangeCondition, outerChangeTest, hits); + }) + .then(function() { + let origWidth = oWidth; + let origHeight = oHeight; + + oWidth = aWindow.outerWidth; + oHeight = aWindow.outerHeight; + + aWindow.resizeTo(origWidth, 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() { + info(`Change was disabled`); + // 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("file_resize_move_windows_1.html", '', + '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("file_resize_move_windows_2.html", '', ''); + 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 0000000000..3ed3f55ec6 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_sizetocontent_clamp.html @@ -0,0 +1,80 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=764240 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 764240</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script 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.includes("Win") ? 5 : 20; + +// Windows 8 has a minimum 122 pixel inner window width due to +// outer window chrome. +var isWin8 = (navigator.userAgent.includes("Windows NT 6.2")); + +var innerWidthMin = (isWin8 ? 120 : 100); +var innerWidthMax = (isWin8 ? 125 : 100); + +// Window size with CSD decorations is 180 pixels +if (navigator.platform.includes("Linux")) { + innerWidthMax = 180; +} + +var isExecuted = false; + +function test() { + var w = window.open('file_empty.html', null, 'width=300,height=300'); + + SimpleTest.waitForFocus(function() { + w.onresize = function() { + info(`got resize: ${w.innerWidth} ${w.innerHeight}`); + + 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 0000000000..77eaccb1d1 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_toJSON.html @@ -0,0 +1,71 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=760851 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 760851</title> + <script 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) { + // EventCounts isn't going to converted to a JSON string + if ('EventCounts' in window && obj instanceof EventCounts) { + return; + } + 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 0000000000..7c5a1f38a6 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_window_bar.html @@ -0,0 +1,151 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=642338 +--> +<head> + <title>Test for Bug 642338</title> + <script 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 + +*/ + +// Popup is opened if one of the following condtitions is met: +// * both location and toolbar are false +// * menubar is false +// * resizable is false +// * scrollbars is false +// * status is false +var featuresList = [ + { + type: 'non-popup', + target: 'all-bars-toolbar', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes', + }, + { + type: 'non-popup', + target: 'all-bars-location', + features: 'location=yes,menubar=yes,status=yes,scrollbars=yes', + }, + { + type: 'popup', + target: 'no-menubar', + features: 'toolbar=yes,menubar=no,status=yes,scrollbars=yes', + }, + { + type: 'popup', + target: 'no-toolbar', + features: 'toolbar=no,menubar=yes,status=yes,scrollbars=yes', + }, + { + type: 'popup', + target: 'no-status', + features: 'toolbar=yes,menubar=yes,status=no,scrollbars=yes', + }, + { + type: 'popup', + target: 'no-scrollbars', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=no', + }, + { + type: 'popup', + target: 'no-bars', + features: 'toolbar=no,menubar=no,status=no,scrollbars=no', + }, + { + type: 'popup', + target: 'no-resizable', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes' + + ',resizable=no', + }, + { + type: 'non-popup', + target: 'width-sized', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes' + + ',width=500', + }, + { + // if features isnt empty, toolbar and location defaults to false, + // and that results in popup. + type: 'popup', + target: 'only-width-sized', + features: 'width=500', + }, + { + type: 'non-popup', + target: 'height-sized', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes' + + ',height=500', + }, + { + type: 'non-popup', + target: 'sized', + features: 'toolbar=yes,menubar=yes,status=yes,scrollbars=yes' + + ',width=500,height=500', + }, + { + type: 'popup', + target: 'only-sized', + features: 'width=500,height=500', + }, +]; + +var numWindows = 0; + +/* Called when our popup loads. */ +function testWindow(w) +{ + function checkFeature(feature) { + if (w.location.search.startsWith('?popup')) { + is(w[feature].visible, false, `${feature} should be hidden for popup (${w.name}).`); + } else { + is(w[feature].visible, true, `${feature} should be visible for non-popup (${w.name}).`); + } + } + + // If popup is opened, all BarProp.visible become false. + checkFeature('menubar'); + checkFeature('toolbar'); + checkFeature('personalbar'); + checkFeature('scrollbars'); + checkFeature('statusbar'); + checkFeature('locationbar'); + + w.close(); + + numWindows++; + if (numWindows == featuresList.length) { + // We're done! + SimpleTest.finish(); + } + +} + +SimpleTest.waitForExplicitFinish(); +for (var item of featuresList) { + // This will call back into testWindow when they open. + window.open(`file_window_bar.html?${item.type}`, item.target, item.features); +} + +</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 0000000000..dfb0eb45a0 --- /dev/null +++ b/dom/tests/mochitest/bugs/utils_bug260264.js @@ -0,0 +1,69 @@ +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); + try { + sendMouseEvent({ type: event }, element.id); + } finally { + element.removeEventListener(event, unique_handler); + } +} + +/** + * 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 openedBrowsingContextID = SpecialPowers.getBrowsingContextID(win); + promises.push( + (function (openedWindow) { + return new Promise(function (resolve) { + let observer = { + observe(subject) { + if (subject.id == openedBrowsingContextID) { + SpecialPowers.removeObserver( + observer, + "browsing-context-discarded" + ); + SimpleTest.executeSoon(resolve); + } + }, + }; + + SpecialPowers.addObserver(observer, "browsing-context-discarded"); + }); + })(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 0000000000..24b3a77a4c --- /dev/null +++ b/dom/tests/mochitest/bugs/utils_bug743615.js @@ -0,0 +1,30 @@ +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/window_bug1171215.html b/dom/tests/mochitest/bugs/window_bug1171215.html new file mode 100644 index 0000000000..f196457b18 --- /dev/null +++ b/dom/tests/mochitest/bugs/window_bug1171215.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1022869 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1022869</title> + <iframe src="about:blank"></iframe> + <script type="text/javascript"> + + function finish() { + opener.postMessage({type: "finish" }); + } + + function info(msg) { + opener.postMessage({type: "info", msg }); + } + + function ok(a, msg) { + opener.postMessage({type: "test", test: !!a, msg }); + } + + function is(a, b, msg) { + ok(a === b, msg); + } + + var f = document.getElementsByTagName("iframe")[0]; + + /** Test for Bug 1022869 **/ + function startTest() { + // 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(continueTest).catch((e) => { ok(false, `Got exception: ${e}`) }); + } + + function waitForLoad() { + return new Promise((resolve) => { + window.addEventListener("message", function(msg) { + info(`got message ${msg.data}`); + resolve(msg.data); + }, {once: true}); + }); + } + + async 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 = await waitForLoad(); + is(cookie, "a=b", "got the cookie"); + + // Cross origin to cross origin. + f.contentWindow.location = createRedirect(thirdParty, thirdParty); + cookie = await waitForLoad(); + is(cookie, "", "no third-party cookies"); + + // Same origin to cross origin. + f.contentWindow.location = createRedirect(sameOrigin, thirdParty); + cookie = await waitForLoad(); + is(cookie, "", "no third-party cookies"); + + // Cross origin to same origin + f.contentWindow.location = createRedirect(thirdParty, sameOrigin); + cookie = await waitForLoad(); + is(cookie, "a=b", "got the cookie"); + + finish(); + } + </script> +</head> +<body onload="startTest()"> +</body> +</html> diff --git a/dom/tests/mochitest/bugs/worker_bug743615.js b/dom/tests/mochitest/bugs/worker_bug743615.js new file mode 100644 index 0000000000..16c5617bd2 --- /dev/null +++ b/dom/tests/mochitest/bugs/worker_bug743615.js @@ -0,0 +1,44 @@ +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, + imageData, + pattern, + }); +}; |