summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/mochitest
diff options
context:
space:
mode:
Diffstat (limited to 'js/xpconnect/tests/mochitest')
-rw-r--r--js/xpconnect/tests/mochitest/bug500931_helper.html8
-rw-r--r--js/xpconnect/tests/mochitest/bug504877_helper.html10
-rw-r--r--js/xpconnect/tests/mochitest/bug571849_helper.html7
-rw-r--r--js/xpconnect/tests/mochitest/bug589028_helper.html27
-rw-r--r--js/xpconnect/tests/mochitest/bug92773_helper.html7
-rw-r--r--js/xpconnect/tests/mochitest/chrome_wrappers_helper.html30
-rw-r--r--js/xpconnect/tests/mochitest/file1_bug629227.html32
-rw-r--r--js/xpconnect/tests/mochitest/file2_bug629227.html11
-rw-r--r--js/xpconnect/tests/mochitest/file_bug505915.html10
-rw-r--r--js/xpconnect/tests/mochitest/file_bug650273.html31
-rw-r--r--js/xpconnect/tests/mochitest/file_bug658560.html4
-rw-r--r--js/xpconnect/tests/mochitest/file_bug706301.html27
-rw-r--r--js/xpconnect/tests/mochitest/file_bug720619.html10
-rw-r--r--js/xpconnect/tests/mochitest/file_bug738244.html10
-rw-r--r--js/xpconnect/tests/mochitest/file_bug760131.html23
-rw-r--r--js/xpconnect/tests/mochitest/file_bug781476.html15
-rw-r--r--js/xpconnect/tests/mochitest/file_bug789713.html44
-rw-r--r--js/xpconnect/tests/mochitest/file_bug795275.html28
-rw-r--r--js/xpconnect/tests/mochitest/file_bug795275.xml19
-rw-r--r--js/xpconnect/tests/mochitest/file_bug799348.html11
-rw-r--r--js/xpconnect/tests/mochitest/file_bug802557.html62
-rw-r--r--js/xpconnect/tests/mochitest/file_bug860494.html16
-rw-r--r--js/xpconnect/tests/mochitest/file_crossOriginObjects.html35
-rw-r--r--js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html55
-rw-r--r--js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html9
-rw-r--r--js/xpconnect/tests/mochitest/file_documentdomain.html41
-rw-r--r--js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html10
-rw-r--r--js/xpconnect/tests/mochitest/file_empty.html3
-rw-r--r--js/xpconnect/tests/mochitest/file_evalInSandbox.html8
-rw-r--r--js/xpconnect/tests/mochitest/file_exnstack.html23
-rw-r--r--js/xpconnect/tests/mochitest/file_expandosharing.html34
-rw-r--r--js/xpconnect/tests/mochitest/file_matches.html1
-rw-r--r--js/xpconnect/tests/mochitest/file_nodelists.html7
-rw-r--r--js/xpconnect/tests/mochitest/file_wrappers-2.html13
-rw-r--r--js/xpconnect/tests/mochitest/inner.html7
-rw-r--r--js/xpconnect/tests/mochitest/mochitest.ini107
-rw-r--r--js/xpconnect/tests/mochitest/moz.build8
-rw-r--r--js/xpconnect/tests/mochitest/test1_bug629331.html19
-rw-r--r--js/xpconnect/tests/mochitest/test2_bug629331.html18
-rw-r--r--js/xpconnect/tests/mochitest/test_bug1005806.html27
-rw-r--r--js/xpconnect/tests/mochitest/test_bug1094930.html29
-rw-r--r--js/xpconnect/tests/mochitest/test_bug1158558.html47
-rw-r--r--js/xpconnect/tests/mochitest/test_bug384632.html34
-rw-r--r--js/xpconnect/tests/mochitest/test_bug390488.html64
-rw-r--r--js/xpconnect/tests/mochitest/test_bug393269.html46
-rw-r--r--js/xpconnect/tests/mochitest/test_bug396851.html41
-rw-r--r--js/xpconnect/tests/mochitest/test_bug428021.html40
-rw-r--r--js/xpconnect/tests/mochitest/test_bug446584.html47
-rw-r--r--js/xpconnect/tests/mochitest/test_bug462428.html51
-rw-r--r--js/xpconnect/tests/mochitest/test_bug478438.html65
-rw-r--r--js/xpconnect/tests/mochitest/test_bug484107.html99
-rw-r--r--js/xpconnect/tests/mochitest/test_bug500691.html27
-rw-r--r--js/xpconnect/tests/mochitest/test_bug504877.html64
-rw-r--r--js/xpconnect/tests/mochitest/test_bug505915.html50
-rw-r--r--js/xpconnect/tests/mochitest/test_bug560351.html36
-rw-r--r--js/xpconnect/tests/mochitest/test_bug585745.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug589028.html62
-rw-r--r--js/xpconnect/tests/mochitest/test_bug601299.html18
-rw-r--r--js/xpconnect/tests/mochitest/test_bug605167.html56
-rw-r--r--js/xpconnect/tests/mochitest/test_bug618017.html28
-rw-r--r--js/xpconnect/tests/mochitest/test_bug623437.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug628410.html31
-rw-r--r--js/xpconnect/tests/mochitest/test_bug628794.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug629227.html47
-rw-r--r--js/xpconnect/tests/mochitest/test_bug629331.html37
-rw-r--r--js/xpconnect/tests/mochitest/test_bug636097.html62
-rw-r--r--js/xpconnect/tests/mochitest/test_bug650273.html42
-rw-r--r--js/xpconnect/tests/mochitest/test_bug655297-1.html49
-rw-r--r--js/xpconnect/tests/mochitest/test_bug655297-2.html49
-rw-r--r--js/xpconnect/tests/mochitest/test_bug661980.html61
-rw-r--r--js/xpconnect/tests/mochitest/test_bug691059.html59
-rw-r--r--js/xpconnect/tests/mochitest/test_bug720619.html55
-rw-r--r--js/xpconnect/tests/mochitest/test_bug731471.html42
-rw-r--r--js/xpconnect/tests/mochitest/test_bug764389.html40
-rw-r--r--js/xpconnect/tests/mochitest/test_bug772288.html50
-rw-r--r--js/xpconnect/tests/mochitest/test_bug781476.html36
-rw-r--r--js/xpconnect/tests/mochitest/test_bug789713.html39
-rw-r--r--js/xpconnect/tests/mochitest/test_bug790732.html62
-rw-r--r--js/xpconnect/tests/mochitest/test_bug793969.html53
-rw-r--r--js/xpconnect/tests/mochitest/test_bug800864.html51
-rw-r--r--js/xpconnect/tests/mochitest/test_bug802557.html116
-rw-r--r--js/xpconnect/tests/mochitest/test_bug803730.html41
-rw-r--r--js/xpconnect/tests/mochitest/test_bug809547.html42
-rw-r--r--js/xpconnect/tests/mochitest/test_bug829872.html52
-rw-r--r--js/xpconnect/tests/mochitest/test_bug862380.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug865260.html33
-rw-r--r--js/xpconnect/tests/mochitest/test_bug870423.html51
-rw-r--r--js/xpconnect/tests/mochitest/test_bug871887.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug912322.html36
-rw-r--r--js/xpconnect/tests/mochitest/test_bug916945.html62
-rw-r--r--js/xpconnect/tests/mochitest/test_bug92773.html43
-rw-r--r--js/xpconnect/tests/mochitest/test_bug940783.html62
-rw-r--r--js/xpconnect/tests/mochitest/test_bug960820.html56
-rw-r--r--js/xpconnect/tests/mochitest/test_bug965082.html39
-rw-r--r--js/xpconnect/tests/mochitest/test_bug986542.html45
-rw-r--r--js/xpconnect/tests/mochitest/test_bug993423.html47
-rw-r--r--js/xpconnect/tests/mochitest/test_crossOriginObjects.html336
-rw-r--r--js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html44
-rw-r--r--js/xpconnect/tests/mochitest/test_frameWrapping.html37
-rw-r--r--js/xpconnect/tests/mochitest/test_getWebIDLCaller.html49
-rw-r--r--js/xpconnect/tests/mochitest/test_nac.xhtml64
-rw-r--r--js/xpconnect/tests/mochitest/test_sameOriginPolicy.html109
-rw-r--r--js/xpconnect/tests/mochitest/test_sandbox_fetch.html54
103 files changed, 4269 insertions, 0 deletions
diff --git a/js/xpconnect/tests/mochitest/bug500931_helper.html b/js/xpconnect/tests/mochitest/bug500931_helper.html
new file mode 100644
index 000000000..da268d99d
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/bug500931_helper.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>Inner frame for bug 500931 mochitest</title>
+ <script>x = 42;</script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/bug504877_helper.html b/js/xpconnect/tests/mochitest/bug504877_helper.html
new file mode 100644
index 000000000..dd4b4d166
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/bug504877_helper.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <script>
+ function getblat() {
+ return blat;
+ }
+ foopy = 42;
+ </script>
+ </head>
+</html>
diff --git a/js/xpconnect/tests/mochitest/bug571849_helper.html b/js/xpconnect/tests/mochitest/bug571849_helper.html
new file mode 100644
index 000000000..234cd57cc
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/bug571849_helper.html
@@ -0,0 +1,7 @@
+<html>
+ <head>
+ </head>
+ <body>
+ TEXT NODE TEXT NODE
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/bug589028_helper.html b/js/xpconnect/tests/mochitest/bug589028_helper.html
new file mode 100644
index 000000000..dc56ecbc3
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/bug589028_helper.html
@@ -0,0 +1,27 @@
+<html>
+ <head>
+ <script>
+ function getMyOption() {
+ return new Option();
+ }
+ function getCallersOption(caller) {
+ return new caller.Option();
+ }
+ function getMyAudio() {
+ return new Audio();
+ }
+ function getCallersAudio(caller) {
+ return new caller.Audio();
+ }
+ function getMyImage() {
+ return new Image();
+ }
+ function getCallersImage(caller) {
+ return new caller.Image();
+ }
+ </script>
+ </head>
+ <body>
+ the iframe
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/bug92773_helper.html b/js/xpconnect/tests/mochitest/bug92773_helper.html
new file mode 100644
index 000000000..ac82c5d58
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/bug92773_helper.html
@@ -0,0 +1,7 @@
+<html>
+ <head>
+ <script>
+ foo getter = function() { alert("FAIL"); }
+ </script>
+ </head>
+</html>
diff --git a/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html b/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html
new file mode 100644
index 000000000..26973b713
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <script>
+ function check_wrapper(ok, wrapper, expected, note) {
+
+ var utils = SpecialPowers.DOMWindowUtils;
+ ok(utils.getClassName(wrapper) === expected, note);
+ }
+ function run_test(ok, xpcnw, sjow) {
+ // both wrappers should point to our window: XOW
+ check_wrapper(ok, ok, "Proxy", "functions are wrapped properly")
+ check_wrapper(ok, xpcnw, "Proxy", "XPCNWs are transformed correctly");
+ check_wrapper(ok, sjow, "Proxy", "SJOWs are transformed correctly");
+
+ check_wrapper(ok, window.location, "Proxy",
+ "Content needs a same-compartment security wrappers around location");
+
+ ok(defprop1 === 1, "defprop1 exists");
+ window.defprop1 = 2;
+ ok(defprop1 === 2, "defprop1 is properly writable");
+
+ // defprop2 = {}; disabled because the test doesn't work
+ }
+
+ window.xhr = new XMLHttpRequest();
+ </script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file1_bug629227.html b/js/xpconnect/tests/mochitest/file1_bug629227.html
new file mode 100644
index 000000000..dd1248406
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file1_bug629227.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>
+ function doIt() {
+ var doc = window.frames[0].document;
+ var ok = (doc.form1 == doc.getElementById("test1"));
+ window.parent.postMessage(
+ JSON.stringify({ ok: ok,
+ reason: "Should be able to get named items by name" }),
+ "*");
+ window.parent.postMessage("finish", "*");
+ }
+
+ window.onmessage = function(ev) {
+ if (ev.data == "start") {
+ doIt();
+ }
+ }
+
+ document.domain = "example.org";
+ </script>
+ </head>
+ <body>
+ <iframe id="subframe"></iframe>
+ <script>
+ document.getElementById("subframe").src =
+ "http://test2.example.org" +
+ location.pathname.replace(/file1_bug629227.html/, "file2_bug629227.html");
+ </script>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file2_bug629227.html b/js/xpconnect/tests/mochitest/file2_bug629227.html
new file mode 100644
index 000000000..02a054086
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file2_bug629227.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>
+ document.domain = "example.org";
+ </script>
+ </head>
+ <body>
+ <form name="form1" id="test1"></form>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug505915.html b/js/xpconnect/tests/mochitest/file_bug505915.html
new file mode 100644
index 000000000..512912691
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug505915.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Inner frame for testing bug 505915.
+https://bugzilla.mozilla.org/show_bug.cgi?id=505915
+-->
+<head>
+<body onload="parent.postMessage('', '*');">
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug650273.html b/js/xpconnect/tests/mochitest/file_bug650273.html
new file mode 100644
index 000000000..5fe33e969
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug650273.html
@@ -0,0 +1,31 @@
+<!-- test by moz_bug_r_a4@yahoo.com -->
+<body onload="a()">
+<script>
+var targetUrl = "http://example.com/";
+var l;
+
+function a() {
+ var o = {};
+ o.toString = function() {
+ l();
+ return "a";
+ };
+ var f = Object.getOwnPropertyDescriptor(Document.prototype, "title").set;
+ setTimeout(f.bind(document), 0, o);
+}
+
+function l() {
+ var l = false;
+ onunload = function() {
+ l = true;
+ };
+ location = targetUrl;
+ do {
+ var r = new XMLHttpRequest();
+ r.open("GET", location.href, false);
+ r.overrideMimeType("text/plain");
+ try { r.send(null); }
+ catch (e) {}
+ } while (!l);
+}
+</script>
diff --git a/js/xpconnect/tests/mochitest/file_bug658560.html b/js/xpconnect/tests/mochitest/file_bug658560.html
new file mode 100644
index 000000000..411d31ac7
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug658560.html
@@ -0,0 +1,4 @@
+<html>
+ <body>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug706301.html b/js/xpconnect/tests/mochitest/file_bug706301.html
new file mode 100644
index 000000000..805449b4a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug706301.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script type="application/javascript">
+ window.addEventListener('message', doContentTest);
+
+ function doContentTest() {
+
+ // This has always worked.
+ var nodelist1 = document.getElementsByTagName('details');
+ Object.getOwnPropertyDescriptor(nodelist1, 'length');
+ ok(nodelist1['length'] == 0, "Content should be able to get the length of " +
+ "its own nodelist after calling getOwnPropertyDescriptor.");
+
+ // This is bug 706301.
+ var nodelist2 = document.getElementsByTagName('section');
+ ok(getLengthInChrome(nodelist2), "Chrome should be able to get the length of " +
+ "content nodelist after calling getOwnPropertyDescriptor.");
+
+ // All done.
+ finishTestInChrome();
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug720619.html b/js/xpconnect/tests/mochitest/file_bug720619.html
new file mode 100644
index 000000000..d198ba1fa
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug720619.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script>
+ valueOf = function() { return "v"; }
+ toString = function() { return "s"; }
+ </script>
+ </head>
+ <body></body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug738244.html b/js/xpconnect/tests/mochitest/file_bug738244.html
new file mode 100644
index 000000000..a399d9f0e
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug738244.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+<form name="form1">
+ <input name="input1" />
+ <input name="appendChild" />
+</form>
+<iframe name="frame1">
+</iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug760131.html b/js/xpconnect/tests/mochitest/file_bug760131.html
new file mode 100644
index 000000000..736732a0a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug760131.html
@@ -0,0 +1,23 @@
+<html>
+<div id="target" ontouchstart="alert();"></div>
+<script type="application/javascript">
+
+/** Test for Bug 760131 **/
+
+function accessTouches(evt)
+{
+ var thrown = false;
+ try {
+ var a = evt.touches;
+ } catch (e) {
+ thrown = true;
+ }
+ ok(!thrown, "Unwrapping a TouchList shouldn't throw");
+}
+
+document.getElementById("target").ontouchstart = accessTouches;
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug781476.html b/js/xpconnect/tests/mochitest/file_bug781476.html
new file mode 100644
index 000000000..745f8818e
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug781476.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="application/javascript">
+function makeEvent() {
+ var evt = new Event("MouseEvents");
+ evt.expando = 42;
+ is(evt.expando, 42, "Expando properly visible in iframe");
+ return evt;
+}
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug789713.html b/js/xpconnect/tests/mochitest/file_bug789713.html
new file mode 100644
index 000000000..ea21dae6c
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug789713.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=789713
+-->
+<head>
+ <meta charset="utf-8">
+</head>
+<body>
+
+<script type="application/javascript">
+
+/** Test for Bug 789713 **/
+
+function go() {
+ var ifr = document.getElementById('ifr');
+ var pass = true;
+ var doc = ifr.contentDocument;
+
+ // Tree walkers use nsDOMGenericSH, which has a spineless PreCreate.
+ var walker = doc.createTreeWalker(doc.body);
+ pass = pass && (walker.root === doc.body);
+
+ // Grab a reference to Object.prototype to make sure we test the machinery
+ // with respect to standard prototype remapping.
+ var objProto = ifr.contentWindow.Object.prototype;
+
+ // First, do the document.domain operation. This shouldn't crash.
+ document.domain = "example.org";
+
+ // Now, make sure that we still can't access cross-origin properties despite
+ // the fact that the WN is shared under the hood.
+ try {
+ walker.root;
+ pass = false;
+ } catch (e) { pass = pass && /Permission denied/.exec(e.message); }
+ window.parent.postMessage(pass, '*');
+}
+
+</script>
+<iframe id="ifr" src="file_empty.html" onload="go()"></iframe>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug795275.html b/js/xpconnect/tests/mochitest/file_bug795275.html
new file mode 100644
index 000000000..95e9f2a8e
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug795275.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+<style>
+ .bound {
+ -moz-binding: url(file_bug795275.xml#xbltest);
+ }
+</style>
+<script type="application/javascript">
+ function touchComponents() {
+ Components;
+ }
+ function touchInterfaces() {
+ Components.interfaces;
+ }
+
+ function touchViaXBL() {
+ // Make sure none of this warns.
+ var div = document.getElementById('dummy');
+ div.testProp;
+ div.testMethod();
+ }
+
+</script>
+</head>
+<body>
+<div id="dummy" class="bound"></div>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug795275.xml b/js/xpconnect/tests/mochitest/file_bug795275.xml
new file mode 100644
index 000000000..f9e5e60f5
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug795275.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<bindings id="xbltestBindings" xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+<binding id="xbltest">
+<implementation>
+<method name="testMethod" exposeToUntrustedContent="true">
+<body>
+ Components.interfaces;
+</body>
+</method>
+<property name="testProp" readonly="true"
+ onget="Components; return 3;"
+ exposeToUntrustedContent="true" />
+<constructor>
+ var foo = Components;
+</constructor>
+</implementation>
+</binding>
+</bindings>
diff --git a/js/xpconnect/tests/mochitest/file_bug799348.html b/js/xpconnect/tests/mochitest/file_bug799348.html
new file mode 100644
index 000000000..5800868db
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug799348.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script>
+ var foo = window.open('file_empty.html', '', 'width=550, height=420, status=no, resizable=yes, scrollbars=yes, toolbar=no, left=945, top=225');
+</script>
+</head>
+<body>
+</body>
+</html>
+
diff --git a/js/xpconnect/tests/mochitest/file_bug802557.html b/js/xpconnect/tests/mochitest/file_bug802557.html
new file mode 100644
index 000000000..39f952bc5
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug802557.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+var gTS = window.location.toString;
+var gGHR = Object.getOwnPropertyDescriptor(window.location, 'href').get;
+function getTests(fromOuter) {
+
+ function loc() {
+ return fromOuter ? window.location : location;
+ }
+ return {
+ getLocationImplicit: function() {
+ return loc() + "";
+ },
+ getLocationExplicit: function() {
+ return loc().toString();
+ },
+ getLocationApply1: function() {
+ return gTS.call(loc());
+ },
+ getLocationApply2: function() {
+ return gTS.apply(loc(), []);
+ },
+ getLocationApply3: function() {
+ return Function.call.apply(gTS, [loc()]);
+ },
+ getHref: function() {
+ return loc().href;
+ },
+ getHrefViaApply: function() {
+ return Function.call.apply(gGHR, [loc()]);
+ },
+ }
+};
+
+function mungeNames(obj, suffix) {
+ var rv = {};
+ Object.getOwnPropertyNames(obj)
+ .forEach(name => rv[name + suffix] = obj[name]);
+ return rv;
+}
+
+function mergeObjects(a, b) {
+ var rv = {};
+ Object.getOwnPropertyNames(a).forEach(name => rv[name] = a[name]);
+ Object.getOwnPropertyNames(b).forEach(name => rv[name] = b[name]);
+ return rv;
+}
+
+function getAllTests() {
+ var innerTests = getTests(false);
+ var outerTests = getTests(true);
+ return mergeObjects(mungeNames(innerTests, '_inner'),
+ mungeNames(outerTests, '_outer'));
+}
+
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_bug860494.html b/js/xpconnect/tests/mochitest/file_bug860494.html
new file mode 100644
index 000000000..63a700379
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_bug860494.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title></title>
+</head>
+<body>
+<iframe name="top"></iframe>
+<iframe name="parent"></iframe>
+<iframe name="location"></iframe>
+<iframe name="length"></iframe>
+<iframe name="window"></iframe>
+<iframe name="navigator"></iframe>
+<iframe name="alert"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_crossOriginObjects.html b/js/xpconnect/tests/mochitest/file_crossOriginObjects.html
new file mode 100644
index 000000000..c3093ebda
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_crossOriginObjects.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+<script>
+ // Override the |frames| property to test that such overrides are
+ // properly ignored cross-origin.
+ window.frames = "override";
+
+ // If we get a postMessage, we grab references to everything and set
+ // document.domain to trim off our topmost subdomain.
+ window.onmessage = function(evt) {
+ window.windowReferences = [];
+ window.locationReferences = [];
+ for (var i = 0; i < parent.length; ++i) {
+ windowReferences.push(parent[i]);
+ locationReferences.push(parent[i].location);
+ }
+ document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
+ evt.source.postMessage('', '*');
+ }
+
+ function checkWindowReferences() {
+ for (var i = 0; i < parent.length; ++i) {
+ if (windowReferences[i] != parent[i])
+ throw new Error("Window references don't match for " + i + " after document.domain");
+ if (locationReferences[i] != parent[i].location)
+ throw new Error("Location references don't match for " + i + " after document.domain");
+ }
+ return true;
+ }
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html b/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html
new file mode 100644
index 000000000..1c0f05bd2
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_crossOriginObjects_documentDomain.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ function loadFrames() {
+ window.A = document.getElementById('A').contentWindow;
+ window.B = document.getElementById('B').contentWindow;
+ window.C = document.getElementById('C').contentWindow;
+ window.D = document.getElementById('D').contentWindow;
+
+ var path = location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/file_crossOriginObjects.html';
+ A.location = 'file_crossOriginObjects.html';
+ B.location = frameURI = 'http://test2.mochi.test:' + location.port + path;
+ C.location = frameURI = 'http://test1.mochi.test:' + location.port + path;
+ D.location = frameURI = 'http://test1.mochi.test:' + location.port + path;
+
+ var loadCount = 0;
+ function frameLoaded() {
+ if (++loadCount == 4)
+ go();
+ }
+ Array.forEach(document.getElementsByTagName('iframe'), function(ifr) { ifr.onload = frameLoaded; });
+ }
+
+
+ var results = [];
+ function assert(cond, msg) {
+ results.push({pass: !!cond, message: msg});
+ }
+
+ function go() {
+ window.onmessage = function() {
+ assert(B.checkWindowReferences(), "B's Window references are still self-consistent after document.domain");
+ for (var i = 0; i < window.length; ++i) {
+ assert(window[i] === B.windowReferences[i],
+ "Window reference " + i + " consistent between globals after document.domain");
+ assert(window[i].location === B.locationReferences[i],
+ "Location reference " + i + " consistent between globals after document.domain");
+ }
+ opener.postMessage(results, '*');
+ };
+ A.document.domain = A.document.domain;
+ document.domain = document.domain;
+ B.postMessage('', '*');
+ }
+
+ </script>
+</head>
+<body onload="loadFrames()">
+ <iframe id="A"></iframe>
+ <iframe id="B"></iframe>
+ <iframe id="C"></iframe>
+ <iframe id="D"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html b/js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html
new file mode 100644
index 000000000..b25cdb2f9
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_crosscompartment_weakmap.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <link rel="stylesheet" href="data:text/css,div {}">
+ <title>Test Cross-Compartment DOM WeakMaps</title>
+</head>
+<body>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_documentdomain.html b/js/xpconnect/tests/mochitest/file_documentdomain.html
new file mode 100644
index 000000000..784ed269d
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_documentdomain.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="application/javascript">
+
+ function setDomain(domain) {
+ document.domain = domain;
+ }
+
+ function tryToAccess(otherWin) {
+ try {
+ var text = otherWin.document.getElementById('foo').innerHTML;
+ return /Better Late/.exec(text);
+ } catch (e) { return false; }
+ }
+
+ var gRef = null;
+ function storeReference(otherWin) {
+ gRef = otherWin.document.getElementById('foo');
+ }
+
+ function tryToAccessStored() {
+ try {
+ return /Better Late/.exec(gRef.innerHTML);
+ } catch (e) { return false; }
+ }
+
+ function invokingFunctionThrowsSecurityException(name) {
+ try {
+ window[name]();
+ return false;
+ } catch (e) { return /insecure|denied/.test(e); }
+ }
+
+
+</script>
+</head>
+<body>
+<span id="foo">Better Late than Never</span>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html b/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html
new file mode 100644
index 000000000..f789a33d7
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <script>
+ // We want to put an expando on the object, but we want this object
+ // to be wrapped in other compartments. This means that the expando
+ // must implement precreate, which happens (in general) for nodes.
+ // So we just do a cyclic reference to the document body.
+ window.expando = document.documentElement;
+ </script>
+ </head>
diff --git a/js/xpconnect/tests/mochitest/file_empty.html b/js/xpconnect/tests/mochitest/file_empty.html
new file mode 100644
index 000000000..ebe8e56a6
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_empty.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<!-- Note: other tests throughout the tree depend on the layout of this, including the title. Don't make big changes without a try run. -->
+<html><head><title>empty test page</title></head><body><span id="text">Nothing to see here</span><iframe name="subframe"></iframe></body></html>
diff --git a/js/xpconnect/tests/mochitest/file_evalInSandbox.html b/js/xpconnect/tests/mochitest/file_evalInSandbox.html
new file mode 100644
index 000000000..f53aa1166
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_evalInSandbox.html
@@ -0,0 +1,8 @@
+<html>
+ <body>
+ <script>
+ document.foo = "bar";
+ windowfoo = "windowbar";
+ </script>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_exnstack.html b/js/xpconnect/tests/mochitest/file_exnstack.html
new file mode 100644
index 000000000..448e3c0a7
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_exnstack.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script type="application/javascript">
+ window.doThrow = function(other) {
+ if (other)
+ throwAsOuter(other);
+ else
+ throwAsInner();
+ }
+
+ function throwAsInner() {
+ throw Error('look at me go!');
+ }
+
+ function throwAsOuter(other) {
+ other.doThrow(null);
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_expandosharing.html b/js/xpconnect/tests/mochitest/file_expandosharing.html
new file mode 100644
index 000000000..ceb4131bb
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_expandosharing.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="application/javascript">
+ function setup() {
+ // Set up different target objects for expandos, one for each binding type.
+ window.targetWN = window;
+ window.targetDOM = new XMLHttpRequest();
+ window.targetJS = new Date();
+ }
+
+ function placeExpando(name, val, target) {
+ target[name] = val;
+ }
+
+ // If val === null, then we shouldn't have access.
+ function checkExpando(name, val, target, msg) {
+ if (val !== null) {
+ ok(name in target, msg);
+ try {
+ is(target[name], val, "Got the right expando value");
+ } catch(e) { ok(false, "Threw when accessing same-origin expando"); }
+ }
+ else {
+ ok(!(name in target), msg);
+ }
+ }
+
+</script>
+</head>
+<body onload="setup();">
+ <span>Salut, Ma Cherise. ;-)</span>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_matches.html b/js/xpconnect/tests/mochitest/file_matches.html
new file mode 100644
index 000000000..0dc101b53
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_matches.html
@@ -0,0 +1 @@
+<html><body></body></html>
diff --git a/js/xpconnect/tests/mochitest/file_nodelists.html b/js/xpconnect/tests/mochitest/file_nodelists.html
new file mode 100644
index 000000000..2195c62cc
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_nodelists.html
@@ -0,0 +1,7 @@
+<html>
+ <body>
+ <p>
+ <p>
+ <p>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/file_wrappers-2.html b/js/xpconnect/tests/mochitest/file_wrappers-2.html
new file mode 100644
index 000000000..e27b07ed6
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/file_wrappers-2.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <script>
+ var obj = {a: 3, next: 1};
+ var to_iterate = Object.create(obj);
+ var enumerate = { 0: 0, "hi": "there" };
+ function func () {};
+ var o = {};
+ var a = [1];
+ </script>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/inner.html b/js/xpconnect/tests/mochitest/inner.html
new file mode 100644
index 000000000..8021a5553
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/inner.html
@@ -0,0 +1,7 @@
+<html>
+ <head>
+ <title>Inner frame for bug 39685 mochitest</title>
+ </head>
+ <body onload="x = 4">
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/mochitest.ini b/js/xpconnect/tests/mochitest/mochitest.ini
new file mode 100644
index 000000000..de6759e7a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/mochitest.ini
@@ -0,0 +1,107 @@
+[DEFAULT]
+support-files =
+ bug500931_helper.html
+ bug504877_helper.html
+ bug571849_helper.html
+ bug589028_helper.html
+ bug92773_helper.html
+ chrome_wrappers_helper.html
+ file1_bug629227.html
+ file2_bug629227.html
+ file_bug505915.html
+ file_bug650273.html
+ file_bug658560.html
+ file_bug706301.html
+ file_bug720619.html
+ file_bug738244.html
+ file_bug760131.html
+ file_bug781476.html
+ file_bug789713.html
+ file_bug795275.html
+ file_bug795275.xml
+ file_bug799348.html
+ file_bug802557.html
+ file_bug860494.html
+ file_crossOriginObjects.html
+ file_crossOriginObjects_documentDomain.html
+ file_crosscompartment_weakmap.html
+ file_documentdomain.html
+ file_doublewrappedcompartments.html
+ file_empty.html
+ file_evalInSandbox.html
+ file_exnstack.html
+ file_expandosharing.html
+ file_matches.html
+ file_nodelists.html
+ file_wrappers-2.html
+ inner.html
+ test1_bug629331.html
+ test2_bug629331.html
+
+[test_bug384632.html]
+[test_bug390488.html]
+[test_bug393269.html]
+[test_bug396851.html]
+[test_bug428021.html]
+[test_bug446584.html]
+[test_bug462428.html]
+[test_bug478438.html]
+[test_bug500691.html]
+[test_bug504877.html]
+[test_bug505915.html]
+[test_bug560351.html]
+[test_bug585745.html]
+[test_bug589028.html]
+[test_bug601299.html]
+[test_bug605167.html]
+[test_bug618017.html]
+[test_bug623437.html]
+[test_bug628410.html]
+[test_bug628794.html]
+[test_bug629227.html]
+[test_bug629331.html]
+[test_bug636097.html]
+[test_bug650273.html]
+[test_bug655297-1.html]
+[test_bug655297-2.html]
+[test_bug661980.html]
+[test_bug691059.html]
+[test_bug720619.html]
+[test_bug731471.html]
+[test_bug764389.html]
+[test_bug772288.html]
+[test_bug781476.html]
+[test_bug789713.html]
+[test_bug790732.html]
+[test_bug793969.html]
+[test_bug800864.html]
+[test_bug802557.html]
+[test_bug803730.html]
+[test_bug809547.html]
+[test_bug829872.html]
+[test_bug862380.html]
+[test_bug865260.html]
+[test_bug870423.html]
+[test_bug871887.html]
+[test_bug912322.html]
+[test_bug916945.html]
+[test_bug92773.html]
+[test_bug940783.html]
+[test_bug965082.html]
+[test_bug960820.html]
+[test_bug986542.html]
+[test_bug993423.html]
+[test_bug1005806.html]
+[test_bug1094930.html]
+[test_bug1158558.html]
+[test_crossOriginObjects.html]
+[test_crosscompartment_weakmap.html]
+[test_frameWrapping.html]
+# The JS test component we use below is only available in debug builds.
+[test_getWebIDLCaller.html]
+skip-if = (debug == false || os == "android")
+[test_nac.xhtml]
+[test_sameOriginPolicy.html]
+[test_sandbox_fetch.html]
+ support-files =
+ ../../../../dom/tests/mochitest/fetch/test_fetch_basic.js
diff --git a/js/xpconnect/tests/mochitest/moz.build b/js/xpconnect/tests/mochitest/moz.build
new file mode 100644
index 000000000..8e5cb5d71
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/moz.build
@@ -0,0 +1,8 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+MOCHITEST_MANIFESTS += ['mochitest.ini']
+
diff --git a/js/xpconnect/tests/mochitest/test1_bug629331.html b/js/xpconnect/tests/mochitest/test1_bug629331.html
new file mode 100644
index 000000000..18843e08d
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test1_bug629331.html
@@ -0,0 +1,19 @@
+<body>
+<iframe src="about:blank" id="ifr"></iframe>
+<script>
+/** Test for Bug 629331 **/
+function finish() {
+ parent.postMessage(JSON.stringify({fun: "finish"}), "*");
+}
+
+function is(a, b, description) {
+ parent.postMessage(JSON.stringify({ fun: "is", a: a, b: b, description: description }), "*");
+}
+
+document.domain = "example.org";
+var i = 0;
+is(i, 0, 'i meets starting conditions');
+document.getElementById('ifr').src = 'http://test2.example.org/tests/js/xpconnect/tests/mochitest/test2_bug629331.html';
+</script>
+
+
diff --git a/js/xpconnect/tests/mochitest/test2_bug629331.html b/js/xpconnect/tests/mochitest/test2_bug629331.html
new file mode 100644
index 000000000..1bcf03739
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test2_bug629331.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ </head>
+ <body>
+ <script>
+ document.domain = "example.org";
+
+ for (var j = 1; j <= 9; j++) {
+ parent.i = j;
+ var locali = parent.i;
+ parent.is(locali, j, 'step ' + j + ' worked');
+ }
+
+ parent.finish();
+ </script>
+ </body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug1005806.html b/js/xpconnect/tests/mochitest/test_bug1005806.html
new file mode 100644
index 000000000..4f041c4be
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug1005806.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1005806
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1005806</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1005806">Mozilla Bug 1005806</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <input id="ipt"></input>
+</div>
+<pre id="test">
+</pre>
+<script type="application/javascript">
+
+/** Test for Bug 1005806 **/
+is(typeof document.getElementById('ipt').controllers, 'undefined', "Controllers property should not appear for content");
+
+</script>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug1094930.html b/js/xpconnect/tests/mochitest/test_bug1094930.html
new file mode 100644
index 000000000..434949360
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug1094930.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1094930
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1094930</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <iframe id="ifr"></iframe>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1094930">Mozilla Bug 1094930</a>
+<p id="display"></p>
+<script type="application/javascript">
+ SimpleTest.waitForExplicitFinish();
+ var proto = {
+ createdCallback: function() {
+ ok(true, "createdCallback was called");
+ SimpleTest.finish()
+ }
+ };
+
+ var f = document.registerElement.call(frames[0].document, "x-foo", { prototype: proto });
+ var inst = new f();
+</script>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug1158558.html b/js/xpconnect/tests/mochitest/test_bug1158558.html
new file mode 100644
index 000000000..3d142e44a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug1158558.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1158558
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1158558</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1158558">Mozilla Bug 1158558</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ <input id="ipt"></input>
+</div>
+<pre id="test">
+</pre>
+<script type="application/javascript">
+
+/** Test for Bug 1158558 **/
+
+// Observers of cycle-collector-begin can be implemented in JS, and
+// thus can end up starting an incremental GC while we're in the middle
+// of a CC slice.
+
+SimpleTest.waitForExplicitFinish();
+
+var observer = {
+ observe: function(subject, topic, data) {
+ SpecialPowers.removeObserver(observer, "cycle-collector-begin");
+ SpecialPowers.Cu.getJSTestingFunctions().startgc(1);
+
+ ok(true, "Do something so the test harness doesn't get angry");
+
+ SimpleTest.finish();
+ }
+};
+
+SpecialPowers.addObserver(observer, "cycle-collector-begin", false);
+
+SpecialPowers.Cu.forceCC();
+
+</script>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug384632.html b/js/xpconnect/tests/mochitest/test_bug384632.html
new file mode 100644
index 000000000..a5e02e448
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug384632.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=384632
+-->
+<head>
+ <title>Test for Bug 384632</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=384632">Mozilla Bug 384632</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 384632 **/
+var Cc = SpecialPowers.Cc, Ci = SpecialPowers.Ci;
+var propBag = Cc["@mozilla.org/hash-property-bag;1"].createInstance(Ci.nsIWritablePropertyBag);
+var obj = {};
+propBag.setProperty("foopy", obj);
+ok(SpecialPowers.unwrap(propBag.getProperty("foopy")) === obj,
+ "nsIVariant works with regular objects");
+propBag.setProperty("foopy1", sidebar);
+ok(SpecialPowers.unwrap(propBag.getProperty("foopy1")) === sidebar,
+ "nsIVariant works with bizarre objects");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug390488.html b/js/xpconnect/tests/mochitest/test_bug390488.html
new file mode 100644
index 000000000..18b4c141c
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug390488.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=390488
+-->
+<head>
+ <title>Test for Bug 390488</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=390488">Mozilla Bug 390488</a>
+<p id="display">
+ <div id="testdiv" onclick="checkForStacks();" style="visibility:hidden">
+ </div>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 390488 **/
+ function getStack1() {
+ var func = arguments.callee.caller;
+ var stack = "";
+ for (var i = 1; func && i < 8; i++) {
+ stack += " " + i + ". " + func.name;
+ func = func.caller;
+ }
+ return stack;
+ }
+
+ function getStack2() {
+ var stack = new Error().stack;
+ // Remove the two lines due to calling this
+ return stack.substring(stack.indexOf("\n", stack.indexOf("\n")+1)+1);
+ }
+
+ function simulateClick() {
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent("click", true, true, window,
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ $("testdiv").dispatchEvent(evt);
+ }
+
+ function matches(s, p, name) {
+ ok(s.match(p) != null, name,
+ "got " + uneval(s) + ", expected a string matching " + uneval(p));
+ }
+
+ function checkForStacks() {
+ matches(getStack1(), /checkForStacks .* onclick .* simulateClick/,
+ "Stack from walking caller chain should be correct");
+ isnot(getStack2().indexOf("simulateClick@"), -1,
+ "Stack from |new Error().stack| should include simulateClick");
+ }
+
+ simulateClick();
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/js/xpconnect/tests/mochitest/test_bug393269.html b/js/xpconnect/tests/mochitest/test_bug393269.html
new file mode 100644
index 000000000..048698854
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug393269.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=393269
+-->
+<head>
+ <title>Test for Bug 393269</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=393269">Mozilla Bug 393269</a>
+<iframe id="ifr"></iframe>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+(function () {
+ /** Test for Bug 393269 **/
+ var doc = $("ifr").contentDocument;
+ is("UTF-8", doc.characterSet, "control, getting a property");
+ doc.open();
+ try {
+ is("UTF-8", doc.characterSet,
+ "can get a property after 1 document.open")
+ } catch (e) {
+ fail("Shouldn't have thrown: " + e);
+ return;
+ } finally {
+ doc.close();
+ }
+
+ doc.open();
+ try {
+ is("UTF-8", doc.characterSet,
+ "can get a property after 2 document.opens")
+ } catch (e) {
+ fail("Shouldn't have thrown: " + e);
+ } finally {
+ doc.close();
+ }
+})();
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/js/xpconnect/tests/mochitest/test_bug396851.html b/js/xpconnect/tests/mochitest/test_bug396851.html
new file mode 100644
index 000000000..aa7a98c08
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug396851.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=396851
+-->
+<head>
+ <title>Test for Bug 396851</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+ <script type="text/javascript">
+ function go() {
+ var iframe = $("ifr");
+ var win = iframe.contentWindow;
+ try {
+ var doc = win.document;
+ fail("Allowed cross-origin access to the document");
+ } catch (e) {
+ ok(e.toString().match("Permission denied") != null, "Weird exception thrown");
+ }
+
+ doc = SpecialPowers.wrap(win).document;
+ ok(doc != null, "Able to access the cross-origin document");
+ SimpleTest.finish();
+ }
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396851">Mozilla Bug 396851</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<script type="text/javascript">
+ SimpleTest.waitForExplicitFinish();
+</script>
+<iframe id="ifr"
+ src="http://example.org/tests/js/xpconnect/tests/mochitest/inner.html"
+ onload="go()">
+</iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug428021.html b/js/xpconnect/tests/mochitest/test_bug428021.html
new file mode 100644
index 000000000..75c9edfce
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug428021.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=428021
+-->
+<head>
+ <title>Test for Bug 428021</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=428021">Mozilla Bug 428021</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+ /** Test for Bug 428021 **/
+ var rangetter, ransetter;
+ this.__defineGetter__('x', function() { rangetter = true; });
+ this.__defineSetter__('x', function(val) { ransetter = true; });
+
+ var exn;
+ try {
+ e = x;
+ x = false;
+ } catch (e) {
+ exn = e;
+ }
+ ok(!exn, "Exception caught: " + exn);
+ ok(rangetter, "Failed to run getter");
+ ok(ransetter, "Failed to run setter");
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/js/xpconnect/tests/mochitest/test_bug446584.html b/js/xpconnect/tests/mochitest/test_bug446584.html
new file mode 100644
index 000000000..4ad1c1d3c
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug446584.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=446584
+-->
+<head>
+ <title>Test for Bug 446584</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=446584">Mozilla Bug 446584</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 446584 **/
+
+function test(val) {
+ try {
+ document.createNodeIterator(document.body,
+ NodeFilter.SHOW_ALL,
+ function() { throw val }).nextNode();
+ ok(false, "NodeIterator::nextNode() should have thrown an exception.");
+ } catch (ex) {
+ ok(val === ex, "NodeIterator did not properly forward exception " +
+ val + " of type " + typeof val + ". Thrown value was " + ex + ".");
+ }
+}
+
+test(0);
+test(1);
+test(3.14);
+test('roses');
+test({});
+test(false);
+test(true);
+test([1,2,3]);
+test(function(){});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug462428.html b/js/xpconnect/tests/mochitest/test_bug462428.html
new file mode 100644
index 000000000..8655bc359
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug462428.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=462428
+-->
+<head>
+ <title>Test for Bug 462428</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462428">Mozilla Bug 462428</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 462428 **/
+var getter = document.__lookupGetter__('documentElement');
+ok(getter !== undefined, "But able to look it up the normal way");
+ok(!document.hasOwnProperty('documentElement'), "property should still be on the prototype");
+
+var sawProp = false;
+for (var i in document) {
+ if (i === "documentElement") {
+ sawProp = true;
+ }
+}
+
+ok(sawProp, "property should be enumerable");
+
+is(getter.call(document), document.documentElement, "the getter actually works");
+
+Document.prototype.__defineSetter__('documentElement', function() {});
+is(getter.call(document), document.documentElement, "the getter works after defineSetter");
+
+var oldTitle = document.title;
+try {
+ var setter = document.__lookupSetter__('title');
+ setter.call(document, "title 1");
+ is(document.title, "title 1", "the setter is bound correctly");
+} finally {
+ document.title = oldTitle
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug478438.html b/js/xpconnect/tests/mochitest/test_bug478438.html
new file mode 100644
index 000000000..76faa706c
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug478438.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=478438
+-->
+<head>
+ <title>Test for Bug 478438</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;version=1.8">
+ function fail(s, e) { ok(false, s + e) }
+ function pass(s, e) { ok(true, s) }
+ (pass.opposite = fail).opposite = pass;
+
+ function test() {
+ if (test.calledAlready)
+ return;
+ test.calledAlready = true;
+
+ var iwin = document.getElementById("f").contentWindow;
+
+ function testOne(fn, onAllow, infinitive) {
+ try { fn(); onAllow("able " + infinitive, "") }
+ catch (e) { onAllow.opposite("unable " + infinitive, ": " + e) }
+ }
+
+ testOne(() => iwin.focus, pass,
+ "to resolve/get allAccess property iwin.focus");
+
+ testOne(() => iwin.focus(), pass,
+ "to call allAccess method iwin.focus");
+
+ testOne(() => iwin.alert, fail,
+ "to resolve/get restricted property iwin.alert");
+
+ testOne(() => iwin.alert(), fail,
+ "to call restricted method iwin.alert");
+
+ testOne(() => iwin.location.toString(), fail,
+ "to call restricted method iwin.location.toString");
+
+ testOne(function() { iwin.location = "http://example.org" }, pass,
+ "to set writable property iwin.location");
+
+ SimpleTest.finish();
+ }
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478438">Mozilla Bug 478438</a>
+<p id="display"></p>
+<div id="content">
+ <iframe id="f" src="http://example.com" onload="test()"></iframe>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 478438 **/
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug484107.html b/js/xpconnect/tests/mochitest/test_bug484107.html
new file mode 100644
index 000000000..3bb82947e
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug484107.html
@@ -0,0 +1,99 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=484107
+-->
+<head>
+ <title>Test for Bug 484107</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484107">Mozilla Bug 484107</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 484107 **/
+
+ var text = "first group",
+ xpcWin = new XPCSafeJSObjectWrapper(window);
+ function get$1() { return RegExp.$1 };
+
+ function reset() {
+ var match = /(.*)/.exec(text);
+ if (!reset.skipStupidTests) {
+ reset.skipStupidTests = true;
+ ok(match, "No match?");
+ is(match[1], text, "Bad match?");
+ is(text, RegExp.$1, "RegExp.$1 missing?");
+ is(text, get$1(), "RegExp.$1 inaccessible?");
+ }
+ }
+
+ function test_XPC_SJOW_Call() {
+ isnot(text, xpcWin.get$1(), "Able to see RegExp.$1 from wrapped method.");
+ is("", xpcWin.get$1(), "Saw something other than an empty string for " +
+ "RegExp.$1 from wrapped method.");
+ is(text, window.get$1(), "Unable to see RegExp.$1 from non-wrapped method.");
+ }
+
+ function test_XPC_SJOW_Call_foreign_obj() {
+ var obj = {
+ xpcGet: xpcWin.get$1,
+ rawGet: window.get$1
+ };
+ isnot(text, obj.xpcGet(), "obj.xpcGet() returned matched text.");
+ is("", obj.xpcGet(), "obj.xpcGet() returned something other than the empty string.");
+ is(text, obj.rawGet(), "obj.rawGet() did not return matched text.");
+ }
+
+ function test_XPC_SJOW_toString() {
+ var str = new XPCSafeJSObjectWrapper({
+ toString: function() { return RegExp.$1 }
+ }) + "";
+ isnot(text, str, "toString() returned the matched text.");
+ is("", str, "toString() returned something other than the empty string.");
+ }
+
+ function test_XPC_SJOW_GetOrSetProperty() {
+ window.__defineGetter__("firstMatch", function() { return RegExp.$1 });
+ isnot(text, xpcWin.firstMatch, "Getter xpcWin.firstMatch returned matched text.");
+ is("", xpcWin.firstMatch,
+ "Getter xpcWin.firstMatch returned something other than the empty string.");
+ is(text, window.firstMatch, "Getter window.firstMatch did not return matched text.");
+ }
+
+ function test_XPC_SJOW_Create() {
+ function ctor() {
+ this.match = RegExp.$1;
+ return this; // XXX Why is this necessary?
+ }
+ ctor.prototype.getMatch = function() { return this.match };
+ var xpcCtor = new XPCSafeJSObjectWrapper(ctor),
+ match = (new xpcCtor).getMatch();
+ isnot(text, match, "(new xpcCtor).getMatch() was the matched text.");
+ is("", match, "(new xpcCtor).getMatch() was not the empty string.");
+ }
+
+ var tests = [
+ test_XPC_SJOW_Call,
+ test_XPC_SJOW_Call_foreign_obj,
+ test_XPC_SJOW_toString,
+ test_XPC_SJOW_GetOrSetProperty,
+ test_XPC_SJOW_Create
+ ];
+
+ for (var i = 0; i < tests.length; i++) {
+ reset();
+ tests[i]();
+ is(text, RegExp.$1, "RegExp.$1 was clobbered.");
+ }
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug500691.html b/js/xpconnect/tests/mochitest/test_bug500691.html
new file mode 100644
index 000000000..d543e4c03
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug500691.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=500691
+-->
+<head>
+ <title>Test for Bug 500691</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=500691">Mozilla Bug 500691</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 500691 **/
+ok(Function === alert.constructor, "alert's constructor is our Function");
+ok(window.Function === alert.constructor, "window.Function is also correct");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug504877.html b/js/xpconnect/tests/mochitest/test_bug504877.html
new file mode 100644
index 000000000..3b9fe9a52
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug504877.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=504877
+-->
+<head>
+ <title>Test for Bug 504877</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504877">Mozilla Bug 504877</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 504877 **/
+SimpleTest.waitForExplicitFinish();
+var p = 0;
+function go() {
+ var ifr = $('ifr').contentWindow;
+ function test1() {
+ try {
+ ifr.foopy;
+ ok(false, "should have thrown a cross-origin access exception");
+ } catch (e) {
+ ok(/Permission denied/.test(e), "Threw a permission denied exception");
+ }
+
+ var loc = ifr.location;
+ (function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ ifr.blat = 42;
+
+ is(ifr.blat, 42, "able to set random properties")
+ is(ifr.getblat(), 42, "setting properties propagates");
+ is(ifr.foopy, 42, "able to use UniversalXPConnect to get random properties");
+
+ loc.replace; // resolves the property onto the wrapper.
+ })();
+
+ loc.replace("http://mochi.test:8888/");
+ ok(true, "able to set location on the cross origin(!) frame");
+ }
+
+ function test2() {
+ SimpleTest.finish();
+ }
+
+ switch (++p) {
+ case 1: return test1();
+ case 2: return test2();
+ }
+}
+
+
+</script>
+</pre>
+<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/bug504877_helper.html" id="ifr" onload="go()"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug505915.html b/js/xpconnect/tests/mochitest/test_bug505915.html
new file mode 100644
index 000000000..04c5da82a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug505915.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=505915
+-->
+<head>
+ <title>Test for Bug 505915</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=505915">Mozilla Bug 505915</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript;version=1.7">
+
+/** Test for Bug 505915 **/
+window.addEventListener("message", function () { gen.next() }, false);
+
+function go() {
+ var ifr = $('ifr');
+ try {
+ // NB: the contentDocument getter now returns null for cross-origin
+ // frames, so use SpecialPowers to get a security wrapper to the document.
+ var xdoc = SpecialPowers.unwrap(SpecialPowers.wrap(ifr).contentDocument)
+ document.createTreeWalker(xdoc, 0, null);
+ ok(false, "should have thrown a security exception");
+ } catch (e) {
+ ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
+ /TypeError: Argument 1 of Document.createTreeWalker does not implement interface Node/.test(e),
+ "threw a security exception or binding exception instead of an " +
+ "invalid child exception");
+ }
+
+ SimpleTest.finish();
+ yield;
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+
+<iframe id="ifr" onload="gen = go(); gen.next();" src="http://example.org/"></iframe>
+
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug560351.html b/js/xpconnect/tests/mochitest/test_bug560351.html
new file mode 100644
index 000000000..27c26335f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug560351.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=560351
+-->
+<head>
+ <title>Test for Bug 560351</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=560351">Mozilla Bug 560351</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 560351 **/
+var pass = false;
+try {
+ document.body.__lookupGetter__("lastChild")();
+} catch (e) {
+ pass = true;
+}
+
+</script>
+<script>
+
+ok(pass, "pass was set to true");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug585745.html b/js/xpconnect/tests/mochitest/test_bug585745.html
new file mode 100644
index 000000000..a910bf376
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug585745.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=585745
+-->
+<head>
+ <title>Test for Bug 585745</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=585745">Mozilla Bug 585745</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 585745 **/
+
+ var a = document.createElementNS("http://www.w3.org/1998/Math/MathML", 'mrow');
+ var b = document.createElementNS("http://www.w3.org/1999/xhtml", 'span');
+ var htmlProto = Object.getPrototypeOf(b);
+ var mathMLProto = Object.getPrototypeOf(a);
+ // XXXbz once bug 560072 is fixed, we should be able to use
+ // getOwnPropertyDescriptor here.
+ Object.defineProperty(mathMLProto, "style", {
+ get: htmlProto.__lookupGetter__("style"),
+ });
+
+ var threw = false;
+ try {
+ a.style;
+ } catch(e) {
+ threw = true;
+ }
+ is(threw, true,
+ "Getting .style off a mathml element should throw in this case");
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug589028.html b/js/xpconnect/tests/mochitest/test_bug589028.html
new file mode 100644
index 000000000..d25c9a901
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug589028.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=589028
+-->
+<head>
+ <title>Test for Bug 589028</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=589028">Mozilla Bug 589028</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script>
+
+/** Test for Bug 589028 **/
+SimpleTest.waitForExplicitFinish();
+var p = 0;
+function go() {
+ var ifr = $('ifr');
+ var ifrwin = ifr.contentWindow;
+ var ifrdoc = ifr.contentDocument;
+
+ o1 = new ifrwin.Option();
+ is(o1.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ o2 = ifrwin.getMyOption();
+ is(o2.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ o3 = ifrwin.getCallersOption(this);
+ is(o3.ownerDocument, document);
+
+ a1 = new ifrwin.Audio();
+ is(a1.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ a2 = ifrwin.getMyAudio();
+ is(a2.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ a3 = ifrwin.getCallersAudio(this);
+ is(a3.ownerDocument, document);
+
+ i1 = new ifrwin.Image();
+ is(i1.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ i2 = ifrwin.getMyImage();
+ is(i2.ownerDocument, ifrdoc, "ownerDocument doesn't match iframe");
+
+ i3 = ifrwin.getCallersImage(this);
+ is(i3.ownerDocument, document);
+
+ SimpleTest.finish();
+}
+
+
+</script>
+</pre>
+<iframe src="bug589028_helper.html" id="ifr" onload="go()"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug601299.html b/js/xpconnect/tests/mochitest/test_bug601299.html
new file mode 100644
index 000000000..375c858a6
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug601299.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=601299
+
+Trigger a fastnative from a frameless context.
+-->
+<head>
+ <title>Test for Bug 601299</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="window.setTimeout(RegExp, 0); window.setTimeout(function() { ok(true); SimpleTest.finish(); }, 0);">
+<script>
+SimpleTest.waitForExplicitFinish();
+</script>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug605167.html b/js/xpconnect/tests/mochitest/test_bug605167.html
new file mode 100644
index 000000000..eaa4d2f67
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug605167.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=505915
+-->
+<head>
+ <title>Test for Bug 505915</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=505915">Mozilla Bug 505915</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript;version=1.7">
+
+/** Test for Bug 505915 **/
+var dataUrl = "data:text/html,<script>parent.f = function() { return this; };<" + "/script>";
+var targetUrl = "http://example.com";
+var f;
+
+var p = 0;
+function go() {
+ switch (++p) {
+ case 1:
+ frames[0].location = dataUrl;
+ break;
+ case 2:
+ frames[0].location = targetUrl;
+ break;
+ case 3:
+ try {
+ f().cross_origin_property;
+ ok(false, "should have thrown an exception");
+ } catch (e) {
+ ok(/Permission denied/.test(e) || /attempt to run compile-and-go script/.test(e),
+ "threw the correct exception");
+ }
+ SimpleTest.finish();
+ break;
+ }
+}
+
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+
+<iframe id="ifr" onload="go();"></iframe>
+
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug618017.html b/js/xpconnect/tests/mochitest/test_bug618017.html
new file mode 100644
index 000000000..c5b815e8d
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug618017.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=618017
+
+Parsing XML must not override the version.
+-->
+<head>
+ <title>Test for Bug 618017</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type='application/javascript;version=1.7'>
+let x = 12;
+function doLetEval() {
+ ok(eval('let x = 13; x') === 13, 'let statement is valid syntax in version 1.7');
+}
+</script>
+
+<script type='application/javascript;version=1.5'>
+doLetEval(); // Call to a function with a different version.
+</script>
+
+</body>
+</html>
+
diff --git a/js/xpconnect/tests/mochitest/test_bug623437.html b/js/xpconnect/tests/mochitest/test_bug623437.html
new file mode 100644
index 000000000..c925932a5
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug623437.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=623437
+-->
+<head>
+ <title>Test for Bug 623437</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=623437">Mozilla Bug 623437</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 623437 **/
+ var c = document.createElement("canvas").getContext("2d");
+ var seenArcToFirst;
+ var seenArc = false;
+ var seenArcTo = false;
+ for (var i in c) {
+ if (i == "arc") {
+ seenArc = true;
+ if (!seenArcTo)
+ seenArcToFirst = false;
+ }
+ if (i == "arcTo") {
+ seenArcTo = true;
+ if (!seenArc)
+ seenArcToFirst = true;
+ }
+ }
+ is(seenArc, true, "Should see arc");
+ is(seenArcTo, true, "Should see arcTo");
+ is(seenArcToFirst, true, "Should see arcTo before arc");
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug628410.html b/js/xpconnect/tests/mochitest/test_bug628410.html
new file mode 100644
index 000000000..1708ae393
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug628410.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=628410
+-->
+<head>
+ <title>Test for Bug 628410</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=628410">Mozilla Bug 628410</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 628410 **/
+window.toSource();
+window.toString();
+InstallTrigger + "";
+console + "";
+ok(true, "Things didn't throw");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug628794.html b/js/xpconnect/tests/mochitest/test_bug628794.html
new file mode 100644
index 000000000..115b6118f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug628794.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=585745
+-->
+<head>
+ <title>Test for Bug 585745</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=585745">Mozilla Bug 585745</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 585745 **/
+
+ var a = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
+ var b = document.createElementNS("http://www.w3.org/1999/xhtml", 'span');
+ var htmlProto = Object.getPrototypeOf(b);
+ var svgProto = Object.getPrototypeOf(a);
+ // XXXbz once bug 560072 is fixed, we should be able to use
+ // getOwnPropertyDescriptor here.
+ Object.defineProperty(svgProto, "style", {
+ get: htmlProto.__lookupGetter__("style"),
+ });
+
+ var threw = false;
+ try {
+ a.style;
+ } catch(e) {
+ threw = true;
+ }
+ is(threw, true,
+ "Getting .style off an svg element should throw in this case");
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug629227.html b/js/xpconnect/tests/mochitest/test_bug629227.html
new file mode 100644
index 000000000..0ed381285
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug629227.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=629227
+-->
+<head>
+ <title>Test for Bug 629227</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629227">Mozilla Bug 629227</a>
+<p id="display">
+ <iframe id="testTarget"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 629227 **/
+SimpleTest.waitForExplicitFinish();
+
+$("testTarget").src =
+ "http://test1.example.org" +
+ location.pathname.replace(/test_bug629227.html/, "file1_bug629227.html");
+
+window.onmessage = function(ev) {
+ if (ev.data == "finish") {
+ SimpleTest.finish();
+ } else {
+ var data = JSON.parse(ev.data);
+ if ("ok" in data) {
+ ok(data.ok, data.reason);
+ }
+ }
+}
+
+addLoadEvent(function() {
+ $("testTarget").contentWindow.postMessage("start", "*");
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug629331.html b/js/xpconnect/tests/mochitest/test_bug629331.html
new file mode 100644
index 000000000..413ec9d7b
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug629331.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=629331
+-->
+<head>
+ <title>Test for Bug 629331</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629331">Mozilla Bug 629331</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+
+function handler(event) {
+ var obj = JSON.parse(event.data);
+ if (obj.fun == "finish") {
+ SimpleTest.finish();
+ } else {
+ is(obj.a, obj.b, obj.description);
+ }
+}
+
+window.addEventListener('message', handler, false);
+
+</script>
+<iframe src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/test1_bug629331.html">
+</iframe>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug636097.html b/js/xpconnect/tests/mochitest/test_bug636097.html
new file mode 100644
index 000000000..09fd695a8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug636097.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=504877
+test by moz_bug_r_a4@yahoo.com
+-->
+<head>
+ <title>Test for Bug 504877</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504877">Mozilla Bug 504877</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 504877 **/
+SimpleTest.waitForExplicitFinish();
+
+var targetUrl = "http://example.com/";
+var l;
+
+function a() {
+ var r = "FAIL", s;
+ try {
+ s = l.toString();
+ }
+ catch (e) {
+ if (/denied|insecure/.test(e))
+ r = "PASS";
+ s = e;
+ }
+
+ is(r, "PASS", "should have thrown an exception");
+ SimpleTest.finish();
+}
+
+var p = 0;
+function b() {
+ switch (++p) {
+ case 1:
+ frames[0].location = "about:blank";
+ break;
+ case 2:
+ l = frames[0].location;
+ frames[0].location = targetUrl;
+ break;
+ case 3:
+ a();
+ break;
+ }
+}
+</script>
+
+</pre>
+<iframe onload="b()"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug650273.html b/js/xpconnect/tests/mochitest/test_bug650273.html
new file mode 100644
index 000000000..37f6609d8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug650273.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=650273
+test by moz_bug_r_a4@yahoo.com
+-->
+<head>
+ <title>Test for Bug 650273</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank"
+href="https://bugzilla.mozilla.org/show_bug.cgi?id=650273">Mozilla Bug 650273</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 504877 **/
+SimpleTest.waitForExplicitFinish();
+var count = 0;
+function done() {
+ if (++count == 2) {
+ try {
+ ok($('ifr').location.host === 'example.com', "shouldn't see this");
+ } catch (e) {
+ ok(true, "navigation successfully happened");
+ }
+ SimpleTest.finish();
+ }
+}
+
+</script>
+
+<iframe id="ifr" src="file_bug650273.html" onload="done()"></iframe>
+
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug655297-1.html b/js/xpconnect/tests/mochitest/test_bug655297-1.html
new file mode 100644
index 000000000..8f615762f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug655297-1.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=655297
+-->
+<head>
+ <title>Test for Bug 655297</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=655297">Mozilla Bug 655297</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+ <form>0</form> <form>1</form> <form>2</form> <form>3</form> <form>4</form>
+ <form>5</form> <form>6</form> <form>7</form> <form>8</form> <form>9</form>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 655297 **/
+
+var map = new WeakMap();
+function f() {
+ var paras = document.getElementsByTagName("form");
+ for (var i = 0; i < paras.length; i++)
+ map.set(paras[i], "ok");
+}
+function g() {
+ var paras = document.getElementsByTagName("form");
+ for (var i = 0; i < paras.length; i++) {
+ if (map.get(paras[i]) != "ok") {
+ return false;
+ }
+ }
+ return true;
+}
+
+f();
+SpecialPowers.forceGC();
+ok(g(), "Failed to keep XPCWrappedNative used as WeakMap key alive.");
+
+</script>
+
+
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug655297-2.html b/js/xpconnect/tests/mochitest/test_bug655297-2.html
new file mode 100644
index 000000000..2a99557d2
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug655297-2.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=655297
+-->
+<head>
+ <title>Test for Bug 655297</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=655297">Mozilla Bug 655297</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+ <p>0</p> <p>1</p> <p>2</p> <p>3</p> <p>4</p>
+ <p>5</p> <p>6</p> <p>7</p> <p>8</p> <p>9</p>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 655297 **/
+
+var map = new WeakMap();
+function f() {
+ var paras = document.getElementsByTagName("p");
+ for (var i = 0; i < paras.length; i++)
+ map.set(paras[i], "ok");
+}
+function g() {
+ var paras = document.getElementsByTagName("p");
+ for (var i = 0; i < paras.length; i++) {
+ if (map.get(paras[i]) != "ok") {
+ return false;
+ }
+ }
+ return true;
+}
+
+f();
+SpecialPowers.forceGC();
+ok(g(), "Failed to keep XPCWrappedNative used as WeakMap key alive.");
+
+</script>
+
+
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug661980.html b/js/xpconnect/tests/mochitest/test_bug661980.html
new file mode 100644
index 000000000..e372c1ee0
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug661980.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=661980
+-->
+<head>
+ <title>Test for Bug 661980</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=661980">Mozilla Bug 661980</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 661980 **/
+
+// While not currently needed, make this as similar as possible to a real
+// EventTarget just to make sure that we're tripping on the wrapping and
+// nothing else.
+var fakeTarget = {
+ addEventListener: function() {},
+ removeEventListener: function() {},
+ dispatchEvent: function() {}
+}
+
+var mouseevent = document.createEvent("MouseEvent");
+var didThrow = false;
+dump("hello nurse\n");
+try {
+ mouseevent.initMouseEvent("mouseover",
+ false, false,
+ window,
+ 1, 2, 3, 4, 5,
+ false, false, false, false,
+ 0,
+ fakeTarget);
+}
+catch (ex) {
+ didThrow = true;
+}
+ok(didThrow, "should not be able to implement EventTarget using script");
+
+mouseevent.initMouseEvent("mouseout",
+ false, false,
+ window,
+ 1, 2, 3, 4, 5,
+ false, false, false, false,
+ 0,
+ document.body);
+is(mouseevent.type, "mouseout",
+ "should able to implement EventTarget using Element");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug691059.html b/js/xpconnect/tests/mochitest/test_bug691059.html
new file mode 100644
index 000000000..830cf7b5d
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug691059.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=691059
+-->
+<head>
+ <title>Test for Bug 691059</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691059">Mozilla Bug 691059</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+
+/** Test for Bug 691059 **/
+
+function f() {}
+
+function testEventTarget(obj) {
+ obj.onmouseenter = f;
+ is(obj.onmouseenter, f,
+ "onmouseenter should be settable");
+ obj.onmouseleave = f;
+ is(obj.onmouseleave, f,
+ "onmouseenter should be settable");
+}
+
+function testInterface(obj) {
+ try {
+ obj.prototype.onmouseenter = f;
+ is("onmouseenter" in obj, false,
+ "setting <Interface>.prototype.onmouseenter has no effect on the " +
+ "non-existent <Interface>.onmouseenter");
+ obj.prototype.onmouseleave = f;
+ is("onmouseleave" in obj, false,
+ "setting <Interface>.prototype.onmouseleave has no effect on the " +
+ "non-existent <Interface>.onmouseleave");
+ } catch(ex) {
+ ok(false, ex);
+ }
+}
+
+testEventTarget(window);
+testEventTarget(document);
+testEventTarget(document.documentElement);
+
+testInterface(Document);
+testInterface(HTMLElement);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug720619.html b/js/xpconnect/tests/mochitest/test_bug720619.html
new file mode 100644
index 000000000..bf973a30a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug720619.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=720619
+-->
+<head>
+ <title>Test for Bug 629227</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720619">Mozilla Bug 720619</a>
+<p id="display">
+ <iframe id="testTarget"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 720619 **/
+SimpleTest.waitForExplicitFinish();
+
+function checkThrows(f, exception) {
+ try {
+ f();
+ ok(false, "should have thrown: " + f);
+ } catch (e) {
+ ok(exception.test(e.toString()), "correctly threw");
+ }
+}
+
+function go() {
+ var loc = $('ifr').contentWindow.location;
+ checkThrows(function() {loc + '';}, /Permission denied/);
+ checkThrows(function() {'' + loc;}, /Permission denied/);
+ checkThrows(function() {String(loc);}, /Permission denied/);
+
+ var win = $('ifr').contentWindow;
+ checkThrows(function() {win + '';}, /Permission denied/);
+ checkThrows(function() {'' + win;}, /Permission denied/);
+ checkThrows(function() {String(win);}, /Permission denied/);
+
+ SimpleTest.finish();
+}
+
+</script>
+
+<iframe id="ifr" onload="go()"
+ src="http://example.org/tests/js/xpconnect/tests/mochitest/file_bug720619.html">
+</iframe>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug731471.html b/js/xpconnect/tests/mochitest/test_bug731471.html
new file mode 100644
index 000000000..02f50d401
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug731471.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=731471
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 731471</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="setTimeout(boom, 0);">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=731471">Mozilla Bug 731471</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 731471. This is effectively a crashtest, but it uses window.open, which
+ doesn't work in the crashtest harness. **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+function boom()
+{
+ w = window.open("data:text/html,1");
+ setTimeout(function() {
+ w.document.write("2");
+ w.document.close();
+ w.document.write("3 - Done");
+ w.document.close();
+ w.close();
+ ok(true, "Didn't assert!");
+ SimpleTest.finish();
+ }, 400);
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug764389.html b/js/xpconnect/tests/mochitest/test_bug764389.html
new file mode 100644
index 000000000..3af46c51b
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug764389.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=764389
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 764389</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=764389">Mozilla Bug 764389</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 764389 **/
+
+// This is basically a crash test, but we need to write a mochitest so that it
+// runs with http:// urls instead of file:// urls.
+SimpleTest.waitForExplicitFinish();
+
+function go() {
+ var ifr = document.getElementById('ifr');
+ ifr.contentDocument.open();
+ ok(true, "Didn't crash");
+ ifr.contentDocument.close();
+ SimpleTest.finish();
+}
+
+
+
+</script>
+<iframe id="ifr" onload="go();" src="file_empty.html">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug772288.html b/js/xpconnect/tests/mochitest/test_bug772288.html
new file mode 100644
index 000000000..fba63f1a8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug772288.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=772288
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 772288</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="doTest()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=772288">Mozilla Bug 772288</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 772288 **/
+SimpleTest.waitForExplicitFinish();
+
+const Cu = SpecialPowers.Cu;
+
+function doTest() {
+ msg = "Services should be imported on window";
+ try {
+ Cu.import("resource://gre/modules/Services.jsm", window);
+ ok(Services, msg);
+ } catch (ex) {
+ ok(false, msg + " : " + ex);
+ }
+
+ msg = "Services should be imported on myObj";
+ try {
+ var myObj = {};
+ Cu.import("resource://gre/modules/Services.jsm", myObj);
+ ok(myObj.Services, msg);
+ } catch (ex) {
+ ok(false, msg + " : " + ex);
+ }
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug781476.html b/js/xpconnect/tests/mochitest/test_bug781476.html
new file mode 100644
index 000000000..f01cedfd4
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug781476.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=781476
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 781476</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781476">Mozilla Bug 781476</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 781476 **/
+SimpleTest.waitForExplicitFinish();
+
+function go() {
+ var iwin = document.getElementById('ifr').contentWindow;
+ iwin.is = is;
+ var evt = iwin.makeEvent();
+ is(evt.expando, 42, "Expando properly visible in caller frame");
+ SimpleTest.finish();
+}
+
+
+</script>
+</pre>
+<iframe onload="go();" id="ifr" src="file_bug781476.html"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug789713.html b/js/xpconnect/tests/mochitest/test_bug789713.html
new file mode 100644
index 000000000..58ebf2fb2
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug789713.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=789713
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 789713</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=789713">Mozilla Bug 789713</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 Bug 789713 **/
+
+// We can't set document.domain on mochi.test, because it's forbidden to set
+// document.domain to a TLD.
+var ifr = document.getElementById('ifr');
+
+SimpleTest.waitForExplicitFinish();
+ifr.src = window.location.toString().replace("mochi.test:8888", "test1.example.org")
+ .replace("test_bug789713", "file_bug789713")
+ .split('?')[0];
+window.onmessage = function(message) {
+ ok(message.data, "Test succeeded and didn't crash");
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug790732.html b/js/xpconnect/tests/mochitest/test_bug790732.html
new file mode 100644
index 000000000..48b7fdbb6
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug790732.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=790732
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 790732</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">
+
+ // Basic stuff
+ ok(Components, "Components shim exists!");
+ var Ci = Components.interfaces;
+ ok(Ci, "interfaces shim exists!");
+ is(typeof Components.classes, 'undefined', "Shouldn't have a Cc");
+
+ // Check each interface that we shim. We start by checking specific
+ // constants for a couple of interfaces, and then once it's pretty clear that
+ // it's working as intended we just check that the objects themselves are the
+ // same.
+ is(Ci.nsIXMLHttpRequest.HEADERS_RECEIVED, XMLHttpRequest.HEADERS_RECEIVED);
+ is(Ci.nsIDOMDOMException.DATA_CLONE_ERR, DOMException.DATA_CLONE_ERR);
+ is(Ci.nsIDOMNode.DOCUMENT_NODE, Node.DOCUMENT_NODE);
+ is(Ci.nsIDOMCSSPrimitiveValue.CSS_PX, CSSPrimitiveValue.CSS_PX);
+ is(Ci.nsIDOMCSSRule.NAMESPACE_RULE, CSSRule.NAMESPACE_RULE);
+ is(Ci.nsIDOMCSSValue.CSS_PRIMITIVE_VALUE, CSSValue.CSS_PRIMITIVE_VALUE);
+ is(Ci.nsIDOMEvent.FOCUS, Event.FOCUS);
+ is(Ci.nsIDOMNSEvent.CLICK, Event.CLICK);
+ is(Ci.nsIDOMKeyEvent, KeyEvent);
+ is(Ci.nsIDOMMouseEvent, MouseEvent);
+ is(Ci.nsIDOMMouseScrollEvent, MouseScrollEvent);
+ is(Ci.nsIDOMMutationEvent, MutationEvent);
+ is(Ci.nsIDOMSimpleGestureEvent, SimpleGestureEvent);
+ is(Ci.nsIDOMUIEvent, UIEvent);
+ is(Ci.nsIDOMHTMLMediaElement, HTMLMediaElement);
+ is(Ci.nsIDOMOfflineResourceList, OfflineResourceList);
+ is(Ci.nsIDOMRange, Range);
+ is(Ci.nsIDOMSVGLength, SVGLength);
+ is(Ci.nsIDOMNodeFilter, NodeFilter);
+ is(Ci.nsIDOMXPathResult, XPathResult);
+
+ // Test for Bug 895231
+ for (var k of Object.keys(Components.interfaces)) {
+ ok(SpecialPowers.Ci.hasOwnProperty(k),
+ k + " should be removed from the Components shim");
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=790732">Mozilla Bug 790732</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+<iframe id="ifr"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug793969.html b/js/xpconnect/tests/mochitest/test_bug793969.html
new file mode 100644
index 000000000..0936967bd
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug793969.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=793969
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 793969</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=793969">Mozilla Bug 793969</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 793969 **/
+function checkThrows(f, desc, skipMessageCheck) {
+ try {
+ f();
+ ok(false, "Should have thrown for " + desc);
+ } catch (e) {
+ ok(true, "threw correctly");
+ if (!skipMessageCheck)
+ ok(/denied/.exec(e) ||
+ /can't redefine non-configurable property/.exec(e),
+ "Correctly threw a security exception: " + e);
+ }
+}
+
+// NB: These sets will be no-ops (throw in strict mode) because setting an inherited readonly value prop has those semantics.
+checkThrows(function() { "use strict"; location.valueOf = 'hah'; }, 'Shadow with string', /* skipMessageCheck = */ true);
+checkThrows(function() { "use strict"; location.valueOf = function() { return {a: 'hah'};} }, 'Shadow with function', /* skipMessageCheck = */ true);
+checkThrows(function() { Object.defineProperty(location, 'valueOf', { value: function() { return 'hah'; } }); }, 'defineProperty with value');
+checkThrows(function() { delete location.valueOf; Object.defineProperty(location, 'valueOf', { value: function() { return 'hah'; } }); }, 'delete + defineProperty with value');
+checkThrows(function() { Object.defineProperty(location, 'valueOf', { get: function() { return 'hah'; } }); }, 'defineProperty with getter');
+checkThrows(function() { delete location.valueOf; Object.defineProperty(location, 'valueOf', { get: function() { return 'hah'; } }); }, 'delete + defineProperty with getter');
+
+Object.prototype.valueOf = function() { return 'hah'; };
+is(({}).valueOf(), 'hah', "Shadowing on Object.prototype works for vanilla objects");
+is(location.valueOf(), location, "Shadowing on Object.prototype and Location.prototype doesn't for location objects");
+
+location[Symbol.toPrimitive] = function() { return 'hah'; }
+is(location + "", location.toString(), "Should't be able to shadow with toPrimitive");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug800864.html b/js/xpconnect/tests/mochitest/test_bug800864.html
new file mode 100644
index 000000000..560dda072
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug800864.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=800864
+-->
+<head>
+ <title>Test for Bug 800864</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=800864">Mozilla Bug 800864</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function checkThrows(f) {
+ try {
+ f();
+ ok(false, "Didn't throw a security exception like we should");
+ } catch(e) {
+ ok(/denied|insecure/.exec(e), "Should throw security exception. Got: " + e);
+ }
+}
+
+function go() {
+ ifr = document.getElementById('ifr');
+ win = ifr.contentWindow;
+ loc = win.location;
+ ifr.onload = check;
+ win.location = 'http://test1.example.com';
+}
+
+function check() {
+ checkThrows(function() { loc.toString(); });
+ checkThrows(function() { loc.valueOf().toString(); });
+ checkThrows(function() { loc.href; });
+ checkThrows(function() { loc + ''; });
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+<iframe id="ifr" onload="go()" src="file_empty.html"></iframe>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug802557.html b/js/xpconnect/tests/mochitest/test_bug802557.html
new file mode 100644
index 000000000..073f22e72
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug802557.html
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=802557
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 802557</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 802557 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function checkThrows(fun, desc) {
+ try {
+ fun();
+ ok(false, "Didn't throw when " + desc);
+ } catch(e) {
+ ok(true, "Threw when " + desc + " " + e);
+ ok(/denied|insecure/.exec(e), "Should be security exception");
+ }
+ }
+
+ var loadCount = 0;
+ function go() {
+ ++loadCount;
+ window.ifr = document.getElementById('ifr');
+ window.iWin = ifr.contentWindow;
+
+ if (loadCount == 1) {
+ gLoc = iWin.location;
+ // Note that accessors pulled off Xrays are currently bound. This is bug 658909.
+ // [getter, description, locationObj, bound]
+ gGetters = [[ location.toString, 'toString from LW' ],
+ [ gLoc.toString, 'toString from XLW' ],
+ [ Object.__lookupGetter__.call(location, 'href'), 'href getter from LW' ],
+ [ Object.__lookupGetter__.call(gLoc, 'href'), 'href getter from XLW' ],
+ [ Object.getOwnPropertyDescriptor(location, 'href').get, 'href getter from location' ],
+ [ Object.getOwnPropertyDescriptor(gLoc, 'href').get, 'href getter from iWin.location' ],
+ [ function() { return this + ''; }, 'implicit conversion via [[DefaultValue]]', /* doMessageCheck = */ true ]];
+ gGetters.forEach(function(item) {
+ try {
+ is(item[0].call(location), location.toString(), 'Same-origin LW: ' + item[1]);
+ is(item[0].call(gLoc), gLoc.toString(), 'Same-origin XLW: ' + item[1]);
+ } catch (e) {
+ ok(false, "Threw while applying " + item[1] + " to same-origin location object: " + e);
+ }
+ });
+ ifr.src = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
+ }
+ else if (loadCount == 2) {
+ gGetters.forEach(function(item) {
+ checkThrows(function() { item[0].call(gLoc); },
+ 'call()ing ' + item[1] + ' after navigation cross-origin');
+ });
+ ifr.src = 'http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_bug802557.html';
+ }
+ else if (loadCount == 3) {
+ gTestFunctions = ifr.contentWindow.getAllTests();
+ var win = ifr.contentWindow;
+ for (fun in gTestFunctions)
+ is(gTestFunctions[fun](), win.location.toString(), "allowed via " + fun);
+ win.location = 'http://example.org/tests/js/xpconnect/tests/mochitest/file_bug802557.html';
+ }
+ else if (loadCount == 4) {
+ for (fun in gTestFunctions) {
+ var f = gTestFunctions[fun];
+ checkThrows(f, "calling " + fun);
+ }
+
+ // Verify that URL.prototype.toString can't be applied to Location
+ var threw = false;
+ try {
+ URL.prototype.toString.call(location);
+ } catch (e) {
+ threw = true;
+ }
+ ok(threw,
+ "Should not be able to use URL.prototype.toString on a Location instance");
+
+ // Verify that URL.prototype.href getter can't be applied to Location
+ threw = false;
+ var reachedTest = false;
+ try {
+ var get = Object.getOwnPropertyDescriptor(URL.prototype, "href").get;
+ is(typeof(get), "function", "Should have an href getter on URL.prototype");
+ var reachedTest = true;
+ get.call(location);
+ } catch (e) {
+ threw = true;
+ }
+ ok(reachedTest,
+ "Should not be able to find URL.prototype.href getter");
+ ok(threw,
+ "Should not be able to use URL.prototype.href getter on a Location instance");
+ SimpleTest.finish();
+ }
+ }
+
+
+
+</script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=802557">Mozilla Bug 802557</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe id="ifr" onload="go();" src="file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug803730.html b/js/xpconnect/tests/mochitest/test_bug803730.html
new file mode 100644
index 000000000..4a1552f4f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug803730.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=803730
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 803730</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=803730">Mozilla Bug 803730</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 803730 **/
+var foo = {
+ isNode: function(obj) {
+ return !!(obj instanceof Node);
+ }
+};
+
+var elem = document.createElement("span");
+var trueCount = 0,
+ falseCount = 0;
+for (var x = 0; x < 100000; x++) {
+ if (foo.isNode(elem))
+ trueCount++;
+ else
+ falseCount++;
+}
+is(falseCount, 0, "elem instanceof Node working correctly.");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug809547.html b/js/xpconnect/tests/mochitest/test_bug809547.html
new file mode 100644
index 000000000..c2c87623f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug809547.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=809547
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 809547</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="go()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=809547">Mozilla Bug 809547</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 809547 **/
+SimpleTest.waitForExplicitFinish();
+var gObj = {};
+function go() {
+ window.location.expando = gObj;
+ is(window.location.expando, gObj, "Expando appears");
+ SimpleTest.executeSoon(finish);
+}
+
+function finish() {
+ SpecialPowers.forceGC();
+ SpecialPowers.forceCC();
+ SpecialPowers.forceGC();
+ SpecialPowers.forceCC();
+ is(window.location.expando, gObj, "Expando preserved");
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug829872.html b/js/xpconnect/tests/mochitest/test_bug829872.html
new file mode 100644
index 000000000..9c48983e8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug829872.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=829872
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 829872</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 829872 and Bug 968003 **/
+ SimpleTest.waitForExplicitFinish();
+
+ var gLoadCount = 0;
+ function loaded() {
+ if (++gLoadCount == 3)
+ go();
+ }
+
+ function check(elem, desc) {
+ is(elem.contentDocument, null, "null cross-origin contentDocument for " + desc);
+ ok(SpecialPowers.wrap(elem).contentWindow.eval('frameElement === null;'),
+ "null cross-origin frameElement for " + desc);
+ if (!(elem instanceof HTMLFrameElement))
+ is(elem.getSVGDocument(), null, "null cross-origin getSVGDocument() for " + desc);
+ }
+
+ function go() {
+ ok(true, "Starting test");
+ check($('ifr'), "iframe element");
+ check($('obj'), "object element");
+ check($('framesetholder').contentDocument.getElementById('fr'), "frameset frame");
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=829872">Mozilla Bug 829872</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+<iframe id="ifr" onload="loaded();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+<object id="obj" onload="loaded();" data="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></object>
+<iframe id="framesetholder" src="data:text/html,<html><head></head><frameset cols='100%'><frame id='fr' onload='parent.loaded();' src='http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html' /></frameset></html>"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug862380.html b/js/xpconnect/tests/mochitest/test_bug862380.html
new file mode 100644
index 000000000..0d3fb7329
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug862380.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=862380
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 862380</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 862380 **/
+ SimpleTest.waitForExplicitFinish();
+ function go() {
+ checkNotEnumerable($('ifr').contentWindow);
+ checkNotEnumerable($('ifr').contentWindow.location);
+ SimpleTest.finish();
+ }
+
+ function checkNotEnumerable(obj) {
+ try {
+ is(Object.keys(obj).length, 0, "Object.keys gives empty array");
+ for (var i in obj)
+ ok(false, "Enumerated something: " + i);
+ } catch (e) {
+ ok(false, "threw: " + e);
+ }
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=862380">Mozilla Bug 862380</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe id="ifr" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug865260.html b/js/xpconnect/tests/mochitest/test_bug865260.html
new file mode 100644
index 000000000..8878e9df5
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug865260.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=865260
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 865260</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 865260 **/
+ SimpleTest.waitForExplicitFinish();
+ function go() {
+ var exn = "nothrow";
+ try { $('ifr').contentWindow['Date']; } catch (e) { exn = e; };
+ ok(!!/denied/.exec(exn), "Threw instead of crashing");
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=865260">Mozilla Bug 865260</a>
+<p id="display"></p>
+<div id="content">
+<iframe id="ifr" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug870423.html b/js/xpconnect/tests/mochitest/test_bug870423.html
new file mode 100644
index 000000000..6fce43527
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug870423.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=870423
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 870423</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 cross-scope instanceof. **/
+ SimpleTest.waitForExplicitFinish();
+
+ function go() {
+ var sowin = $('soifr').contentWindow;
+ var xowin = $('xoifr').contentWindow;
+
+ check(window, sowin, 'HTMLBodyElement', function(win) { return win.document.body; });
+ check(window, sowin, 'HTMLDocument', function(win) { return win.document; });
+ check(window, sowin, 'Window', function(win) { return win; });
+ check(window, sowin, 'Location', function(win) { return win.location; });
+
+ ok(xowin instanceof Window, "Cross-origin instanceof should work");
+ ok(xowin.location instanceof Location, "Cross-origin instanceof should work");
+
+ SimpleTest.finish();
+ }
+
+ function check(win1, win2, constructorName, getInstance) {
+ ok(getInstance(win1) instanceof win2[constructorName],
+ "Cross-Scope instanceof works: " + constructorName + ", " + win1.location + ", " + win2.location);
+ ok(getInstance(win2) instanceof win1[constructorName],
+ "Cross-Scope instanceof works: " + constructorName + ", " + win2.location + ", " + win1.location);
+ }
+
+ </script>
+</head>
+<body onload="go();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870423">Mozilla Bug 870423</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe id="soifr" src="file_empty.html"></iframe>
+<iframe id="xoifr" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug871887.html b/js/xpconnect/tests/mochitest/test_bug871887.html
new file mode 100644
index 000000000..89239eb44
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug871887.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=871887
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 871887</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;version=1.7">
+
+ /** Test for Bug 871887 **/
+ SimpleTest.waitForExplicitFinish();
+
+ // NB: onstart ends up getting invoked twice, for mysterious and potentially-
+ // IE6-related reasons.
+ function checkpoint(invocant) {
+ ok(true, "onstart called");
+ is(invocant, $('llama'), "this-binding is correct");
+ $('llama').loop = 1;
+ $('llama').scrollDelay = 1;
+ $('llama').scrollAmount = 500;
+ }
+
+ function done(invocant) {
+ is(invocant, $('llama'), "this-binding is correct");
+ ok(true, "onfinish called");
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=871887">Mozilla Bug 871887</a>
+<p id="display"></p>
+<div id="content">
+<marquee id="llama" onstart="checkpoint(this);" onfinish="done(this);">Watch the Llama</marquee>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug912322.html b/js/xpconnect/tests/mochitest/test_bug912322.html
new file mode 100644
index 000000000..c274b6afc
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug912322.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=912322
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 912322</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 that XBL functions aren't exposed to the web. **/
+ funs = ['getAnonymousNodes', 'getAnonymousElementByAttribute',
+ 'getBindingParent', 'loadBindingDocument'];
+ for (var f of funs) {
+ ok(!(f in document), f + " should not be available to content");
+ ok(f in SpecialPowers.wrap(document), f + " should be available to chrome via Xray");
+ }
+
+ // Test window.controllers.
+ ok(typeof window.controllers, 'undefined', "controllers should not be available to content");
+ ok(typeof SpecialPowers.wrap(window).controllers, 'object', "controllers should be available over Xray");
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=912322">Mozilla Bug 912322</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug916945.html b/js/xpconnect/tests/mochitest/test_bug916945.html
new file mode 100644
index 000000000..078f2a445
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug916945.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=916945
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 916945</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 916945 **/
+ SimpleTest.waitForExplicitFinish();
+
+ var gLoadCount = 0;
+ function loaded() {
+ if (++gLoadCount == 2)
+ go();
+ }
+ function go() {
+ // Both same-origin and cross-origin names should be visible if they're set
+ // on the iframe element.
+ ok('winA' in window, "same-origin named access works");
+ ok(winA instanceof Window, "same-origin named access works");
+ ok('winB' in window, "cross-origin named access works when iframe name matches");
+ // XXXbholley - flip me when Window moves to new bindings.
+ todo_is(winB instanceof Window, "cross-origin named access works when iframe name matches");
+
+ // Setting the 'name' attribute should propagate to the docshell.
+ var ifrB = document.getElementById('ifrB');
+ ifrB.setAttribute('name', 'foo');
+ is(SpecialPowers.wrap(ifrB).contentWindow.name, 'foo', 'attribute sets propagate to the docshell');
+ ok('foo' in window, "names are dynamic if updated via setAttribute");
+ // XXXbholley - flip me when Window moves to new bindings.
+ todo('foo' instanceof Window, "names are dynamic if updated via setAttribute");
+
+ // Setting window.name on the subframe should not propagate to the attribute.
+ SpecialPowers.wrap(ifrB).contentWindow.name = 'bar';
+ is(ifrB.getAttribute('name'), 'foo', 'docshell updates dont propagate to the attribute');
+
+ // When the frame element attribute and docshell name don't match, nothing is returned.
+ ok(!('foo' in window), "frame element name not resolved if it doesn't match the docshell");
+ ok(!('bar' in window), "docshell name not resolved if it doesn't match the frame element");
+
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=916945">Mozilla Bug 916945</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe id="ifrA" name="winA" onload="loaded();" src="file_empty.html"></iframe>
+<iframe id="ifrB" name="winB" onload="loaded();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug92773.html b/js/xpconnect/tests/mochitest/test_bug92773.html
new file mode 100644
index 000000000..4cec5eae6
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug92773.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=92773
+-->
+<head>
+ <title>Test for Bug 92773</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=92773">Mozilla Bug 92773</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 92773 **/
+function go() {
+ try {
+ $('ifr').contentWindow.foo;
+ ok(false, "able to access cross-origin getter");
+ } catch (e) {
+ ok(/Permission denied/.exec(e), "unable to access cross-origin getter");
+ }
+
+ SimpleTest.finish();
+}
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+
+<iframe id='ifr'
+ src='http://example.com/tests/js/xpconnect/tests/mochitest/bug92773_helper.html'
+ onload="go()">
+</iframe>
+
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug940783.html b/js/xpconnect/tests/mochitest/test_bug940783.html
new file mode 100644
index 000000000..9e9e49084
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug940783.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=940783
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 940783</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 940783 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function checkHistoryThrows(hist) {
+ checkThrows(function() { hist.length; });
+ checkThrows(function() { hist.state; });
+ checkThrows(function() { hist.go(); });
+ checkThrows(function() { hist.back(); });
+ checkThrows(function() { hist.forward(); });
+ checkThrows(function() { hist.pushState({}, "foo"); });
+ checkThrows(function() { hist.replaceState({}, "foo"); });
+
+ }
+
+ window.gLoads = 0;
+ function load() {
+ var iwin = $('ifr').contentWindow;
+ ++gLoads;
+ if (gLoads == 1) {
+ window.gHist = iwin.history;
+ iwin.location = "file_empty.html";
+ } else if (gLoads == 2) {
+ checkHistoryThrows(gHist);
+ window.gHist = iwin.history;
+ iwin.location = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
+ } else {
+ checkHistoryThrows(gHist);
+ $('ifr').setAttribute('onload', null);
+ SimpleTest.finish();
+ }
+ }
+
+ function checkThrows(fn) {
+ try { fn(); ok(false, "Should have thrown: " + fn.toSource()); }
+ catch (e) { ok(!!/denied|insecure/.exec(e), "Threw correctly: " + e); }
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=940783">Mozilla Bug 940783</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+<iframe id="ifr" onload="load();" src="file_empty.html"></iframe>
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug960820.html b/js/xpconnect/tests/mochitest/test_bug960820.html
new file mode 100644
index 000000000..43310f589
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug960820.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=960820
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 960820</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 exception stacks crossing **/
+
+ // Synchronous event dispatch creates a new script entry point. At the time
+ // of this writing, an event listener defined in a Sandbox will cause the
+ // SafeJSContext to be pushed to the cx stack, which differs from the JSContext
+ // associated with this DOM window. So we test both kinds of boundaries.
+ var sb = new SpecialPowers.Cu.Sandbox(SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal());
+ sb.win = window;
+ SpecialPowers.Cu.evalInSandbox("win.document.addEventListener('click', " +
+ "function clickHandler() { win.wrappedJSObject.clickCallback(); });", sb);
+ function clickCallback() {
+ var stack = (new Error()).stack;
+ ok(true, "Invoked clickCallback. Stack: " + stack);
+ ok(/clickCallback/.test(stack), "clickCallback should be in the stack");
+ ok(!/clickHandler/.test(stack), "clickHandler should not be in the stack");
+ ok(/dispatchClick/.test(stack), "dispatchClick should be in the stack");
+
+ // Check Components.stack, but first filter through the SpecialPowers junk.
+ var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
+ while (/specialpowers/.test(stack)) {
+ stack = stack.caller;
+ }
+ ok(/clickCallback/.test(stack), "clickCallback should be reachable via Components.stack");
+ ok(/clickHandler/.test(stack.caller), "clickHandler should be reachable via Components.stack");
+ ok(/dispatchClick/.test(stack.caller.caller), "dispatchClick hould be reachable via Components.stack");
+ }
+ function dispatchClick() {
+ document.dispatchEvent(new MouseEvent('click'));
+ }
+ dispatchClick();
+
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=960820">Mozilla Bug 960820</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug965082.html b/js/xpconnect/tests/mochitest/test_bug965082.html
new file mode 100644
index 000000000..8f04cd3f8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug965082.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=965082
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 965082</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 965082 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function checkThrows(f, msg) {
+ try { f(); ok(false, "Should have thrown: " + msg); }
+ catch (e) { ok(/denied|insecure/.test(e), "Should throw security exception: " + e + " (" + msg + ")"); }
+ }
+
+ function go() {
+ var protoSetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
+ checkThrows(function() { protoSetter.call(window[0], new Object()); }, "Setting cross-origin Window prototype");
+ checkThrows(function() { protoSetter.call(window[0].location, new Object()); }, "Setting cross-origin Location prototype");
+ SimpleTest.finish();
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=965082">Mozilla Bug 965082</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<iframe id="ifr" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug986542.html b/js/xpconnect/tests/mochitest/test_bug986542.html
new file mode 100644
index 000000000..a0759c43f
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug986542.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=986542
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 986542</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 986542 **/
+ SimpleTest.waitForExplicitFinish();
+ addLoadEvent(function() {
+ var ifr = document.getElementById("ifr");
+ var doc = ifr.contentDocument;
+ var scr = doc.createElement("script");
+ scr.textContent = "function f() { onF(); }";
+ ifr.contentWindow.onF = function() {
+ ok(true, "Called event handler in detached window");
+ SimpleTest.finish();
+ }
+ doc.body.appendChild(scr);
+ var target = document.getElementById("target");
+ target.onclick = ifr.contentWindow.f;
+ ifr.parentNode.removeChild(ifr);
+ info("Removed frame from document. Waiting for event handler to be called.");
+ target.dispatchEvent(new MouseEvent('click'));
+ });
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=986542">Mozilla Bug 986542</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<div id="target"></div>
+<iframe id="ifr"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_bug993423.html b/js/xpconnect/tests/mochitest/test_bug993423.html
new file mode 100644
index 000000000..43c17a49a
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_bug993423.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=993423
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 993423</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 993423 **/
+ SimpleTest.waitForExplicitFinish();
+
+ var sCallbackInvocations = 0;
+ function callback(handlerIsInXBLScope) {
+ ok(!handlerIsInXBLScope, "Event handler should not be in XBL scope");
+ if (++sCallbackInvocations == 2)
+ SimpleTest.finish();
+ }
+
+ function go() {
+ document.querySelector('use').setAttributeNS('http://www.w3.org/1999/xlink',
+ 'href', location.href + '#a');
+ }
+
+ </script>
+</head>
+<body onload="go()";>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=993423">Mozilla Bug 993423</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+<svg>
+ <symbol id="a">
+ <foreignObject>
+ <img src="about:logo" onload="var isInXBL = (function() { return this; })() != window; if (isInXBL) callback = window.wrappedJSObject.callback; callback(isInXBL);">
+ </foreignObject>
+ </symbol>
+ <use />
+</svg>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_crossOriginObjects.html b/js/xpconnect/tests/mochitest/test_crossOriginObjects.html
new file mode 100644
index 000000000..adfd25869
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_crossOriginObjects.html
@@ -0,0 +1,336 @@
+<!doctype html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Cross-origin behavior of Window and Location</title>
+<link rel="author" title="Bobby Holley (:bholley)" href="bobbyholley@gmail.com">
+<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/#security-window">
+<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/#security-location">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe id="B"></iframe>
+<iframe id="C"></iframe>
+<script>
+
+/*
+ * Setup boilerplate. This gives us a same-origin window "B" and a cross-origin
+ * window "C".
+ */
+
+setup({explicit_done: true});
+path = location.pathname.substring(0, location.pathname.lastIndexOf('/')) + '/file_crossOriginObjects.html';
+var B = document.getElementById('B').contentWindow;
+var C = document.getElementById('C').contentWindow;
+B.frameElement.uriToLoad = path;
+C.frameElement.uriToLoad = 'http://test1.mochi.test:' + location.port + path;
+
+function reloadSubframes(cb) {
+ var iframes = document.getElementsByTagName('iframe');
+ iframes.forEach = Array.prototype.forEach;
+ var count = 0;
+ function frameLoaded() {
+ this.onload = null;
+ if (++count == iframes.length)
+ cb();
+ }
+ iframes.forEach(function(ifr) { ifr.onload = frameLoaded; ifr.setAttribute('src', ifr.uriToLoad); });
+}
+function isObject(x) { return Object(x) === x; }
+
+/*
+ * Note: we eschew assert_equals in a lot of these tests, since the harness ends
+ * up throwing when it tries to format a message involving a cross-origin object.
+ */
+
+var testList = [];
+function addTest(fun, desc) { testList.push([fun, desc]); }
+
+
+/*
+ * Basic sanity testing.
+ */
+
+addTest(function() {
+ assert_equals(location.host, 'mochi.test:8888', 'Need to run the top-level test from mochi.test:8888');
+ assert_equals(B.parent, window, "window.parent works same-origin");
+ assert_equals(C.parent, window, "window.parent works cross-origin");
+ assert_equals(B.location.pathname, path, "location.href works same-origin");
+ assert_throws(null, function() { C.location.pathname; }, "location.pathname throws cross-origin");
+ assert_equals(B.frames, 'override', "Overrides visible in the same-origin case");
+ assert_equals(C.frames, C, "Overrides invisible in the cross-origin case");
+}, "Basic sanity-checking");
+
+/*
+ * Whitelist behavior.
+ *
+ * Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior.
+ */
+
+var whitelistedWindowProps = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent',
+ 'opener', 'closed', 'close', 'blur', 'focus', 'length'];
+addTest(function() {
+ for (var prop in window) {
+ if (whitelistedWindowProps.indexOf(prop) != -1) {
+ C[prop]; // Shouldn't throw.
+ Object.getOwnPropertyDescriptor(C, prop); // Shouldn't throw.
+ assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + prop);
+ } else {
+ assert_throws(null, function() { C[prop]; }, "Should throw when accessing " + prop + " on Window");
+ assert_throws(null, function() { Object.getOwnPropertyDescriptor(C, prop); },
+ "Should throw when accessing property descriptor for " + prop + " on Window");
+ assert_throws(null, function() { Object.prototype.hasOwnProperty.call(C, prop); },
+ "Should throw when invoking hasOwnProperty for " + prop + " on Window");
+ }
+ if (prop != 'location')
+ assert_throws(null, function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window");
+ }
+ for (var prop in location) {
+ if (prop == 'replace') {
+ C.location[prop]; // Shouldn't throw.
+ Object.getOwnPropertyDescriptor(C.location, prop); // Shouldn't throw.
+ assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop);
+ }
+ else {
+ assert_throws(null, function() { C[prop]; }, "Should throw when accessing " + prop + " on Location");
+ assert_throws(null, function() { Object.getOwnPropertyDescriptor(C, prop); },
+ "Should throw when accessing property descriptor for " + prop + " on Location");
+ assert_throws(null, function() { Object.prototype.hasOwnProperty.call(C, prop); },
+ "Should throw when invoking hasOwnProperty for " + prop + " on Location");
+ }
+ if (prop != 'href')
+ assert_throws(null, function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location");
+ }
+}, "Only whitelisted properties are accessible cross-origin");
+
+/*
+ * ES Internal Methods.
+ */
+
+/*
+ * [[GetPrototypeOf]]
+ */
+addTest(function() {
+ assert_true(Object.getPrototypeOf(C) === null, "cross-origin Window proto is null");
+ assert_true(Object.getPrototypeOf(C.location) === null, "cross-origin Location proto is null (__proto__)");
+ var protoGetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').get;
+ assert_true(protoGetter.call(C) === null, "cross-origin Window proto is null");
+ assert_true(protoGetter.call(C.location) === null, "cross-origin Location proto is null (__proto__)");
+ assert_throws(null, function() { C.__proto__; }, "__proto__ property not available cross-origin");
+ assert_throws(null, function() { C.location.__proto__; }, "__proto__ property not available cross-origin");
+
+}, "[[GetPrototypeOf]] should return null");
+
+/*
+ * [[SetPrototypeOf]]
+ */
+addTest(function() {
+ assert_throws(null, function() { C.__proto__ = new Object(); }, "proto set on cross-origin Window");
+ assert_throws(null, function() { C.location.__proto__ = new Object(); }, "proto set on cross-origin Location");
+ var setters = [Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set];
+ if (Object.setPrototypeOf)
+ setters.push(function(p) { Object.setPrototypeOf(this, p); });
+ setters.forEach(function(protoSetter) {
+ assert_throws(null, function() { protoSetter.call(C, new Object()); }, "proto setter |call| on cross-origin Window");
+ assert_throws(null, function() { protoSetter.call(C.location, new Object()); }, "proto setter |call| on cross-origin Location");
+ });
+}, "[[SetPrototypeOf]] should throw");
+
+/*
+ * [[IsExtensible]]
+ */
+addTest(function() {
+ assert_true(Object.isExtensible(C), "cross-origin Window should be extensible");
+ assert_true(Object.isExtensible(C.location), "cross-origin Location should be extensible");
+}, "[[IsExtensible]] should return true for cross-origin objects");
+
+/*
+ * [[PreventExtensions]]
+ */
+addTest(function() {
+ assert_throws(null, function() { Object.preventExtensions(C) },
+ "preventExtensions on cross-origin Window should throw");
+ assert_throws(null, function() { Object.preventExtensions(C.location) },
+ "preventExtensions on cross-origin Location should throw");
+}, "[[PreventExtensions]] should throw for cross-origin objects");
+
+/*
+ * [[GetOwnProperty]]
+ */
+
+addTest(function() {
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'close')), "C.close is |own|");
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'top')), "C.top is |own|");
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'href')), "C.location.href is |own|");
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'replace')), "C.location.replace is |own|");
+}, "[[GetOwnProperty]] - Properties on cross-origin objects should be reported |own|");
+
+function checkPropertyDescriptor(desc, propName, expectWritable) {
+ assert_true(isObject(desc), "property descriptor for " + propName + " should exist");
+ assert_equals(desc.enumerable, false, "property descriptor for " + propName + " should be non-enumerable");
+ assert_equals(desc.configurable, true, "property descriptor for " + propName + " should be configurable");
+ if ('value' in desc)
+ assert_equals(desc.writable, expectWritable, "property descriptor for " + propName + " should have writable: " + expectWritable);
+ else
+ assert_equals(typeof desc.set != 'undefined', expectWritable,
+ "property descriptor for " + propName + " should " + (expectWritable ? "" : "not ") + "have setter");
+}
+
+addTest(function() {
+ whitelistedWindowProps.forEach(function(prop) {
+ var desc = Object.getOwnPropertyDescriptor(C, prop);
+ checkPropertyDescriptor(desc, prop, prop == 'location');
+ });
+ checkPropertyDescriptor(Object.getOwnPropertyDescriptor(C.location, 'replace'), 'replace', false);
+ checkPropertyDescriptor(Object.getOwnPropertyDescriptor(C.location, 'href'), 'href', true);
+ assert_equals(typeof Object.getOwnPropertyDescriptor(C.location, 'href').get, 'undefined', "Cross-origin location should have no href getter");
+}, "[[GetOwnProperty]] - Property descriptors for cross-origin properties should be set up correctly");
+
+/*
+ * [[Delete]]
+ */
+addTest(function() {
+ assert_throws(null, function() { delete C.location; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.parent; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.length; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.document; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.foopy; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.location.href; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.location.replace; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.location.port; }, "Can't delete cross-origin property");
+ assert_throws(null, function() { delete C.location.foopy; }, "Can't delete cross-origin property");
+}, "[[Delete]] Should throw on cross-origin objects");
+
+/*
+ * [[DefineOwnProperty]]
+ */
+function checkDefine(obj, prop) {
+ var valueDesc = { configurable: true, enumerable: false, writable: false, value: 2 };
+ var accessorDesc = { configurable: true, enumerable: false, get: function() {} };
+ assert_throws(null, function() { Object.defineProperty(obj, prop, valueDesc); }, "Can't define cross-origin value property " + prop);
+ assert_throws(null, function() { Object.defineProperty(obj, prop, accessorDesc); }, "Can't define cross-origin accessor property " + prop);
+}
+addTest(function() {
+ checkDefine(C, 'length');
+ checkDefine(C, 'parent');
+ checkDefine(C, 'location');
+ checkDefine(C, 'document');
+ checkDefine(C, 'foopy');
+ checkDefine(C.location, 'href');
+ checkDefine(C.location, 'replace');
+ checkDefine(C.location, 'port');
+ checkDefine(C.location, 'foopy');
+}, "[[DefineOwnProperty]] Should throw for cross-origin objects");
+
+/*
+ * [[Enumerate]]
+ */
+
+addTest(function() {
+ for (var prop in C)
+ assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
+ for (var prop in C.location)
+ assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
+}, "[[Enumerate]] should return an empty iterator");
+
+/*
+ * [[OwnPropertyKeys]]
+ */
+
+addTest(function() {
+ assert_array_equals(whitelistedWindowProps.sort(), Object.getOwnPropertyNames(C).sort(),
+ "Object.getOwnPropertyNames() gives the right answer for cross-origin Window");
+ assert_array_equals(Object.getOwnPropertyNames(C.location).sort(), ['href', 'replace'],
+ "Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
+}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
+
+addTest(function() {
+ assert_true(B.eval('parent.C') === C, "A and B observe the same identity for C's Window");
+ assert_true(B.eval('parent.C.location') === C.location, "A and B observe the same identity for C's Location");
+}, "A and B jointly observe the same identity for cross-origin Window and Location");
+
+function checkFunction(f, proto) {
+ var name = f.name || '<missing name>';
+ assert_equals(typeof f, 'function', name + " is a function");
+ assert_equals(Object.getPrototypeOf(f), proto, f.name + " has the right prototype");
+}
+
+addTest(function() {
+ checkFunction(C.close, Function.prototype);
+ checkFunction(C.location.replace, Function.prototype);
+}, "Cross-origin functions get local Function.prototype");
+
+addTest(function() {
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
+ "Need to be able to use Object.getOwnPropertyDescriptor do this test");
+ checkFunction(Object.getOwnPropertyDescriptor(C, 'parent').get, Function.prototype);
+ checkFunction(Object.getOwnPropertyDescriptor(C.location, 'href').set, Function.prototype);
+}, "Cross-origin Window accessors get local Function.prototype");
+
+addTest(function() {
+ checkFunction(close, Function.prototype);
+ assert_true(close != B.close, 'same-origin Window functions get their own object');
+ assert_true(close != C.close, 'cross-origin Window functions get their own object');
+ var close_B = B.eval('parent.C.close');
+ assert_true(close != close_B, 'close_B is unique when viewed by the parent');
+ assert_true(close_B != C.close, 'different Window functions per-incumbent script settings object');
+ checkFunction(close_B, B.Function.prototype);
+
+ checkFunction(location.replace, Function.prototype);
+ assert_true(location.replace != C.location.replace, "cross-origin Location functions get their own object");
+ var replace_B = B.eval('parent.C.location.replace');
+ assert_true(replace_B != C.location.replace, 'different Location functions per-incumbent script settings object');
+ checkFunction(replace_B, B.Function.prototype);
+}, "Same-origin observers get different functions for cross-origin objects");
+
+addTest(function() {
+ assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
+ "Need to be able to use Object.getOwnPropertyDescriptor do this test");
+ var get_self_parent = Object.getOwnPropertyDescriptor(window, 'parent').get;
+ var get_parent_A = Object.getOwnPropertyDescriptor(C, 'parent').get;
+ var get_parent_B = B.eval('Object.getOwnPropertyDescriptor(parent.C, "parent").get');
+ assert_true(get_self_parent != get_parent_A, 'different Window accessors per-incumbent script settings object');
+ assert_true(get_parent_A != get_parent_B, 'different Window accessors per-incumbent script settings object');
+ checkFunction(get_self_parent, Function.prototype);
+ checkFunction(get_parent_A, Function.prototype);
+ checkFunction(get_parent_B, B.Function.prototype);
+}, "Same-origin obsevers get different accessors for cross-origin Window");
+
+addTest(function() {
+ var set_self_href = Object.getOwnPropertyDescriptor(window.location, 'href').set;
+ var set_href_A = Object.getOwnPropertyDescriptor(C.location, 'href').set;
+ var set_href_B = B.eval('Object.getOwnPropertyDescriptor(parent.C.location, "href").set');
+ assert_true(set_self_href != set_href_A, 'different Location accessors per-incumbent script settings object');
+ assert_true(set_href_A != set_href_B, 'different Location accessors per-incumbent script settings object');
+ checkFunction(set_self_href, Function.prototype);
+ checkFunction(set_href_A, Function.prototype);
+ checkFunction(set_href_B, B.Function.prototype);
+}, "Same-origin observers get different accessors for cross-origin Location");
+
+function doDocumentDomainTest(cb) {
+ window.addEventListener('message', function onmessage(evt) {
+ window.removeEventListener('message', onmessage);
+ test(function() {
+ var results = evt.data;
+ assert_true(results.length > 0, 'Need results');
+ results.forEach(function(r) { assert_true(r.pass, r.message); });
+ }, "Cross-origin object identity preserved across document.domain");
+ win.close();
+ cb();
+ });
+ var win = window.open('file_crossOriginObjects_documentDomain.html');
+}
+
+// We do a fresh load of the subframes for each test to minimize side-effects.
+// It would be nice to reload ourselves as well, but we can't do that without
+// disrupting the test harness.
+function runNextTest() {
+ var entry = testList.shift();
+ test(entry[0], entry[1]);
+ if (testList.length != 0)
+ reloadSubframes(runNextTest);
+ else
+ doDocumentDomainTest(done); // Asynchronous.
+}
+reloadSubframes(runNextTest);
+
+</script>
diff --git a/js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html b/js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html
new file mode 100644
index 000000000..e50b1f1bd
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test Cross-Compartment DOM WeakMaps</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<script type="application/javascript">
+
+var my_map = new WeakMap();
+
+function setup() {
+ var item = window.frames[0].document.querySelector("body");
+
+ my_map.set(item, "success_string");
+
+ var rule_fail = false;
+ try {
+ my_map.set(window.frames[0].document.styleSheets[0].cssRules[0], 1);
+ } catch (e) {
+ rule_fail = true;
+ }
+ ok(rule_fail, "Using rule as a weak map key across compartments should produce an exception because it can't be wrapper preserved.");
+}
+
+function runTest() {
+ setup();
+ SpecialPowers.forceGC();
+ SpecialPowers.forceCC();
+ SpecialPowers.forceGC();
+ SpecialPowers.forceCC();
+ var item = window.frames[0].document.querySelector("body");
+ is(my_map.get(item), "success_string", "Preserve reflectors used cross-compartment as weak map keys.");
+}
+
+</script>
+<iframe src="file_crosscompartment_weakmap.html" onload="runTest()"></iframe>
+
+
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_frameWrapping.html b/js/xpconnect/tests/mochitest/test_frameWrapping.html
new file mode 100644
index 000000000..7aecf1c3e
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_frameWrapping.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+No bug.
+-->
+<head>
+ <title>Test for Bug </title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** No bug for this test **/
+
+function go() {
+ var win = frames[0];
+ (function() {
+ var utils = SpecialPowers.getDOMWindowUtils(window);
+ is(utils.getClassName(win), "Proxy", "correctly wrap frame elements");
+ })()
+ SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+<iframe id="ifr" src="inner.html" onload="go()"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_getWebIDLCaller.html b/js/xpconnect/tests/mochitest/test_getWebIDLCaller.html
new file mode 100644
index 000000000..0627eb659
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_getWebIDLCaller.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=968335
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 968335</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 Cu.getCallerPrincipal (within JS-implemented WebIDL). **/
+
+ SimpleTest.waitForExplicitFinish();
+ SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]}, go);
+
+
+ function go() {
+ var t = new TestInterfaceJS();
+ is(t.getCallerPrincipal(), location.origin,
+ "Cu.getCallerPrincipal works right within JS-implemented WebIDL");
+
+ try {
+ SpecialPowers.Cu.getWebIDLCallerPrincipal();
+ ok(false, "Should have thrown");
+ } catch (e) {
+ ok(/NOT_AVAILABLE/.test(SpecialPowers.wrap(e)),
+ "API should throw when invoked outside of JS-implemented WebIDL");
+ }
+
+ SimpleTest.finish();
+ }
+
+
+
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968335">Mozilla Bug 968335</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_nac.xhtml b/js/xpconnect/tests/mochitest/test_nac.xhtml
new file mode 100644
index 000000000..0f18fe489
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_nac.xhtml
@@ -0,0 +1,64 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=914618
+-->
+<head>
+ <title>Test for Bug 914618</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="testBinding" chromeOnlyContent="true">
+ <!-- The root of the anonymous subtree is special, and is not allowed to
+ be adopted, among other things. Work with a child of the root. -->
+ <content><html:div><html:span id="nac">hidden text</html:span></html:div></content>
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ var nac = document.getAnonymousNodes(this)[0].firstChild;
+ win.is(nac.textContent, "hidden text", "XBL can see NAC");
+ win.playWithNAC(nac);
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 914618 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function checkThrows(fn) {
+ try {
+ fn();
+ ok(false, "Should have thrown");
+ } catch (e) {
+ ok(/denied|insecure|/.test(e), "Should have thrown security error");
+ }
+ }
+
+ function playWithNAC(nac) {
+ checkThrows(function() { nac.toString(); });
+ checkThrows(function() { nac.textContent; });
+ var iwin = document.getElementById('ifr').contentWindow;
+ iwin.nac = window.nac = nac;
+ checkThrows(new iwin.Function('nac.toString();'));
+ checkThrows(new iwin.Function('nac.textContent;'));
+
+ SimpleTest.finish();
+ }
+
+ ]]>
+</script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=914618">Mozilla Bug 914618</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<div id="bindingSink" style="-moz-binding: url(#testBinding);"></div>
+<iframe id="ifr"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html b/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html
new file mode 100644
index 000000000..1969e517c
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_sameOriginPolicy.html
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=801576
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 801576</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=801576">Mozilla Bug 801576</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for the same-origin policy. **/
+SimpleTest.waitForExplicitFinish();
+
+function check(obj, prop, allowed, write) {
+ var accessed = false;
+ try {
+ if (write) {
+ try {
+ obj[prop] = 2;
+ accessed = true;
+ } catch (e) {}
+ Object.defineProperty(obj, 'prop', {getter: function() {}, setter: null});
+ }
+ else
+ obj[prop];
+ accessed = true;
+ } catch (e) {}
+ is(accessed, allowed, prop + " is correctly (in)accessible for " + (write ? 'write' : 'read'));
+}
+
+var crossOriginReadableWindowProps = ['blur', 'close', 'closed', 'focus',
+ 'frames', 'location', 'length',
+ 'opener', 'parent', 'postMessage',
+ 'self', 'top', 'window',
+ /* indexed and named accessors */
+ '0', 'subframe'];
+
+function isCrossOriginReadable(obj, prop) {
+ if (obj == "Window")
+ return crossOriginReadableWindowProps.indexOf(prop) != -1;
+ if (obj == "Location")
+ return prop == 'replace';
+ return false;
+}
+
+function isCrossOriginWritable(obj, prop) {
+ if (obj == "Window")
+ return prop == 'location';
+ if (obj == "Location")
+ return prop == 'href';
+}
+
+// NB: we don't want to succeed with writes, so we only check them when it should be denied.
+function testAll(sameOrigin) {
+ var win = document.getElementById('ifr').contentWindow;
+
+ // Build a list of properties to check from the properties available on our
+ // window.
+ var props = [];
+ for (var prop in window) { props.push(prop); }
+
+ // On android, this appears to be on the window but not on the iframe. It's
+ // not really relevant to this test, so just skip it.
+ if (props.indexOf('crypto') != -1)
+ props.splice(props.indexOf('crypto'), 1);
+
+ // Add the named grand-child, since that won't appear on our window.
+ props.push('subframe');
+
+ for (var prop of props) {
+ check(win, prop, sameOrigin || isCrossOriginReadable('Window', prop), /* write = */ false);
+ if (!sameOrigin && !isCrossOriginWritable('Window', prop))
+ check(win, prop, false, /* write = */ true);
+ }
+ for (var prop in window.location) {
+ check(win.location, prop, sameOrigin || isCrossOriginReadable('Location', prop));
+ if (!sameOrigin && !isCrossOriginWritable('Location', prop))
+ check(win.location, prop, false, /* write = */ true);
+ }
+}
+
+var loadCount = 0;
+function go() {
+ ++loadCount;
+ if (loadCount == 1) {
+ testAll(true);
+ document.getElementById('ifr').contentWindow.location = 'http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html';
+ }
+ else {
+ is(loadCount, 2);
+ testAll(false);
+ SimpleTest.finish();
+ }
+}
+
+</script>
+</pre>
+<iframe id="ifr" onload="go();" src="file_empty.html"></iframe>
+</body>
+</html>
diff --git a/js/xpconnect/tests/mochitest/test_sandbox_fetch.html b/js/xpconnect/tests/mochitest/test_sandbox_fetch.html
new file mode 100644
index 000000000..b206efdb8
--- /dev/null
+++ b/js/xpconnect/tests/mochitest/test_sandbox_fetch.html
@@ -0,0 +1,54 @@
+<!doctype html>
+<html>
+<head>
+ <title>Fetch in JS Sandbox</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
+ <script src="test_fetch_basic.js"></script>
+</head>
+<body>
+<script type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function testHttpFetch(url) {
+ info('fetch: ' + url);
+ return fetch(new Request(url, { method: 'GET' }))
+ .then(response => {
+ is(response.status, 200, 'Response is 200');
+ is(response.url, url, 'Response URL matches');
+ });
+}
+
+function runSandboxTest(testFunc, argString) {
+ is(typeof testFunc, 'function');
+ var resolvePromise;
+ var testPromise = new Promise(r => resolvePromise = r);
+ var finishFuncName = 'finish_' + testFunc.name;
+ SpecialPowers.Cu.exportFunction(_ => resolvePromise(), sb,
+ { defineAs: finishFuncName });
+ SpecialPowers.Cu.evalInSandbox('(' + testFunc.toSource() + ')' +
+ '(' + argString + ')' +
+ '.then(' + finishFuncName + ');', sb);
+ return testPromise;
+}
+
+var origin = 'https://example.com';
+var properties = ['fetch', 'Blob', 'URL'];
+var sb = new SpecialPowers.Cu.Sandbox(origin,
+ { wantGlobalProperties: properties });
+
+sb.ok = SpecialPowers.Cu.exportFunction(ok, sb);
+sb.is = SpecialPowers.Cu.exportFunction(is, sb);
+sb.info = SpecialPowers.Cu.exportFunction(info, sb);
+
+Promise.resolve()
+ .then(_ => runSandboxTest(testHttpFetch, '"' + origin + window.location.pathname + '"'))
+ .then(_ => runSandboxTest(testAboutURL))
+ .then(_ => runSandboxTest(testDataURL))
+ .then(_ => runSandboxTest(testSameOriginBlobURL))
+ .then(_ => SimpleTest.finish());
+
+</script>
+</body>
+</html>