summaryrefslogtreecommitdiffstats
path: root/dom/xbl/test
diff options
context:
space:
mode:
Diffstat (limited to 'dom/xbl/test')
-rw-r--r--dom/xbl/test/bug310107-resource.xhtml21
-rw-r--r--dom/xbl/test/chrome.ini15
-rw-r--r--dom/xbl/test/file_bug372769.xhtml181
-rw-r--r--dom/xbl/test/file_bug379959_cross.html32
-rw-r--r--dom/xbl/test/file_bug379959_data.html20
-rw-r--r--dom/xbl/test/file_bug379959_xbl.xml4
-rw-r--r--dom/xbl/test/file_bug397934.xhtml117
-rw-r--r--dom/xbl/test/file_bug481558.xbl14
-rw-r--r--dom/xbl/test/file_bug481558css.sjs17
-rw-r--r--dom/xbl/test/file_bug591198_inner.html38
-rw-r--r--dom/xbl/test/file_bug591198_xbl.xml5
-rw-r--r--dom/xbl/test/file_bug821850.xhtml299
-rw-r--r--dom/xbl/test/file_bug844783.xhtml54
-rw-r--r--dom/xbl/test/file_bug944407.html8
-rw-r--r--dom/xbl/test/file_bug944407.xml76
-rw-r--r--dom/xbl/test/file_bug946815.xhtml97
-rw-r--r--dom/xbl/test/file_bug950909.html8
-rw-r--r--dom/xbl/test/file_bug950909.xml37
-rw-r--r--dom/xbl/test/file_fieldScopeChain.xml8
-rw-r--r--dom/xbl/test/mochitest.ini43
-rw-r--r--dom/xbl/test/test_bug1086996.xhtml62
-rw-r--r--dom/xbl/test/test_bug1098628_throw_from_construct.xhtml40
-rw-r--r--dom/xbl/test/test_bug1359859.xhtml41
-rw-r--r--dom/xbl/test/test_bug310107.html53
-rw-r--r--dom/xbl/test/test_bug366770.html41
-rw-r--r--dom/xbl/test/test_bug371724.xhtml58
-rw-r--r--dom/xbl/test/test_bug372769.html34
-rw-r--r--dom/xbl/test/test_bug378518.xul83
-rw-r--r--dom/xbl/test/test_bug378866.xhtml57
-rw-r--r--dom/xbl/test/test_bug379959.html69
-rw-r--r--dom/xbl/test/test_bug389322.xhtml126
-rw-r--r--dom/xbl/test/test_bug397934.html34
-rw-r--r--dom/xbl/test/test_bug398135.xul135
-rw-r--r--dom/xbl/test/test_bug398492.xul91
-rw-r--r--dom/xbl/test/test_bug400705.xhtml48
-rw-r--r--dom/xbl/test/test_bug401907.xhtml58
-rw-r--r--dom/xbl/test/test_bug403162.xhtml57
-rw-r--r--dom/xbl/test/test_bug468210.xhtml51
-rw-r--r--dom/xbl/test/test_bug481558.html38
-rw-r--r--dom/xbl/test/test_bug526178.xhtml80
-rw-r--r--dom/xbl/test/test_bug542406.xhtml44
-rw-r--r--dom/xbl/test/test_bug591198.html46
-rw-r--r--dom/xbl/test/test_bug639338.xhtml66
-rw-r--r--dom/xbl/test/test_bug721452.xul25
-rw-r--r--dom/xbl/test/test_bug723676.xul25
-rw-r--r--dom/xbl/test/test_bug772966.xul42
-rw-r--r--dom/xbl/test/test_bug790265.xhtml55
-rw-r--r--dom/xbl/test/test_bug821850.html37
-rw-r--r--dom/xbl/test/test_bug844783.html38
-rw-r--r--dom/xbl/test/test_bug872273.xhtml53
-rw-r--r--dom/xbl/test/test_bug944407.xul44
-rw-r--r--dom/xbl/test/test_bug950909.xul36
-rw-r--r--dom/xbl/test/test_fieldScopeChain.html34
53 files changed, 2895 insertions, 0 deletions
diff --git a/dom/xbl/test/bug310107-resource.xhtml b/dom/xbl/test/bug310107-resource.xhtml
new file mode 100644
index 000000000..2a3f1df35
--- /dev/null
+++ b/dom/xbl/test/bug310107-resource.xhtml
@@ -0,0 +1,21 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <style>
+ #bar {
+ -moz-binding: url("#binding");
+ }
+ </style>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="binding">
+ <implementation>
+ <property name="prop" readonly="true" exposeToUntrustedContent="true"
+ onget="return 2;"/>
+ </implementation>
+ </binding>
+ </bindings>
+ </head>
+ <!-- Use a timeout so that we get bfcached -->
+ <body onload="setTimeout(window.opener.runTest, 100)">
+ <div id="bar"></div>
+ </body>
+</html>
diff --git a/dom/xbl/test/chrome.ini b/dom/xbl/test/chrome.ini
new file mode 100644
index 000000000..40606de12
--- /dev/null
+++ b/dom/xbl/test/chrome.ini
@@ -0,0 +1,15 @@
+[DEFAULT]
+support-files =
+ file_bug944407.xml
+ file_bug950909.xml
+ file_fieldScopeChain.xml
+
+[test_bug378518.xul]
+[test_bug398135.xul]
+[test_bug398492.xul]
+[test_bug721452.xul]
+[test_bug723676.xul]
+[test_bug772966.xul]
+[test_bug944407.xul]
+[test_bug950909.xul]
+[test_fieldScopeChain.html]
diff --git a/dom/xbl/test/file_bug372769.xhtml b/dom/xbl/test/file_bug372769.xhtml
new file mode 100644
index 000000000..79a36be85
--- /dev/null
+++ b/dom/xbl/test/file_bug372769.xhtml
@@ -0,0 +1,181 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=372769
+-->
+<head>
+ <title>Test for Bug 372769</title>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="test1">
+ <implementation>
+ <field name="one">1</field>
+ <field name="two">9</field>
+ <field name="three">3</field>
+ <field name="four">10</field>
+ <field name="five">11</field>
+ <field name="six">this.four = 4; 6;</field>
+ <field name="seven">this.five = 5; 7;</field>
+ </implementation>
+ </binding>
+
+ <binding id="test2">
+ <implementation>
+ <!-- Tests for recursive resolves -->
+ <field name="eight">this.eight</field>
+ <field name="nine">this.ten</field>
+ <field name="ten">this.nine</field>
+ <!-- Tests for non-DOM overrides -->
+ <field name="eleven">11</field>
+ <field name="twelve">12</field>
+ <!-- Tests for DOM overrides -->
+ <field name="parentNode">this.parentNode</field>
+ <field name="ownerDocument">"ownerDocument override"</field>
+ </implementation>
+ </binding>
+
+ <binding id="test3-ancestor">
+ <implementation>
+ <field name="thirteen">"13 ancestor"</field>
+ <field name="fourteen">"14 ancestor"</field>
+ <property name="fifteen" readonly="true" onget="return '15 ancestor'"/>
+ </implementation>
+ </binding>
+
+ <binding id="test3" extends="#test3-ancestor">
+ <implementation>
+ <field name="thirteen">13</field>
+ <field name="fifteen">15</field>
+ <field name="sixteen">16</field>
+ <field name="sixteen">"16 later"</field>
+ <field name="seventeen">17</field>
+ <field name="eighteen">"18 field"</field>
+ <property name="eighteen" readonly="true" onget="return 18"/>
+ <property name="nineteen" readonly="true" onget="return 19"/>
+ <field name="nineteen">"19 field"</field>
+ </implementation>
+ </binding>
+
+ <binding id="test4">
+ <implementation>
+ <field name="twenty">for (var i in this) ; 20;</field>
+ </implementation>
+ </binding>
+
+ <binding id="test5">
+ <implementation>
+ <field name="twenty-one">for (var i in this) ; 21;</field>
+ </implementation>
+ </binding>
+</bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372769">Mozilla Bug 372769</a>
+<p id="display1" style="-moz-binding: url(#test1)"></p>
+<p id="display2" style="-moz-binding: url(#test2)"></p>
+<p id="display3" style="-moz-binding: url(#test3)"></p>
+<p id="display4" style="-moz-binding: url(#test4)"></p>
+<p id="display5" style="-moz-binding: url(#test5)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+/** Test for Bug 372769 **/
+
+SimpleTest = parent.SimpleTest;
+ok = parent.ok;
+is = parent.is;
+$ = function(x) { return document.getElementById(x); }
+
+window.onload = function() {
+ var d = $("display1");
+ is(d.one, 1, "Should be able to read field");
+
+ d.two = 2;
+ is(d.two, 2, "Should be able to write field");
+
+ is("three" in d, true, 'Should have a property named "three"');
+ is(d.three, 3, "Should be 3");
+
+ is(d.four, 10, "Unexpected value so far");
+
+ // Save "five" for now
+
+ is(d.six, 6, "Should be 6");
+
+ is(d.four, 4, "Now should be 4");
+
+ d.four = 9;
+ is(d.four, 9, "Just set it to 9");
+
+ var found = false;
+ for (var prop in d) {
+ if (prop == "seven") {
+ found = true;
+ break;
+ }
+ }
+ is(found, true, "Enumeration is broken");
+
+ is(d.four, 9, "Shouldn't have rerun field six");
+ is(d.five, 11, "Shouldn't have run field 7");
+ is(d.seven, 7, "Should be 7")
+ is(d.five, 5, "Should have run field 7");
+
+ d = $("display2");
+ is(typeof(d.eight), "undefined", "Recursive resolve should bail out");
+ is(typeof(d.nine), "undefined", "Recursive double resolve should bail out");
+ is(typeof(d.ten), "undefined",
+ "This recursive double resolve should bail out too");
+
+ // Get .eleven so it's resolved now
+ is(d.eleven, 11, "Unexpected value for .eleven");
+ var newProto = {};
+ newProto.eleven = "Proto 11";
+ newProto.twelve = "Proto 12";
+ newProto.__proto__ = d.__proto__;
+ d.__proto__ = newProto;
+ is(d.eleven, 11, "Proto should not have affected this");
+ is(d.twelve, "Proto 12", "Proto should have overridden 'twelve'");
+
+ is(d.parentNode, undefined, "We overrode this, yes we did");
+ is(typeof(d.parentNode), "undefined", "This is a recursive resolve too");
+ is(d.ownerDocument, "ownerDocument override",
+ "Should have overridden ownerDocument");
+
+ d = $("display3");
+ is(d.thirteen, 13, "descendant should win here");
+ is(d.fourteen, "14 ancestor",
+ "ancestor should win if descendant does nothing")
+ is(d.fifteen, 15,
+ "Field beats ancestor's property, since the latter lives on higher proto")
+ is(d.sixteen, 16, "First field wins");
+ is(d.__proto__.seventeen, undefined, "Shouldn't have this on proto");
+ is(typeof(d.__proto__.seventeen), "undefined",
+ "Really, should be undefined");
+ is(d.seventeen, 17, "Should have this prop on the node itself, though");
+ is(d.eighteen, 18, "Property beats field");
+ is(d.nineteen, 19, "Property still beats field");
+
+ d = $("display4");
+ is(d.twenty, 20, "Should be 20");
+
+ d = $("display5");
+ found = false;
+ for (var prop2 in d) {
+ if (prop2 == "twenty-one") {
+ found = true;
+ break;
+ }
+ }
+ is(found, true, "Enumeration is broken");
+ is(d["twenty-one"], 21, "Should be 21");
+ SimpleTest.finish();
+}
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/file_bug379959_cross.html b/dom/xbl/test/file_bug379959_cross.html
new file mode 100644
index 000000000..80e2be97d
--- /dev/null
+++ b/dom/xbl/test/file_bug379959_cross.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+#div1 {
+ color: green;
+ -moz-binding: url(file_bug379959_xbl.xml#xbltest);
+}
+#div2 {
+ color: green;
+ -moz-binding: url(http://example.com/tests/dom/xbl/test/file_bug379959_xbl.xml#xbltest);
+}
+</style>
+<body>
+<div id="div1"></div>
+<div id="div2"></div>
+<script>
+onload = function() {
+ // same origin should be allowed
+ var nodes1 = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('div1'));
+ parent.postMessage({test: "sameOriginIsAllowed",
+ result: nodes1 ? nodes1.length : 0,
+ senderURL: "http://mochi.test:8888"}, "*");
+
+ // cross origin should be blocked
+ var nodes2 = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('div2'));
+ parent.postMessage({test: "crossOriginIsBlocked",
+ result: nodes2 ? nodes2.length : 0,
+ senderURL: "http://mochi.test:8888"}, "*");
+}
+</script>
+</html>
diff --git a/dom/xbl/test/file_bug379959_data.html b/dom/xbl/test/file_bug379959_data.html
new file mode 100644
index 000000000..64fe3e45a
--- /dev/null
+++ b/dom/xbl/test/file_bug379959_data.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+#d {
+ color: green;
+ -moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%0A%3Cbindings%20id%3D%22xbltestBindings%22%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%3E%0A%20%20%3Cbinding%20id%3D%22xbltest%22%3E%3Ccontent%3EPASS%3C/content%3E%3C/binding%3E%0A%3C/bindings%3E%0A);
+}
+</style>
+<body>
+<div id="d"></div>
+<script>
+onload = function() {
+ var nodes = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('d'));
+ parent.postMessage({test: "dataIsAllowed",
+ result: nodes ? nodes.length : 0,
+ senderURL: "http://mochi.test:8888"}, "*");
+}
+</script>
+</html>
diff --git a/dom/xbl/test/file_bug379959_xbl.xml b/dom/xbl/test/file_bug379959_xbl.xml
new file mode 100644
index 000000000..c791a2e2b
--- /dev/null
+++ b/dom/xbl/test/file_bug379959_xbl.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<bindings id="xbltestBindings" xmlns="http://www.mozilla.org/xbl">
+ <binding id="xbltest"><content>PASS</content></binding>
+</bindings>
diff --git a/dom/xbl/test/file_bug397934.xhtml b/dom/xbl/test/file_bug397934.xhtml
new file mode 100644
index 000000000..c8505aab4
--- /dev/null
+++ b/dom/xbl/test/file_bug397934.xhtml
@@ -0,0 +1,117 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=397934
+-->
+<head>
+ <title>Test for Bug 397934</title>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="ancestor">
+ <implementation>
+ <field name="testAncestor">"ancestor"</field>
+ </implementation>
+ </binding>
+ <binding id="test1" extends="#ancestor">
+ <implementation>
+ <constructor>
+ this.storage = window;
+ </constructor>
+ <field name="window"></field>
+ <field name="storage">null</field>
+ <field name="parentNode"></field>
+ <field name="ownerDocument">"ownerDocument"</field>
+ <field name="emptyTest1"></field>
+ <field name="emptyTest1">"empty1"</field>
+ <field name="emptyTest2">"empty2"</field>
+ <field name="emptyTest2"></field>
+ <field name="testAncestor"></field>
+ <field name="testEvalOnce">XPCNativeWrapper.unwrap(window).counter++; undefined</field>
+ </implementation>
+ </binding>
+ <binding id="test2" extends="#ancestor">
+ <implementation>
+ <constructor>
+ this.storage = window;
+ </constructor>
+ <field name="window">undefined</field>
+ <field name="storage">null</field>
+ <field name="parentNode">undefined</field>
+ <field name="ownerDocument">"ownerDocument"</field>
+ <field name="emptyTest1">undefined</field>
+ <field name="emptyTest1">"empty1"</field>
+ <field name="emptyTest2">"empty2"</field>
+ <field name="emptyTest2">undefined</field>
+ <field name="testAncestor">undefined</field>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=397934">Mozilla Bug 397934</a>
+<p id="display1" style="-moz-binding: url(#test1)"></p>
+<p id="display2" style="-moz-binding: url(#test2)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+/** Test for Bug 397934 **/
+SimpleTest = parent.SimpleTest;
+ok = parent.ok;
+is = parent.is;
+$ = function(x) { return document.getElementById(x); }
+window.onload = function() {
+ var d;
+ d = $("display1");
+ is(d.storage, window,
+ "test1" +
+ ": |window| in the constructor should have resolved to our window");
+ is(d.ownerDocument, "ownerDocument",
+ "test1" + ": Control to test field overriding DOM prop");
+ is(d.parentNode, document.body, "test1" + ": unexpected parent");
+ is(d.emptyTest1, undefined,
+ "test1" + ": First field wins even if undefined");
+ is(typeof(d.emptyTest1), "undefined",
+ "test1" + ": First field wins even if undefined, double-check");
+ is(d.emptyTest2, "empty2",
+ "test1" + ": First field wins");
+ is(d.testAncestor, "ancestor",
+ "test1" + ": Empty field should not override ancestor binding");
+
+ var win = window;
+ win.counter = 0;
+ d.testEvalOnce;
+ d.testEvalOnce;
+ is(win.counter, 1, "Field should have evaluated once and only once");
+
+ d = $("display2");
+ is(d.storage, undefined,
+ "test2" +
+ ": |window| in the constructor should have resolved to undefined");
+ is(typeof(d.storage), "undefined",
+ "test2" +
+ ": |window| in the constructor should really have resolved to undefined");
+ is(d.ownerDocument, "ownerDocument",
+ "test2" + ": Control to test field overriding DOM prop");
+ is(d.parentNode, undefined, "test2" + ": unexpected parent");
+ is(typeof(d.parentNode), "undefined", "test2" + ": unexpected parent for real");
+ is(d.emptyTest1, undefined,
+ "test2" + ": First field wins even if undefined");
+ is(typeof(d.emptyTest1), "undefined",
+ "test2" + ": First field wins even if undefined, double-check");
+ is(d.emptyTest2, "empty2",
+ "test2" + ": First field wins");
+ is(d.testAncestor, undefined,
+ "test2" + ": Undefined field should override ancestor binding");
+ is(typeof(d.testAncestor), "undefined",
+ "test2" + ": Undefined field should really override ancestor binding");
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/file_bug481558.xbl b/dom/xbl/test/file_bug481558.xbl
new file mode 100644
index 000000000..f9ae7be1c
--- /dev/null
+++ b/dom/xbl/test/file_bug481558.xbl
@@ -0,0 +1,14 @@
+<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xbl="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+<binding id="test">
+ <content>
+ <children/>
+ Binding Attached
+ </content>
+ <implementation>
+ <property name="xblBoundProperty" onget="return 1;"
+ exposeToUntrustedContent="true"/>
+ </implementation>
+</binding>
+</bindings>
diff --git a/dom/xbl/test/file_bug481558css.sjs b/dom/xbl/test/file_bug481558css.sjs
new file mode 100644
index 000000000..a44cb9c95
--- /dev/null
+++ b/dom/xbl/test/file_bug481558css.sjs
@@ -0,0 +1,17 @@
+function handleRequest(request, response)
+{
+ var query = {};
+ request.queryString.split('&').forEach(function (val) {
+ [name, value] = val.split('=');
+ query[name] = unescape(value);
+ });
+
+ response.setHeader("Content-Type", "text/css", false);
+ css = "#" + query.id + " { -moz-binding: url(\"";
+ if (query.server) {
+ css += "http://" + query.server + "/tests/dom/xbl/test/";
+ }
+ css += "file_bug481558.xbl#test\"); }";
+
+ response.write(css);
+}
diff --git a/dom/xbl/test/file_bug591198_inner.html b/dom/xbl/test/file_bug591198_inner.html
new file mode 100644
index 000000000..89b547a39
--- /dev/null
+++ b/dom/xbl/test/file_bug591198_inner.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <style>
+ #b {
+ -moz-binding: url("file_bug591198_xbl.xml#xbltest");
+ }
+ span {
+ white-space: nowrap;
+ }
+ </style>
+ <script>
+function sendResults() {
+ var res = {
+ widths: []
+ };
+
+ ps = document.getElementsByTagName('span');
+ for (var i = 0; i < ps.length; i++) {
+ res.widths.push(ps[i].offsetWidth);
+ }
+
+ try {
+ res.anonChildCount =
+ SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('b')).length;
+ }
+ catch (ex) {}
+
+ parent.postMessage(JSON.stringify(res), "*");
+}
+ </script>
+ </head>
+ <body onload="sendResults();">
+ <div><span id=b>long long text here</span></div>
+ <div><span>long long text here</span></div>
+ <div><span>PASS</span></div>
+ </body>
+</html>
diff --git a/dom/xbl/test/file_bug591198_xbl.xml b/dom/xbl/test/file_bug591198_xbl.xml
new file mode 100644
index 000000000..f69959b47
--- /dev/null
+++ b/dom/xbl/test/file_bug591198_xbl.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<bindings id="xbltestBindings" xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="xbltest"><content>PASS<html:b style="display:none"><children/></html:b></content></binding>
+</bindings>
diff --git a/dom/xbl/test/file_bug821850.xhtml b/dom/xbl/test/file_bug821850.xhtml
new file mode 100644
index 000000000..0d68a908f
--- /dev/null
+++ b/dom/xbl/test/file_bug821850.xhtml
@@ -0,0 +1,299 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=821850
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="testBinding">
+ <implementation>
+ <constructor>
+ // Store a property as an expando on the bound element.
+ this._prop = "propVal";
+
+ // Wait for both constructors to fire.
+ window.constructorCount = (window.constructorCount + 1) || 1;
+ if (window.constructorCount != 3)
+ return;
+
+ // Grab some basic infrastructure off the content window.
+ var win = XPCNativeWrapper.unwrap(window);
+ SpecialPowers = win.SpecialPowers;
+ Cu = SpecialPowers.Cu;
+ is = win.is;
+ ok = win.ok;
+ SimpleTest = win.SimpleTest;
+
+ // Stick some expandos on the content window.
+ window.xrayExpando = 3;
+ win.primitiveExpando = 11;
+ win.stringExpando = "stringExpando";
+ win.objectExpando = { foo: 12 };
+ win.globalExpando = SpecialPowers.unwrap(Cu.getGlobalForObject({}));
+ win.functionExpando = function() { return "called" };
+ win.functionExpando.prop = 2;
+
+ // Make sure we're Xraying.
+ ok(Cu.isXrayWrapper(window), "Window is Xrayed");
+ ok(Cu.isXrayWrapper(document), "Document is Xrayed");
+
+ var bound = document.getElementById('bound');
+ var bound2 = document.getElementById('bound2');
+ var bound3 = document.getElementById('bound3');
+ ok(bound, "bound is non-null");
+ is(bound.method('baz'), "method:baz", "Xray methods work");
+ is(bound.prop, "propVal", "Property Xrays work");
+ is(bound.primitiveField, undefined, "Xrays don't show fields");
+ is(bound.wrappedJSObject.primitiveField, 2, "Waiving Xrays show fields");
+
+ // Check exposure behavior.
+ is(typeof bound.unexposedMethod, 'function',
+ "Unexposed method should be visible to XBL");
+ is(typeof bound.wrappedJSObject.unexposedMethod, 'undefined',
+ "Unexposed method should not be defined in content");
+ is(typeof bound.unexposedProperty, 'number',
+ "Unexposed property should be visible to XBL");
+ is(typeof bound.wrappedJSObject.unexposedProperty, 'undefined',
+ "Unexposed property should not be defined in content");
+
+ // Check that here HTMLImageElement.QueryInterface works
+ var img = document.querySelector("img");
+ ok("QueryInterface" in img,
+ "Should have a img.QueryInterface here");
+ is(img.QueryInterface(Components.interfaces.nsIImageLoadingContent),
+ img, "Should be able to QI the image");
+
+ // Make sure standard constructors work right in the presence of
+ // sandboxPrototype and Xray-resolved constructors.
+ is(window.Function, XPCNativeWrapper(window.wrappedJSObject.Function),
+ "window.Function comes from the window, not the global");
+ ok(Function != window.Function, "Function constructors are distinct");
+ is(Object.getPrototypeOf(Function.prototype), Object.getPrototypeOf({foo: 42}),
+ "Function constructor is local");
+
+ ok(Object.getPrototypeOf(bound.wrappedJSObject) == Object.getPrototypeOf(bound2.wrappedJSObject),
+ "Div and div should have the same content-side prototype");
+ ok(Object.getPrototypeOf(bound.wrappedJSObject) != Object.getPrototypeOf(bound3.wrappedJSObject),
+ "Div and span should have different content-side prototypes");
+ ok(bound.wrappedJSObject.method == bound3.wrappedJSObject.method,
+ "Methods should be shared");
+
+ // This gets invoked by an event handler.
+ window.finish = function() {
+ // Content messed with stuff. Make sure we still see the right thing.
+ is(bound.method('bay'), "method:bay", "Xray methods work");
+ is(bound.wrappedJSObject.method('bay'), "hah", "Xray waived methods work");
+ is(bound.prop, "set:someOtherVal", "Xray props work");
+ is(bound.wrappedJSObject.prop, "redefined", "Xray waived props work");
+ is(bound.wrappedJSObject.primitiveField, 321, "Can't do anything about redefined fields");
+
+ SimpleTest.finish();
+ }
+
+ // Hand things off to content. Content will call us back.
+ win.go();
+ </constructor>
+ <field name="primitiveField">2</field>
+ <method name="unexposedMethod"><body></body></method>
+ <property name="unexposedProperty" onget="return 2;" readonly="true"></property>
+ <method name="method" exposeToUntrustedContent="true">
+ <parameter name="arg" />
+ <body>
+ return "method:" + arg;
+ </body>
+ </method>
+ <method name="passMeAJSObject" exposeToUntrustedContent="true">
+ <parameter name="arg" />
+ <body>
+ is(typeof arg.prop, 'undefined', "No properties");
+ is(arg.wrappedJSObject.prop, 2, "Underlying object has properties");
+ is(Object.getOwnPropertyNames(arg).length, 0, "Should have no own properties");
+ is(Object.getOwnPropertyNames(arg.wrappedJSObject).length, 1, "Underlying object has properties");
+ arg.foo = 2;
+ is(arg.foo, 2, "Should place expandos");
+ is(typeof arg.wrappedJSObject.foo, 'undefined', "Expandos should be invisible to content");
+ </body>
+ </method>
+ <property name="prop" exposeToUntrustedContent="true">
+ <getter>return this._prop;</getter>
+ <setter>this._prop = "set:" + val;</setter>
+ </property>
+ </implementation>
+ <handlers>
+ <handler event="testevent" action="ok(true, 'called event handler'); finish();" allowuntrusted="true"/>
+ <handler event="testtrusted" action="ok(true, 'called trusted handler'); window.wrappedJSObject.triggeredTrustedHandler = true;"/>
+ <handler event="keyup" action="ok(true, 'called untrusted key handler'); window.wrappedJSObject.triggeredUntrustedKeyHandler = true;" allowuntrusted="true"/>
+ <handler event="keydown" action="ok(true, 'called trusted key handler'); window.wrappedJSObject.triggeredTrustedKeyHandler = true;"/>
+ </handlers>
+ </binding>
+ </bindings>
+ <script type="application/javascript">
+ <![CDATA[
+
+ ok = parent.ok;
+ is = parent.is;
+ SimpleTest = parent.SimpleTest;
+ SpecialPowers = parent.SpecialPowers;
+
+ // Test the Xray waiving behavior when accessing fields. We should be able to
+ // see sequential JS-implemented properties, but should regain Xrays when we
+ // hit a native property.
+ window.contentVal = { foo: 10, rabbit: { hole: { bar: 100, win: window} } };
+ ok(true, "Set contentVal");
+
+ // Check that we're not exposing QueryInterface to non-XBL code
+ ok(!("QueryInterface" in document),
+ "Should not have a document.QueryInterface here");
+
+ function go() {
+ "use strict";
+
+ // Test what we can and cannot access in the XBL scope.
+ is(typeof window.xrayExpando, "undefined", "Xray expandos are private to the caller");
+ is(window.primitiveExpando, 11, "Can see waived expandos");
+ is(window.stringExpando, "stringExpando", "Can see waived expandos");
+ is(typeof window.objectExpando, "object", "object expando exists");
+ checkThrows(() => window.objectExpando.foo);
+ is(SpecialPowers.wrap(window.objectExpando).foo, 12, "SpecialPowers sees the right thing");
+ is(typeof window.globalExpando, "object", "Can see global object");
+ checkThrows(() => window.globalExpando.win);
+ is(window.functionExpando(), "called", "XBL functions are callable");
+ checkThrows(() => window.functionExpando.prop);
+
+ // Inspect the bound element.
+ var bound = document.getElementById('bound');
+ is(bound.primitiveField, 2, "Can see primitive fields");
+ is(bound.method("foo"), "method:foo", "Can invoke XBL method from content");
+ is(bound.prop, "propVal", "Can access properties from content");
+ bound.prop = "someOtherVal";
+ is(bound.prop, "set:someOtherVal", "Can set properties from content");
+
+ // Make sure that XBL scopes get opaque wrappers.
+ //
+ // Note: Now that we have object Xrays, we have to pass in a more obscure
+ // ES type that we don't Xray to test this.
+ var proto = bound.__proto__;
+ var nonXrayableObject = new WeakMap();
+ nonXrayableObject.prop = 2;
+ proto.passMeAJSObject(nonXrayableObject);
+
+ //
+ // Try sticking a bunch of stuff on the prototype object.
+ //
+
+ proto.someExpando = 201;
+ is(bound.someExpando, 201, "Can stick non-XBL properties on the proto");
+
+ // Previously, this code checked that content couldn't tamper with its XBL
+ // prototype. But we decided to allow this to reduce regression risk, so for
+ // now just check that this works.
+ function checkMayTamper(obj, propName, desc) {
+ var accessor = !('value' in Object.getOwnPropertyDescriptor(obj, propName));
+ if (!accessor)
+ checkAllowed(function() { obj[propName] = function() {} }, desc + ": assign");
+ checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, value: 3}) }, desc + ": define with value");
+ checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, writable: true}) }, desc + ": make writable");
+ checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true}) }, desc + ": make configurable");
+ checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, get: function() {}}) }, desc + ": define with getter");
+ checkAllowed(function() { Object.defineProperty(obj, propName, {configurable: true, set: function() {}}) }, desc + ": define with setter");
+
+ // Windows are implemented as proxies, and Proxy::delete_ doesn't currently
+ // pass strict around. Work around it in the window.binding case by just
+ // checking if delete returns false.
+ // manually.
+ checkAllowed(function() { delete obj[propName]; }, desc + ": delete");
+
+ if (!accessor)
+ checkAllowed(function() { obj[propName] = function() {} }, desc + ": assign (again)");
+ }
+
+ // Make sure content can do whatever it wants with the prototype.
+ checkMayTamper(proto, 'method', "XBL Proto Method");
+ checkMayTamper(proto, 'prop', "XBL Proto Prop");
+ checkMayTamper(proto, 'primitiveField', "XBL Field Accessor");
+
+ // Tamper with the derived object. This doesn't affect the XBL scope thanks
+ // to Xrays.
+ bound.method = function() { return "heh"; };
+ Object.defineProperty(bound, 'method', {value: function() { return "hah" }});
+ Object.defineProperty(bound, 'prop', {value: "redefined"});
+ bound.primitiveField = 321;
+
+ // Untrusted events should not trigger event handlers without
+ // exposeToUntrustedContent=true.
+ window.triggeredTrustedHandler = false;
+ var untrustedEvent = new CustomEvent('testtrusted');
+ is(untrustedEvent.type, 'testtrusted', "Constructor should see type");
+ bound.dispatchEvent(untrustedEvent);
+ ok(!window.triggeredTrustedHandler, "untrusted events should not trigger trusted handler");
+ var trustedEvent = new CustomEvent('testtrusted');
+ is(trustedEvent.type, 'testtrusted', "Wrapped constructor should see type");
+ SpecialPowers.wrap(bound).dispatchEvent(trustedEvent); // Dispatch over SpecialPowers to make the event trusted.
+ ok(window.triggeredTrustedHandler, "trusted events should trigger trusted handler");
+
+ //
+ // We check key events as well, since they're implemented differently.
+ //
+ // NB: We don't check isTrusted on the events we create here, because
+ // according to smaug, old-style event initialization doesn't mark the
+ // event as trusted until it's dispatched.
+ //
+
+ window.triggeredUntrustedKeyHandler = false;
+ window.triggeredTrustedKeyHandler = false;
+
+ // Untrusted event, permissive handler.
+ var untrustedKeyEvent = document.createEvent('KeyboardEvent');
+ untrustedKeyEvent.initEvent('keyup', true, true);
+ bound.dispatchEvent(untrustedKeyEvent);
+ ok(window.triggeredUntrustedKeyHandler, "untrusted key events should trigger untrusted handler");
+
+ // Untrusted event, strict handler.
+ var fakeTrustedKeyEvent = document.createEvent('KeyboardEvent');
+ fakeTrustedKeyEvent.initEvent('keydown', true, true);
+ bound.dispatchEvent(fakeTrustedKeyEvent);
+ ok(!window.triggeredTrustedKeyHandler, "untrusted key events should not trigger trusted handler");
+
+ // Trusted event, strict handler. Dispatch using SpecialPowers to make the event trusted.
+ var trustedKeyEvent = document.createEvent('KeyboardEvent');
+ trustedKeyEvent.initEvent('keydown', true, true);
+ SpecialPowers.wrap(bound).dispatchEvent(trustedKeyEvent);
+ ok(window.triggeredTrustedKeyHandler, "trusted key events should trigger trusted handler");
+
+ // Hand control back to the XBL scope by dispatching an event on the bound element.
+ bound.dispatchEvent(new CustomEvent('testevent'));
+ }
+
+ function checkThrows(fn) {
+ try { fn(); ok(false, "Should have thrown"); }
+ catch (e) { ok(!!/denied|insecure/.exec(e), "Should have thrown security exception: " + e); }
+ }
+
+ function checkAllowed(fn, desc) {
+ try { fn(); ok(true, desc + ": Didn't throw"); }
+ catch (e) { ok(false, desc + ": Threw: " + e); }
+ }
+
+ function setup() {
+ // When the bindings are applied, the constructor will be invoked and the
+ // test will continue.
+ document.getElementById('bound').style.MozBinding = 'url(#testBinding)';
+ document.getElementById('bound2').style.MozBinding = 'url(#testBinding)';
+ document.getElementById('bound3').style.MozBinding = 'url(#testBinding)';
+ }
+
+ ]]>
+</script>
+</head>
+<body onload="setup()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=821850">Mozilla Bug 821850</a>
+<p id="display"></p>
+<div id="content">
+ <div id="bound">Bound element</div>
+ <div id="bound2">Bound element</div>
+ <span id="bound3">Bound element</span>
+ <img/>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/file_bug844783.xhtml b/dom/xbl/test/file_bug844783.xhtml
new file mode 100644
index 000000000..a2e04edf2
--- /dev/null
+++ b/dom/xbl/test/file_bug844783.xhtml
@@ -0,0 +1,54 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=844783
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="testBinding">
+ <implementation>
+ <constructor>
+ is(windowExpando, 42, "Expandos show up without explicit waiving");
+ someFunction();
+ ok(called, "Function called");
+ go();
+ </constructor>
+ </implementation>
+ <handlers>
+ <handler event="testevent" action="is(boundExpando, 11, 'See expandos on |this|'); SimpleTest.finish();"/>
+ </handlers>
+ </binding>
+ </bindings>
+ <script type="application/javascript">
+ <![CDATA[
+
+ is = parent.is;
+ ok = parent.ok;
+ SimpleTest = parent.SimpleTest;
+ window.windowExpando = 42;
+ window.someFunction = function() { ok(true, "Called"); window.called = true; };
+
+ function go() {
+ var bound = document.getElementById('bound');
+ bound.boundExpando = 11;
+ bound.dispatchEvent(new CustomEvent('testevent'));
+ }
+
+ function setup() {
+ // When the bindings are applied, the constructor will be invoked and the
+ // test will continue.
+ document.getElementById('bound').style.MozBinding = 'url(#testBinding)';
+ }
+
+ ]]>
+</script>
+</head>
+<body onload="setup()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=844783">Mozilla Bug 844783</a>
+<p id="display"></p>
+<div id="content">
+ <div id="bound">Bound element</div>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/file_bug944407.html b/dom/xbl/test/file_bug944407.html
new file mode 100644
index 000000000..3e4a0e80f
--- /dev/null
+++ b/dom/xbl/test/file_bug944407.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="deny" style="-moz-binding: url(file_bug944407.xml#testAllowScript)"></div>
+<div id="allow" style="-moz-binding: url(chrome://mochitests/content/chrome/dom/xbl/test/file_bug944407.xml#testAllowScript)"</div>
+<script>/* Flush layout with a script tab - see bug 944407 comment 37. */</script>
+</body>
+</html>
diff --git a/dom/xbl/test/file_bug944407.xml b/dom/xbl/test/file_bug944407.xml
new file mode 100644
index 000000000..e48271b9f
--- /dev/null
+++ b/dom/xbl/test/file_bug944407.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<bindings id="testBindings" xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="testAllowScript" bindToUntrustedContent="true">
+ <implementation>
+ <property name="someProp" onget="return 2;" readonly="true"></property>
+ <method name="someMethod"><body> return 3; </body></method>
+ <method name="startTest">
+ <body>
+ <![CDATA[
+ // Make sure we only get constructed when we're loaded from a domain
+ // with script enabled.
+ is(this.id, 'allow', "XBL should only be bound when the origin of the binding allows scripts");
+
+ var t = this;
+ doFinish = function() {
+ // Take a moment to make sure that other constructors don't run when they shouldn't.
+ if (t.id == 'allow')
+ setTimeout(SpecialPowers.wrap(window.parent).finish, 100);
+ }
+
+ onTestEvent = function(target) {
+ ok(true, 'called event handler');
+
+ // Try calling event handlers on anonymous content.
+ var e = new MouseEvent('click');
+ document.getAnonymousNodes(target)[1].dispatchEvent(e);
+ ok(window.calledEventHandlerOnAC, "Should invoke event handler on AC");
+
+ // Now, dispatch a key event to test key handlers and move the test along.
+ var k = document.createEvent('KeyboardEvent');
+ k.initEvent('keyup', true, true);
+ target.dispatchEvent(k);
+ }
+
+ // Check the implementation.
+ is(this.someProp, 2, "Properties work");
+ is(this.someMethod(), 3, "Methods work");
+
+ // Kick over to the event handlers. This tests XBL event handlers,
+ // XBL key handlers, and event handlers on anonymous content.
+ this.dispatchEvent(new CustomEvent('testEvent'));
+ ]]>
+ </body>
+ </method>
+
+ <constructor>
+ <![CDATA[
+ win = XPCNativeWrapper.unwrap(window);
+ SpecialPowers = win.SpecialPowers;
+ ok = win.ok = SpecialPowers.wrap(window.parent).ok;
+ is = win.is = SpecialPowers.wrap(window.parent).is;
+ info = win.info = SpecialPowers.wrap(window.parent).info;
+
+ info("Invoked constructor for " + this.id);
+
+ var t = this;
+ window.addEventListener('load', function loadListener() {
+ window.removeEventListener('load', loadListener);
+ // Wait two refresh-driver ticks to make sure that the constructor runs
+ // for both |allow| and |deny| if it's ever going to.
+ //
+ // See bug 944407 comment 37.
+ info("Invoked load listener for " + t.id);
+ window.requestAnimationFrame(function() { window.requestAnimationFrame(t.startTest.bind(t)); });
+ });
+ ]]>
+ </constructor>
+ </implementation>
+ <handlers>
+ <handler event="testEvent" action="onTestEvent(this)" allowuntrusted="true"/>
+ <handler event="keyup" action="ok(true, 'called key handler'); doFinish();" allowuntrusted="true"/>
+ </handlers>
+ <content>Anonymous Content<html:div onclick="window.calledEventHandlerOnAC = true;"></html:div><html:b style="display:none"><children/></html:b></content>
+ </binding>
+</bindings>
diff --git a/dom/xbl/test/file_bug946815.xhtml b/dom/xbl/test/file_bug946815.xhtml
new file mode 100644
index 000000000..ca8718b7b
--- /dev/null
+++ b/dom/xbl/test/file_bug946815.xhtml
@@ -0,0 +1,97 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=946815
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="testBinding">
+ <implementation>
+ <constructor>
+ // Grab some basic infrastructure off the content window.
+ var win = XPCNativeWrapper.unwrap(window);
+ SpecialPowers = win.SpecialPowers;
+ Cu = SpecialPowers.Cu;
+ is = win.is;
+ ok = win.ok;
+ SimpleTest = win.SimpleTest;
+
+ var bound = document.getElementById('bound');
+
+ // This gets invoked by an event handler.
+ window.finish = function() {
+ // XBL scope, with 'wifi-manage' scope
+ testWifiPermissionFromXbl(true, true /* with wifi-manage permission */);
+ SimpleTest.finish();
+ }
+
+ eval('var testWifiPermissionFromXbl = ' + win.testWifiPermissionFromContent.toSource());
+
+ // XBL scope, with no 'wifi-manage' permission
+ testWifiPermissionFromXbl(true, false /* without wifi-manage permission */);
+
+ // Hand things off to content. Content will call us back.
+ win.go();
+ </constructor>
+ </implementation>
+ <handlers>
+ <handler event="testevent" action="ok(true, 'called event handler'); finish();" allowuntrusted="true"/>
+ </handlers>
+ </binding>
+ </bindings>
+ <script type="application/javascript">
+ <![CDATA[
+
+ ok = parent.ok;
+ is = parent.is;
+ SimpleTest = parent.SimpleTest;
+ SpecialPowers = parent.SpecialPowers;
+
+ function go() {
+ "use strict";
+
+ // Content scope, with no 'wifi-manage' permission
+ testWifiPermissionFromContent(false, false /* without wifi-manage permission */);
+
+ SpecialPowers.pushPermissions([{ "type": "wifi-manage", "allow": 1, "context": window.document }], function() {
+ testWifiPermissionFromContent(false, true /* with wifi-manage permission */);
+ // Hand control back to the XBL scope by dispatching an event on the bound element.
+ bound.dispatchEvent(new CustomEvent('testevent'));
+ });
+ }
+
+ function testWifiPermissionFromContent(aIsXblScope, aExpectedWifiPermission) {
+ // Even though the function name has suggested we are either in content or
+ // XBL scope, the argument |aIsXblScope| is still required to print
+ // descriptive enough message for the test.
+
+ // If this test fails, something must be wrong with the permission manipulation.
+ // Check test_bug946815.html to see if we removed wifi-manage permission in
+ // the beginning and if we forgot to add permission back during testing.
+ is(aExpectedWifiPermission, SpecialPowers.hasPermission("wifi-manage", window.document),
+ "'wifi-manage' permission is not as expected! Expected: " + aExpectedWifiPermission);
+
+ is(typeof window.MozWifiP2pManager, (aExpectedWifiPermission ? "function" : "undefined"),
+ (aIsXblScope ? "XBL" : "Content") + " should" + (aExpectedWifiPermission ? "" : " NOT") +
+ " see MozWifiP2pManager with" + (aExpectedWifiPermission ? "" : "out") +
+ " 'wifi-manage' permission." );
+ }
+
+ function setup() {
+ // When the bindings are applied, the constructor will be invoked and the
+ // test will continue.
+ document.getElementById('bound').style.MozBinding = 'url(#testBinding)';
+ }
+
+ ]]>
+</script>
+</head>
+<body onload="setup()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946815">Mozilla Bug 946815</a>
+<p id="display"></p>
+<div id="content">
+ <div id="bound">Bound element</div>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/file_bug950909.html b/dom/xbl/test/file_bug950909.html
new file mode 100644
index 000000000..a33d9bbf8
--- /dev/null
+++ b/dom/xbl/test/file_bug950909.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="-moz-binding: url(chrome://mochitests/content/chrome/dom/xbl/test/file_bug950909.xml#testBinding"></div>
+</body>
+</html>
diff --git a/dom/xbl/test/file_bug950909.xml b/dom/xbl/test/file_bug950909.xml
new file mode 100644
index 000000000..c711d9ed4
--- /dev/null
+++ b/dom/xbl/test/file_bug950909.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<bindings id="chromeTestBindings" xmlns="http://www.mozilla.org/xbl">
+ <binding id="testBinding" bindToUntrustedContent="true">
+ <implementation implements="nsIObserver">
+ <constructor>
+ <![CDATA[
+ // This binding gets applied to a content object, and thus is actually
+ // running in a content XBL scope.
+ var win = XPCNativeWrapper.unwrap(window);
+ var SpecialPowers = win.SpecialPowers;
+ var ok = SpecialPowers.unwrap(SpecialPowers.wrap(window).parent.ok);
+ ok(win != window, "Should be running in an XBL scope with Xrays");
+
+ // Generate an XPCWrappedJS for the reflector. We need to do this
+ // explicitly with a testing helper, because we're converging on
+ // removing XPConnect from the web, which means that it won't be
+ // possible to generate an XPCWrappedJS from content (or XBL) code.
+ var scope = {};
+ var holder = SpecialPowers.Cu.generateXPCWrappedJS(this, scope);
+
+ // Now, QI |this|, which will generate an aggregated native.
+ this.QueryInterface(Components.interfaces.nsIObserver);
+
+ ok(true, "Didn't assert or crash");
+
+ SpecialPowers.wrap(window).parent.SimpleTest.finish();
+ ]]>
+ </constructor>
+ <method name="observe">
+ <parameter name="aSubject"/>
+ <parameter name="aTopic"/>
+ <parameter name="aData"/>
+ <body><![CDATA[]]></body>
+ </method>
+ </implementation>
+ </binding>
+</bindings>
diff --git a/dom/xbl/test/file_fieldScopeChain.xml b/dom/xbl/test/file_fieldScopeChain.xml
new file mode 100644
index 000000000..80e6cf477
--- /dev/null
+++ b/dom/xbl/test/file_fieldScopeChain.xml
@@ -0,0 +1,8 @@
+<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="foo">
+ <implementation>
+ <field name="bar">baz</field>
+ </implementation>
+ </binding>
+</bindings>
diff --git a/dom/xbl/test/mochitest.ini b/dom/xbl/test/mochitest.ini
new file mode 100644
index 000000000..2804d501f
--- /dev/null
+++ b/dom/xbl/test/mochitest.ini
@@ -0,0 +1,43 @@
+[DEFAULT]
+support-files =
+ bug310107-resource.xhtml
+ file_bug372769.xhtml
+ file_bug379959_cross.html
+ file_bug379959_data.html
+ file_bug379959_xbl.xml
+ file_bug397934.xhtml
+ file_bug481558.xbl
+ file_bug481558css.sjs
+ file_bug591198_inner.html
+ file_bug591198_xbl.xml
+ file_bug821850.xhtml
+ file_bug844783.xhtml
+ file_bug944407.html
+ file_bug944407.xml
+ file_bug946815.xhtml
+ file_bug950909.html
+
+[test_bug310107.html]
+[test_bug366770.html]
+[test_bug371724.xhtml]
+[test_bug372769.html]
+[test_bug378866.xhtml]
+[test_bug379959.html]
+[test_bug389322.xhtml]
+[test_bug397934.html]
+[test_bug400705.xhtml]
+[test_bug401907.xhtml]
+[test_bug403162.xhtml]
+[test_bug468210.xhtml]
+[test_bug481558.html]
+[test_bug526178.xhtml]
+[test_bug542406.xhtml]
+[test_bug591198.html]
+[test_bug639338.xhtml]
+[test_bug790265.xhtml]
+[test_bug821850.html]
+[test_bug844783.html]
+[test_bug872273.xhtml]
+[test_bug1086996.xhtml]
+[test_bug1098628_throw_from_construct.xhtml]
+[test_bug1359859.xhtml] \ No newline at end of file
diff --git a/dom/xbl/test/test_bug1086996.xhtml b/dom/xbl/test/test_bug1086996.xhtml
new file mode 100644
index 000000000..c60855a00
--- /dev/null
+++ b/dom/xbl/test/test_bug1086996.xhtml
@@ -0,0 +1,62 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1086996
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:html="http://www.w3.org/1999/xhtml">
+ <binding id="handlerBinding">
+ <implementation>
+ <constructor>
+ <![CDATA[XPCNativeWrapper.unwrap(window).constructedHandlerBinding();]]>
+ </constructor>
+ </implementation>
+ <handlers>
+ <handler event="testevent" action="XPCNativeWrapper.unwrap(window).gotEvent();" allowuntrusted="true"/>
+ </handlers>
+ </binding>
+ <binding id="mainBinding">
+ <content>
+ <html:p id="acWithBinding" style="-moz-binding: url(#handlerBinding)"> Anonymous Content</html:p>
+ </content>
+ <implementation>
+ <method name="doEventDispatch" exposeToUntrustedContent="true">
+ <body>
+ <![CDATA[document.getAnonymousNodes(this)[0].dispatchEvent(new CustomEvent('testevent'));]]>
+ </body>
+ </method>
+ </implementation>
+ </binding>
+ </bindings>
+ <title>Test for Bug 1086996</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=1086996">Mozilla Bug 1086996</a>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 1086996 **/
+SimpleTest.waitForExplicitFinish();
+function constructedHandlerBinding() {
+ ok(true, "Constructed handler binding!");
+ setTimeout(function() { $('boundContent').doEventDispatch(); }, 0);
+}
+
+function gotEvent() {
+ ok(true, "Successfully triggered event handler");
+ SimpleTest.finish();
+}
+
+]]>
+</script>
+</pre>
+<!-- This div needs to come after the <script> so we don't run the binding ctor
+ before the <script> has been parsed -->
+<div id="boundContent" style="-moz-binding: url(#mainBinding)"></div>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug1098628_throw_from_construct.xhtml b/dom/xbl/test/test_bug1098628_throw_from_construct.xhtml
new file mode 100644
index 000000000..22bc88798
--- /dev/null
+++ b/dom/xbl/test/test_bug1098628_throw_from_construct.xhtml
@@ -0,0 +1,40 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1098628
+-->
+<head>
+ <title>Test for Bug 1098628</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <script class="testbody" type="text/javascript">
+ <![CDATA[
+
+ /** Test for Bug 1098628 **/
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('flimfniffle')}]);
+ addLoadEvent(function() {
+ SimpleTest.executeSoon(SimpleTest.endMonitorConsole);
+ });
+ ]]>
+ </script>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="test">
+ <implementation>
+ <constructor><![CDATA[
+ throw "flimfniffle";
+ ]]></constructor>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1098628">Mozilla Bug 1098628</a>
+<p id="display" style="-moz-binding: url(#test)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug1359859.xhtml b/dom/xbl/test/test_bug1359859.xhtml
new file mode 100644
index 000000000..564c2f96d
--- /dev/null
+++ b/dom/xbl/test/test_bug1359859.xhtml
@@ -0,0 +1,41 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <!--
+ https://bugzilla.mozilla.org/show_bug.cgi?id=1359859
+ -->
+ <head>
+ <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">
+ <binding id="testBinding">
+ <implementation>
+ <constructor>
+ XPCNativeWrapper.unwrap(window).running();
+ this.constructed = true;
+ throw new Error("Constructor threw");
+ </constructor>
+ <field name="throwingField">throw new Error("field threw")</field>
+ <field name="normalField">"hello"</field>
+ </implementation>
+ </binding>
+ </bindings>
+ <script>
+ // We need to wait for the binding to load.
+ SimpleTest.waitForExplicitFinish();
+ function running() {
+ // Wait for the rest of the constructor to run
+ SimpleTest.executeSoon(function() {
+ is(document.getElementById("bound").throwingField, undefined,
+ "Should not have a value for a throwing field");
+ is(document.getElementById("bound").normalField, "hello",
+ "Binding should be installed");
+ // The real test is that we haven't gotten any error events so far.
+ SimpleTest.finish();
+ });
+ }
+ </script>
+ </head>
+ <body>
+ <div id="bound" style="-moz-binding: url(#testBinding)"/>
+ </body>
+</html>
+
diff --git a/dom/xbl/test/test_bug310107.html b/dom/xbl/test/test_bug310107.html
new file mode 100644
index 000000000..17e642b97
--- /dev/null
+++ b/dom/xbl/test/test_bug310107.html
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=310107
+-->
+<head>
+ <title>Test for Bug 310107</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=310107">Mozilla Bug 310107</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Bug 310107 **/
+SimpleTest.waitForExplicitFinish();
+
+var win = window.open("bug310107-resource.xhtml", "", "width=10, height=10");
+
+function runTest() {
+ window.el = win.document.getElementById("bar");
+ window.doc = win.document;
+ is(window.el.prop, 2, "Unexpected prop value at load");
+
+ win.location = "data:text/html,<body onload='window.opener.loadDone()'>";
+}
+
+function loadDone() {
+ is(window.el.prop, 2, "Prop still 2 because we're in bfcache");
+ is(window.el, window.doc.getElementById("bar"),
+ "document didn't get bfcached?");
+
+ // Remove our node from the DOM
+ window.el.parentNode.removeChild(window.el);
+
+ is(window.el.prop, undefined, "Binding should have been detached");
+ is(typeof(window.el.prop), "undefined", "Really undefined");
+
+ win.close();
+
+ SimpleTest.finish();
+}
+
+
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug366770.html b/dom/xbl/test/test_bug366770.html
new file mode 100644
index 000000000..d3314ecca
--- /dev/null
+++ b/dom/xbl/test/test_bug366770.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=366770
+-->
+<head>
+ <title>Test for Bug 366770</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=366770">Mozilla Bug 366770</a>
+ <p id="display"></p>
+ <div id="content" style="display: none"></div>
+
+ <!-- data: URI below corresponds to:
+ <?xml version="1.0"?>
+ <bindings id="xbltestBindings" xmlns="http://www.mozilla.org/xbl">
+ <binding id="xbltest">
+ <content>PASS</content>
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ win.document.bindingConstructorRan = true;
+ win.ok(true, "binding URI with no fragment applied");
+ win.SimpleTest.finish();
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+ -->
+ <span id="span" style="-moz-binding: url(data:text/xml;base64,ICA8YmluZGluZ3MgaWQ9InhibHRlc3RCaW5kaW5ncyIgeG1sbnM9Imh0dHA6Ly93d3cubW96aWxsYS5vcmcveGJsIj4KICAgIDxiaW5kaW5nIGlkPSJ4Ymx0ZXN0Ij4KICAgICAgPGNvbnRlbnQ+UEFTUzwvY29udGVudD4KICAgICAgPGltcGxlbWVudGF0aW9uPgogICAgICAgIDxjb25zdHJ1Y3Rvcj4KICAgICAgICAgIHZhciB3aW4gPSBYUENOYXRpdmVXcmFwcGVyLnVud3JhcCh3aW5kb3cpOwogICAgICAgICAgd2luLmRvY3VtZW50LmJpbmRpbmdDb25zdHJ1Y3RvclJhbiA9IHRydWU7CiAgICAgICAgICB3aW4ub2sodHJ1ZSwgImJpbmRpbmcgVVJJIHdpdGggbm8gZnJhZ21lbnQgYXBwbGllZCIpOwogICAgICAgICAgd2luLlNpbXBsZVRlc3QuZmluaXNoKCk7CiAgICAgICAgPC9jb25zdHJ1Y3Rvcj4KICAgICAgPC9pbXBsZW1lbnRhdGlvbj4KICAgIDwvYmluZGluZz4KICA8L2JpbmRpbmdzPg==);"></span>
+
+ <pre id="test">
+ <script class="testbody" type="text/javascript">
+ /** Test for Bug 366770 **/
+ SimpleTest.waitForExplicitFinish();
+ </script>
+ </pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug371724.xhtml b/dom/xbl/test/test_bug371724.xhtml
new file mode 100644
index 000000000..69a317fde
--- /dev/null
+++ b/dom/xbl/test/test_bug371724.xhtml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=371724
+-->
+<head>
+ <script type="text/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">
+ <binding id="rd">
+ <implementation>
+ <property name="hallo" onget="return true;" readonly="true" exposeToUntrustedContent="true"/>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=371724">Mozilla Bug 371724</a>
+ <p id="display"></p>
+ <div id="content" style="display: none"></div>
+ <div id="a" style="-moz-binding:url('#rd');">Success!</div>
+ <pre id="test">
+ <script class="testbody" type="text/javascript">
+ /** Test for Bug 371724 **/
+ SimpleTest.waitForExplicitFinish();
+ function checkReadOnly() {
+ var elt = document.getElementById('a');
+ var oldValue = elt.hallo;
+ var actual;
+ try {
+ elt.hallo = false;
+ actual = elt.hallo;
+ } catch (ex) {
+ actual = "" + ex;
+ }
+ is(actual, true,
+ "Setting a readonly xbl property should do nothing if !strict");
+ checkReadOnlyStrict();
+ }
+ function checkReadOnlyStrict() {
+ "use strict";
+ var elt = document.getElementById('a');
+ var actual;
+ try {
+ elt.hallo = false;
+ actual = "should have thrown";
+ } catch (ex) {
+ actual = ex instanceof TypeError;
+ }
+ is(actual, true,
+ "Setting a readonly xbl property should throw a TypeError exception if strict");
+ SimpleTest.finish();
+ }
+ addLoadEvent(checkReadOnly);
+ </script>
+ </pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug372769.html b/dom/xbl/test/test_bug372769.html
new file mode 100644
index 000000000..c5cbbb7de
--- /dev/null
+++ b/dom/xbl/test/test_bug372769.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=372769
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 372769</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">
+
+ SimpleTest.waitForExplicitFinish();
+
+ // Embed the real test. It will take care of everything else.
+ function setup() {
+ SpecialPowers.pushPrefEnv({'set': [['dom.use_xbl_scopes_for_remote_xul', false]]}, go);
+ }
+ function go() {
+ $('ifr').setAttribute('src', 'file_bug372769.xhtml');
+ }
+
+ </script>
+</head>
+<body onload="setup();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372769">Mozilla Bug 372769</a>
+<p id="display"></p>
+<div id="content">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug378518.xul b/dom/xbl/test/test_bug378518.xul
new file mode 100644
index 000000000..0486f3480
--- /dev/null
+++ b/dom/xbl/test/test_bug378518.xul
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=378518
+-->
+<window title="Mozilla Bug 378518"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript"
+ src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <binding id="mybinding" extends="xul:checkbox">
+ <content>
+ </content>
+ </binding>
+
+ </bindings>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=378518"
+ target="_blank">Mozilla Bug 378518</a>
+ </body>
+
+ <!-- The elements we're testing with -->
+ <command id="myBoxCommand" oncommand="myBoxClicked = true;"/>
+ <command id="myCheckBoxCommand" oncommand="myCheckBoxClicked = true;"/>
+ <command id="myExtendedBoxCommand" oncommand="myExtendedBoxClicked = true;"/>
+
+ <box id="myBox" command="myBoxCommand">
+ <label>myBox</label>
+ </box>
+
+ <checkbox id="myCheckBox" command="myCheckBoxCommand" label="myCheckBox"/>
+
+ <box id="myExtendedBox" command="myExtendedBoxCommand"
+ style="-moz-binding:url(#mybinding)">
+ <label>myExtendedBox</label>
+ </box>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"> <![CDATA[
+
+ SimpleTest.expectAssertions(1);
+
+ var myBoxClicked = false;
+ var myCheckBoxClicked = false;
+ var myExtendedBoxClicked = false;
+
+ function testClick(elemName) {
+ var wu =
+ window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindowUtils);
+
+ var a = document.getElementById(elemName).getBoundingClientRect();
+ wu.sendMouseEvent('mousedown', a.left + 1, a.top + 1, 0, 1, 0);
+ wu.sendMouseEvent('mouseup', a.left + 1, a.top + 1, 0, 1, 0);
+ }
+
+ function doTest() {
+ testClick('myBox');
+ testClick('myCheckBox');
+ testClick('myExtendedBox');
+ ok(!myBoxClicked, "Shouldn't fire");
+ ok(myCheckBoxClicked, "Should fire");
+ ok(!myExtendedBoxClicked, "Shouldn't fire");
+ SimpleTest.finish();
+ }
+
+ /** Test for Bug 378518 **/
+ SimpleTest.waitForExplicitFinish();
+
+ addLoadEvent(function() {
+ setTimeout(doTest, 0);
+ });
+
+ ]]>
+ </script>
+</window>
diff --git a/dom/xbl/test/test_bug378866.xhtml b/dom/xbl/test/test_bug378866.xhtml
new file mode 100644
index 000000000..5a5b9a09a
--- /dev/null
+++ b/dom/xbl/test/test_bug378866.xhtml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=378866
+-->
+<head>
+ <title>Test for Bug 378866</title>
+ <script type="text/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="b1">
+ <content><html:span><html:span>
+ <children/>
+ </html:span></html:span></content>
+ </binding>
+</bindings>
+
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=378866">Mozilla Bug 378866</a>
+<p id="display"></p>
+<div id="content">
+ <span id="grandparent" style="-moz-binding: url(#b1);">
+ <span id="parent">
+ <span id="child"/>
+ </span>
+ </span>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+/** Test for Bug 378866 **/
+
+function runTest() {
+ var anon = SpecialPowers.wrap(document).getAnonymousNodes(document.getElementById('grandparent'));
+ var child = SpecialPowers.wrap(document).getElementById('child');
+ var insertionPoint = anon[0].childNodes[0];
+ insertionPoint.parentNode.removeChild(insertionPoint);
+ child.appendChild(insertionPoint);
+
+ var e = document.createEvent("Event");
+ e.initEvent("foo", true, true);
+ child.dispatchEvent(e);
+ ok(true, "Moving insertion point shouldn't cause problems in event dispatching");
+ addLoadEvent(SimpleTest.finish);
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(runTest);
+
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug379959.html b/dom/xbl/test/test_bug379959.html
new file mode 100644
index 000000000..2b31b54c5
--- /dev/null
+++ b/dom/xbl/test/test_bug379959.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=379959
+-->
+<head>
+ <title>Test for Bug 379959</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runTest();">
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=379959">Mozilla Bug 379959</a>
+ <p id="display">
+ Note: In order to re-run this test correctly you need to shift-reload
+ rather than simply reload. If you just reload we will restore the
+ previous url in the iframe which will result in an extra unexpected
+ message.
+ </p>
+ <div id="content" style="display: none"></div>
+ <iframe id="dataFrame"></iframe>
+ <iframe id="originFrame"></iframe>
+
+ <pre id="test">
+ <script class="testbody" type="application/javascript;version=1.7">
+
+SimpleTest.waitForExplicitFinish();
+
+var seenData = false;
+var seenSameOrigin = false;
+var seenCrossOrign = false;
+
+function receiveMessage(e) {
+ is(e.origin, "http://mochi.test:8888", "wrong sender!");
+
+ if (e.data.test === "dataIsAllowed") {
+ is(e.data.result, 1, "data-url load should have succeeded");
+ seenData = true;
+ }
+ else if (e.data.test === "sameOriginIsAllowed") {
+ is(e.data.result, 1, "same site load should have succeeded");
+ seenSameOrigin = true;
+ }
+ else if (e.data.test === "crossOriginIsBlocked") {
+ is(e.data.result, 0, "cross site load should have failed");
+ seenCrossOrign = true;
+ }
+ else {
+ ok (false, "unrecognized test");
+ }
+
+ if (seenData && seenSameOrigin && seenCrossOrign) {
+ window.removeEventListener("message", receiveMessage, false);
+ SimpleTest.finish();
+ }
+}
+
+window.addEventListener("message", receiveMessage, false);
+
+function runTest() {
+ // make sure data: is allowed
+ document.getElementById('dataFrame').src = "file_bug379959_data.html";
+ // make sure same-origin is allowed but cross site is blocked
+ document.getElementById('originFrame').src = "file_bug379959_cross.html";
+}
+
+ </script>
+ </pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug389322.xhtml b/dom/xbl/test/test_bug389322.xhtml
new file mode 100644
index 000000000..4b80346bd
--- /dev/null
+++ b/dom/xbl/test/test_bug389322.xhtml
@@ -0,0 +1,126 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=389322
+-->
+<head>
+ <title>Test for Bug 389322</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <script>var ctorRan = false;</script>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="test">
+ <implementation>
+ <field name="field"><![CDATA[
+ (function () {
+ try {
+ eval("let x = 1;");
+ var success = true;
+ }
+ catch (e) { success = false; }
+ XPCNativeWrapper.unwrap(window).report("XBL fields", success)
+ return ""
+ }())
+ ]]></field>
+ <property name="property">
+ <getter><![CDATA[
+ try {
+ eval("let x = 1;");
+ var success = true;
+ }
+ catch (e) { success = false; }
+ XPCNativeWrapper.unwrap(window).report("XBL property getters", success)
+ return 1
+ ]]></getter>
+ <setter><![CDATA[
+ try {
+ eval("let x = 1;");
+ var success = true
+ }
+ catch (e) { success = false }
+ XPCNativeWrapper.unwrap(window).report("XBL property setters", success)
+ return val
+ ]]></setter>
+ </property>
+ <method name="method">
+ <body><![CDATA[
+ try {
+ eval("let x = 1;");
+ var success = true;
+
+ }
+ catch (e) { success = false; }
+ XPCNativeWrapper.unwrap(window).report("XBL methods", success)
+ ]]></body>
+ </method>
+ <constructor><![CDATA[
+ this.property += 1
+ var x = this.field;
+ this.method()
+ try {
+ eval("let x = 1;");
+ var success = true
+ }
+ catch (e) { success = false }
+ var win = XPCNativeWrapper.unwrap(window);
+ win.report("XBL constructors", success)
+
+ var ev = document.createEvent("Events")
+ ev.initEvent("custom", false, false)
+ this.dispatchEvent(ev)
+ win.ctorRan = true;
+ ]]></constructor>
+ </implementation>
+ <handlers>
+ <handler action='
+ try {
+ eval("let x = 1;");
+ var success = true
+ }
+ catch (e) { success = false }
+ report("XBL event handlers", success);
+ ' event="custom"/>
+ </handlers>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389322">Mozilla Bug 389322</a>
+<p id="display" style="-moz-binding: url(#test)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+/** Test for Bug 389322 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ is(ctorRan, true, "Constructor should have run");
+});
+addLoadEvent(SimpleTest.finish);
+
+function report(testName, success) {
+ is(success, true, "JS 1.7 should work in " + testName);
+}
+]]>
+</script>
+<script type="text/javascript; version=1.7"><![CDATA[
+ try {
+ eval("let x = 1;");
+ var success = true;
+ }
+ catch (e) { success = false; }
+ report("HTML script tags with explicit version", success)
+]]></script>
+<script type="text/javascript"><![CDATA[
+ try {
+ eval("let x = 1;");
+ var success = true;
+ }
+ catch (e) { success = false; }
+ is(success, true, "let should work in versionless HTML script tags");
+]]></script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug397934.html b/dom/xbl/test/test_bug397934.html
new file mode 100644
index 000000000..098b4c7b5
--- /dev/null
+++ b/dom/xbl/test/test_bug397934.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=397934
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 397934</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">
+
+ SimpleTest.waitForExplicitFinish();
+
+ // Embed the real test. It will take care of everything else.
+ function setup() {
+ SpecialPowers.pushPrefEnv({'set': [['dom.use_xbl_scopes_for_remote_xul', false]]}, go);
+ }
+ function go() {
+ $('ifr').setAttribute('src', 'file_bug397934.xhtml');
+ }
+
+ </script>
+</head>
+<body onload="setup();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=397934">Mozilla Bug 397934</a>
+<p id="display"></p>
+<div id="content">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug398135.xul b/dom/xbl/test/test_bug398135.xul
new file mode 100644
index 000000000..6b0b68c62
--- /dev/null
+++ b/dom/xbl/test/test_bug398135.xul
@@ -0,0 +1,135 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=398135
+-->
+<window title="Mozilla Bug 398135"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">window.log = ""</script>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="ancestor">
+ <implementation>
+ <constructor>
+ window.log += "ancestorConstructor:";
+ </constructor>
+ <destructor>
+ window.log += "ancestorDestructor:";
+ </destructor>
+ <field name="ancestorField">"ancestorField"</field>
+ <property name="ancestorProp" onget="return 'ancestorProp'"/>
+ <method name="ancestorMethod">
+ <body>
+ return "ancestorMethod";
+ </body>
+ </method>
+ </implementation>
+ </binding>
+ <binding id="test" extends="#ancestor">
+ <implementation>
+ <constructor>
+ window.log += "descendantConstructor:";
+ </constructor>
+ <destructor>
+ window.log += "descendantDestructor:";
+ </destructor>
+ <field name="descendantField">"descendantField"</field>
+ <field name="contentField">
+ document.getAnonymousNodes(this)[0];
+ </field>
+ <property name="descendantProp" onget="return 'descendantProp'"/>
+ <method name="descendantMethod">
+ <body>
+ return "descendantMethod";
+ </body>
+ </method>
+ </implementation>
+ <content>
+ <span/>
+ <children/>
+ </content>
+ </binding>
+ </bindings>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=398135"
+ target="_blank">Mozilla Bug 398135</a>
+ </body>
+
+ <hbox id="display" style="-moz-binding: url(#test)"></hbox>
+
+<script type="application/javascript">
+<![CDATA[
+/** Test for Bug 398135 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ var d;
+ d = $("display");
+
+ function testInTree(type) {
+ is(d.ancestorField, "ancestorField", "Wrong ancestor field " + type);
+ is(d.descendantField, "descendantField", "Wrong descendant field " + type);
+ is(d.ancestorProp, "ancestorProp", "Wrong ancestor prop " + type);
+ is(d.descendantProp, "descendantProp", "Wrong descendant prop " + type);
+ is(d.ancestorMethod(), "ancestorMethod", "Wrong ancestor method " + type);
+ is(d.descendantMethod(), "descendantMethod",
+ "Wrong descendant method " + type);
+ is(d.contentField, document.getAnonymousNodes(d)[0],
+ "Unexpected content field " + type);
+ }
+
+ function testNotInTree(type) {
+ is(typeof(d.ancestorField), "undefined", "Wrong ancestor field " + type);
+ is(typeof(d.descendantField), "undefined",
+ "Wrong descendant field " + type);
+ is(typeof(d.ancestorProp), "undefined", "Wrong ancestor prop " + type);
+ is(typeof(d.descendantProp), "undefined", "Wrong descendant prop " + type);
+ is(typeof(d.ancestorMethod), "undefined", "Wrong ancestor method " + type);
+ is(typeof(d.descendantMethod), "undefined",
+ "Wrong descendant method " + type);
+ is(typeof(d.contentField), "undefined",
+ "Unexpected content field " + type);
+ }
+
+ is(window.log, "ancestorConstructor:descendantConstructor:",
+ "Constructors did not fire?");
+ window.log = "";
+ testInTree("before removal");
+
+ var parent = d.parentNode;
+ var nextSibling = d.nextSibling;
+ parent.removeChild(d);
+ testNotInTree("after first removal");
+
+ todo(window.log == "descendantDestructor:ancestorDestructor:",
+ "Destructors did not fire");
+ window.log = "";
+
+ parent.insertBefore(d, nextSibling);
+ is(window.log, "ancestorConstructor:descendantConstructor:",
+ "Constructors did not fire a second time?");
+ window.log = "";
+ testInTree("after reinsertion");
+
+ // Now munge the proto chain to test the robustness of the proto-unhooking
+ // code
+ var origProto = d.__proto__;
+ var origProtoProto = origProto.__proto__;
+ var newProto = new Object();
+ origProto.__proto__ = newProto;
+ newProto.__proto__ = origProtoProto;
+
+ parent.removeChild(d);
+ todo(window.log == "descendantDestructor:ancestorDestructor:",
+ "Destructors did not fire a second time?");
+
+ testNotInTree("after second removal");
+});
+addLoadEvent(SimpleTest.finish);
+
+]]>
+</script>
+</window>
+
diff --git a/dom/xbl/test/test_bug398492.xul b/dom/xbl/test/test_bug398492.xul
new file mode 100644
index 000000000..a854d50fc
--- /dev/null
+++ b/dom/xbl/test/test_bug398492.xul
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=398492
+-->
+<window title="Mozilla Bug 398492"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="test">
+ <content>
+ <xul:hbox id="xxx"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <children/>
+ </xul:hbox>
+ </content>
+ </binding>
+ </bindings>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=398492"
+ target="_blank">Mozilla Bug 398492</a>
+ </body>
+
+ <hbox id="testbox" style="-moz-binding: url(#test)">Text</hbox>
+
+ <!-- test code goes here -->
+ <script type="application/javascript"><![CDATA[
+
+ /** Test for Bug 398492 **/
+ SimpleTest.waitForExplicitFinish();
+
+ function getXBLParent(node) {
+ var utils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
+ .getService(Components.interfaces.inIDOMUtils);
+ return utils.getParentForNode(node, true);
+ }
+
+ addLoadEvent(function() {
+ var n = $("testbox");
+ var kid = n.firstChild;
+ var anonKid = document.getAnonymousNodes(n)[0];
+ is(anonKid instanceof XULElement, true, "Must be a XUL element");
+ is(anonKid, getXBLParent(kid), "Unexpected anonymous nodes");
+
+ var n2 = n.cloneNode(true);
+ var kid2 = n2.firstChild;
+ var anonKid2 = document.getAnonymousNodes(n2)[0];
+ is(anonKid2 instanceof XULElement, true,
+ "Must be a XUL element after clone");
+ is(anonKid2, getXBLParent(kid2),
+ "Unexpected anonymous nodes after clone");
+
+ var n3 = document.createElement("hbox");
+ document.documentElement.appendChild(n3);
+ var kid3 = document.createTextNode("Text");
+ n3.appendChild(kid3);
+
+ // Note - we rely on the fact that the binding is preloaded
+ // by the other hbox here, so that the binding will be applied
+ // sync.
+ n3.style.MozBinding = "url(" + document.location.href + "#test)";
+ n3.getBoundingClientRect(); // Flush styles.
+
+ var anonKid3 = document.getAnonymousNodes(n3)[0];
+ is(anonKid3 instanceof XULElement, true,
+ "Must be a XUL element after addBinding");
+ is(anonKid3, getXBLParent(kid3),
+ "Unexpected anonymous nodes after addBinding");
+
+
+ n.removeChild(kid);
+ isnot(anonKid, getXBLParent(kid),
+ "Should have removed kid from insertion point");
+
+ n2.removeChild(kid2);
+ isnot(anonKid2, getXBLParent(kid2),
+ "Should have removed kid2 from insertion point");
+
+ n3.removeChild(kid3);
+ isnot(anonKid3, getXBLParent(kid3),
+ "Should have removed kid3 from insertion point");
+
+ SimpleTest.finish();
+ });
+
+
+ ]]></script>
+</window>
diff --git a/dom/xbl/test/test_bug400705.xhtml b/dom/xbl/test/test_bug400705.xhtml
new file mode 100644
index 000000000..6ed687d59
--- /dev/null
+++ b/dom/xbl/test/test_bug400705.xhtml
@@ -0,0 +1,48 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=400705
+-->
+<head>
+ <title>Test for Bug 400705</title>
+ <script type="text/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">
+ <binding id="test">
+ <implementation>
+ <field name="a">XPCNativeWrapper.unwrap(window).countera++</field>
+ <field name="b">XPCNativeWrapper.unwrap(window).counterb++</field>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=400705">Mozilla Bug 400705</a>
+<p id="display" style="-moz-binding: url(#test)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+/** Test for Bug 400705 **/
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+ window.countera = 0;
+ window.counterb = 0;
+
+ var d = $("display");
+ // Control to make sure fields are lazy and all
+ d.a;
+ is(window.countera, 1, "Should have evaluated field");
+
+ d.parentNode.removeChild(d);
+ is(window.counterb, 0, "Should not evaluate field on binding teardown");
+ SimpleTest.finish();
+});
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug401907.xhtml b/dom/xbl/test/test_bug401907.xhtml
new file mode 100644
index 000000000..0bc368e29
--- /dev/null
+++ b/dom/xbl/test/test_bug401907.xhtml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=401907
+-->
+<head>
+ <title>Test for Bug 401907</title>
+ <script type="text/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">
+ <binding id="binding">
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ win.ok(true, "First binding with ID 'binding' should be used!");
+ win.testRun = true;
+ if (win.needsFinish) {
+ win.SimpleTest.finish();
+ }
+ </constructor>
+ </implementation>
+ </binding>
+ <binding id="binding">
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ win.ok(false, "First binding with ID 'binding' should be used!");
+ win.testRun = true;
+ if (win.needsFinish) {
+ win.SimpleTest.finish();
+ }
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=401907">Mozilla Bug 401907</a>
+<p id="display"></p>
+<div id="content">
+ <div style="-moz-binding: url(#binding)">Bound element</div>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+/** Test for Bug 401907 **/
+if (!window.testRun) {
+ window.needsFinish = true;
+ SimpleTest.waitForExplicitFinish();
+}
+
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug403162.xhtml b/dom/xbl/test/test_bug403162.xhtml
new file mode 100644
index 000000000..96c9d77ed
--- /dev/null
+++ b/dom/xbl/test/test_bug403162.xhtml
@@ -0,0 +1,57 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=403162
+-->
+<head>
+ <title>Test for Bug 403162</title>
+ <script type="text/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">
+ <binding id="test">
+ <handlers>
+ <handler event="foo" action="XPCNativeWrapper.unwrap(window).triggerCount++" allowuntrusted="true"/>
+ </handlers>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403162">Mozilla Bug 403162</a>
+<p id="display" style="-moz-binding: url(#test)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+var triggerCount = 0;
+
+function dispatchEvent(t) {
+ var ev = document.createEvent("Events");
+ ev.initEvent("foo", true, true);
+ t.dispatchEvent(ev);
+}
+
+/** Test for Bug 403162 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ var t = $("display");
+ is(triggerCount, 0, "Haven't dispatched event");
+
+ dispatchEvent(t);
+ is(triggerCount, 1, "Dispatched once");
+
+ dispatchEvent(t);
+ is(triggerCount, 2, "Dispatched twice");
+
+ t.parentNode.removeChild(t);
+ dispatchEvent(t);
+ is(triggerCount, 2, "Listener should be gone now");
+
+ SimpleTest.finish();
+});
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug468210.xhtml b/dom/xbl/test/test_bug468210.xhtml
new file mode 100644
index 000000000..72834d241
--- /dev/null
+++ b/dom/xbl/test/test_bug468210.xhtml
@@ -0,0 +1,51 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=468210
+-->
+<head>
+ <title>Test for Bug 468210</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <!-- Keep the stuff inside <content> without spaces, so that the getAnonymousNodes works right -->
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="foo">
+ <content><span xmlns='http://www.w3.org/1999/xhtml'><children xmlns="http://www.mozilla.org/xbl"/></span></content>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468210">Mozilla Bug 468210</a>
+<p id="display">
+ <div id="d" style="-moz-binding: url(#foo);"></div>
+ <a name="foo"></a>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 468210 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ var div = $("d");
+ var n = document.anchors.length;
+ is(n, 1, "Unexpected number of anchors");
+ var anon = SpecialPowers.wrap(document).getAnonymousNodes(div)[0];
+ ok(SpecialPowers.call_Instanceof(anon, HTMLSpanElement), "Unexpected node");
+ is(SpecialPowers.unwrap(anon.parentNode), div, "Unexpected parent");
+ document.body.appendChild(div);
+ is(anon.parentNode, null, "Parent should have become null");
+ // An attr set to test notifications
+ anon.setAttribute("h", "i");
+});
+addLoadEvent(SimpleTest.finish);
+
+
+
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug481558.html b/dom/xbl/test/test_bug481558.html
new file mode 100644
index 000000000..72b418987
--- /dev/null
+++ b/dom/xbl/test/test_bug481558.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=481558
+-->
+<head>
+ <title>Test for Bug 481558</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+ <link rel="stylesheet" type="text/css"
+ href="file_bug481558css.sjs?id=id1">
+ <link rel="stylesheet" type="text/css"
+ href="file_bug481558css.sjs?id=id2&server=example.com">
+ <link rel="stylesheet" type="text/css" href="http://example.com/tests/dom/xbl/test/file_bug481558css.sjs?id=id3">
+ <link rel="stylesheet" type="text/css" href="http://example.com/tests/dom/xbl/test/file_bug481558css.sjs?id=id4&server=localhost:8888">
+</head>
+<body onload="runTest();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=481558">Mozilla Bug 481558</a>
+<p id="id1"></p>
+<p id="id2"></p>
+<p id="id3"></p>
+<p id="id4"></p>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+function runTest() {
+ is ($('id1').xblBoundProperty, 1, "XBL should be attached");
+ is ($('id2').xblBoundProperty, undefined, "XBL shouldn't be attached");
+ is ($('id3').xblBoundProperty, undefined, "XBL shouldn't be attached");
+ is ($('id4').xblBoundProperty, undefined, "XBL shouldn't be attached");
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug526178.xhtml b/dom/xbl/test/test_bug526178.xhtml
new file mode 100644
index 000000000..602a405a1
--- /dev/null
+++ b/dom/xbl/test/test_bug526178.xhtml
@@ -0,0 +1,80 @@
+<html xmlns="http://www.w3.org/1999/xhtml" style="display: none">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=526178
+-->
+<head>
+ <title>Test for Bug 526178</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <style id="sheet">
+ #content * {
+ display: block;
+ -moz-binding: url("#binding");
+ }
+ </style>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="binding">
+ <implementation>
+ <constructor>
+ var win = XPCNativeWrapper.unwrap(window);
+ win.logString += this.localName;
+ win.bindingDone();
+ </constructor>
+ </implementation>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=526178">Mozilla Bug 526178</a>
+<div id="content">
+ <a>
+ <b>
+ <c/>
+ </b>
+ <d/>
+ <e style="display: inline">
+ <f style="display: inline">
+ <g style="display: inline"/>
+ <h style="display: none"/>
+ <i style="display: inline"/>
+ </f>
+ <j style="display: none"/>
+ <k style="display: inline">
+ <l style="display: inline"/>
+ <m/>
+ <n style="display: inline"/>
+ </k>
+ </e>
+ <o style="display: none"/>
+ <p/>
+ </a>
+</div>
+<p id="display">
+</p>
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 526178 **/
+var logString = "";
+// Add one for the root
+var pendingBindings = $("content").getElementsByTagName("*").length + 1;
+function bindingDone() {
+ if (--pendingBindings == 0) {
+ is(logString, "apoeknmljfihgdbchtml");
+ SimpleTest.finish();
+ }
+}
+
+SimpleTest.waitForExplicitFinish();
+
+// Have to add the rule for the root dynamically so the binding doesn't try
+// to load before bindingDone() is defined.
+$("sheet").sheet.insertRule(':root { -moz-binding: url("#binding"); }', 0);
+document.documentElement.style.display = "";
+
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug542406.xhtml b/dom/xbl/test/test_bug542406.xhtml
new file mode 100644
index 000000000..880d69a8e
--- /dev/null
+++ b/dom/xbl/test/test_bug542406.xhtml
@@ -0,0 +1,44 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=542406
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="foo">
+ <content><children/></content>
+ <implementation>
+ <field name="one" readonly="true">1</field>
+ <field name="three">3</field>
+ </implementation>
+ </binding>
+ </bindings>
+ <title>Test for Bug 542406</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=542406">Mozilla Bug 542406</a>
+<p id="display" style="-moz-binding: url(#foo)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 542406 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ is($("display").one, 1, "Field one not installed?");
+ $("display").one = 2;
+ is($("display").one, 1, "Field one not readonly");
+ is($("display").three, 3, "Field three not installed?");
+ $("display").three = 4;
+ is($("display").three, 4, "Field three readonly?");
+ SimpleTest.finish();
+});
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug591198.html b/dom/xbl/test/test_bug591198.html
new file mode 100644
index 000000000..2c7df3613
--- /dev/null
+++ b/dom/xbl/test/test_bug591198.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=591198
+-->
+<head>
+ <title>Test for Bug 591198</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+</head>
+<body onload="gen.next();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=591198">Mozilla Bug 591198</a>
+<iframe id=iframe></iframe>
+<pre id="test">
+<script class="testbody" type="text/javascript;version=1.8">
+
+SimpleTest.waitForExplicitFinish();
+
+gen = runTest();
+
+function runTest() {
+ let iframe = $('iframe');
+ window.addEventListener("message", function(e) {
+ gen.send(JSON.parse(e.data));
+ }, false);
+
+ iframe.src = "file_bug591198_inner.html";
+ let res = (yield);
+ is(res.widths[0], res.widths[2], "binding was rendered");
+ isnot(res.widths[0], res.widths[1], "binding was rendered");
+ is(res.anonChildCount, 2, "correct number of anon children");
+
+ iframe.src = "http://noxul.example.com/tests/dom/xbl/test/file_bug591198_inner.html";
+ res = (yield);
+ is(res.widths[0], res.widths[1], "binding was not rendered");
+ isnot(res.widths[0], res.widths[2], "binding was not rendered");
+ is("anonChildCount" in res, false, "no anon children");
+
+ SimpleTest.finish();
+ yield undefined;
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug639338.xhtml b/dom/xbl/test/test_bug639338.xhtml
new file mode 100644
index 000000000..e88ff1abc
--- /dev/null
+++ b/dom/xbl/test/test_bug639338.xhtml
@@ -0,0 +1,66 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=403162
+-->
+<head>
+ <title>Test for Bug 639338</title>
+ <script type="text/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">
+ <binding id="test">
+ <handlers>
+ <handler event="DOMMouseScroll" action="XPCNativeWrapper.unwrap(window).triggerCount++" allowuntrusted="true"/>
+ <handler event="DOMMouseScroll" modifiers="shift" action="XPCNativeWrapper.unwrap(window).shiftCount++" allowuntrusted="true"/>
+ <handler event="DOMMouseScroll" modifiers="control" action="XPCNativeWrapper.unwrap(window).controlCount++" allowuntrusted="true"/>
+ </handlers>
+ </binding>
+ </bindings>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=639338">Mozilla Bug 639338</a>
+<p id="display" style="-moz-binding: url(#test)"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+var triggerCount = 0;
+var shiftCount = 0;
+var controlCount = 0;
+
+function dispatchEvent(t, controlKey, shiftKey) {
+ var ev = document.createEvent("MouseScrollEvents");
+ ev.initMouseScrollEvent("DOMMouseScroll", true, true, window, 0, 0, 0, 0, 0, controlKey, false, shiftKey, false, 0, null, 0);
+ t.dispatchEvent(ev);
+}
+
+/** Test for Bug 403162 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+ var t = $("display");
+ is(triggerCount, 0, "Haven't dispatched event");
+
+ dispatchEvent(t, false, false);
+ is(triggerCount, 1, "Dispatched once");
+ is(shiftCount, 0, "Not shift");
+ is(controlCount, 0, "Not control");
+
+ dispatchEvent(t, false, true);
+ is(triggerCount, 2, "Dispatched twice");
+ is(shiftCount, 1, "Shift");
+ is(controlCount, 0, "Not control");
+
+ dispatchEvent(t, true, false);
+ is(triggerCount, 3, "Dispatched thrice");
+ is(shiftCount, 1, "Not shift");
+ is(controlCount, 1, "Control");
+
+ SimpleTest.finish();
+});
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug721452.xul b/dom/xbl/test/test_bug721452.xul
new file mode 100644
index 000000000..d1393d542
--- /dev/null
+++ b/dom/xbl/test/test_bug721452.xul
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<script>
+ok(true, "Handler with empty action didn't crash")
+</script>
+
+<body xmlns="http://www.w3.org/1999/xhtml"/>
+
+<box style="-moz-binding: url(#binding)"/>
+
+<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+ <xbl:binding id="binding">
+ <xbl:content/>
+ <xbl:handlers>
+ <xbl:handler nt="action" action=""/>
+ </xbl:handlers>
+ </xbl:binding>
+</xbl:bindings>
+
+</window>
diff --git a/dom/xbl/test/test_bug723676.xul b/dom/xbl/test/test_bug723676.xul
new file mode 100644
index 000000000..29561a57e
--- /dev/null
+++ b/dom/xbl/test/test_bug723676.xul
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<script>
+ok(true, "Method with empty body didn't crash");
+</script>
+
+<body xmlns="http://www.w3.org/1999/xhtml"/>
+
+<box style="-moz-binding: url(#binding)"/>
+
+<xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+ <xbl:binding id="binding">
+ <xbl:implementation>
+ <xbl:method name="init"/>
+ </xbl:implementation>
+ </xbl:binding>
+</xbl:bindings>
+
+
+</window>
diff --git a/dom/xbl/test/test_bug772966.xul b/dom/xbl/test/test_bug772966.xul
new file mode 100644
index 000000000..d58d5525d
--- /dev/null
+++ b/dom/xbl/test/test_bug772966.xul
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=772966
+-->
+<window title="Mozilla Bug 772966"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="runTest()">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=772966"
+ target="_blank">Mozilla Bug 772966</a>
+ </body>
+
+ <script>
+ function runTest() {
+ is(document.getElementById('b').test(123, 123, 123), 2, "Should have 2 params.");
+ }
+ </script>
+
+ <box id="b" style="-moz-binding: url(#binding)"/>
+
+ <xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl">
+ <xbl:binding id="binding">
+ <xbl:implementation>
+ <xbl:method name="test">
+ <xbl:parameter name="p1"/>
+ <xbl:parameter name=""/>
+ <xbl:parameter name="p2"/>
+ <xbl:body><![CDATA[
+ return arguments.callee.length;
+ ]]></xbl:body>
+ </xbl:method>
+ </xbl:implementation>
+ </xbl:binding>
+ </xbl:bindings>
+
+
+</window>
diff --git a/dom/xbl/test/test_bug790265.xhtml b/dom/xbl/test/test_bug790265.xhtml
new file mode 100644
index 000000000..1ce8363a7
--- /dev/null
+++ b/dom/xbl/test/test_bug790265.xhtml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=790265
+-->
+<head>
+ <title>Test for Bug 790265</title>
+ <script type="text/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">
+ <binding id="binding">
+ <implementation>
+ <method name="foo" exposeToUntrustedContent="true">
+ <body><![CDATA[
+ return this;
+ ]]></body>
+ </method>
+ </implementation>
+ </binding>
+ </bindings>
+ <style>
+ #toBind { display: none; }
+ #toBind.bound { -moz-binding: url(#binding); }
+ </style>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=790265">Mozilla Bug 790265</a>
+<p id="display"></p>
+<div id="content">
+ <div id="toBind">Bound element</div>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+ SimpleTest.waitForExplicitFinish();
+ // Flush out style on $("toBind")
+ $("toBind").offsetWidth;
+ ok(!("foo" in $("toBind")), "Should not have binding applied");
+ is(getComputedStyle($("toBind")).MozBinding, "none",
+ "Computed binding should be none");
+ $("toBind").className = "bound";
+ // Flush the style change, so we kick off the binding load before onload
+ // fires and thus block onload.
+ $("toBind").offsetWidth;
+ addLoadEvent(function() {
+ ok("foo" in $("toBind"), "Should have binding applied");
+ is($("toBind").foo(), $("toBind"), "Should have correct return value");
+ SimpleTest.finish();
+ });
+]]>
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xbl/test/test_bug821850.html b/dom/xbl/test/test_bug821850.html
new file mode 100644
index 000000000..9ac7cdc61
--- /dev/null
+++ b/dom/xbl/test/test_bug821850.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=821850
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 821850</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 XBL scope behavior. **/
+ SimpleTest.waitForExplicitFinish();
+
+ // Embed the real test. It will take care of everything else.
+ //
+ // NB: This two-layer setup used to exist because XBL scopes were behind a
+ // pref, and we wanted to make sure that we properly set the pref before
+ // loading the real test. This stuff is no longer behind a pref, but we just
+ // leave the structure as-is for expediency.
+ function setup() {
+ $('ifr').setAttribute('src', 'file_bug821850.xhtml');
+ }
+
+ </script>
+</head>
+<body onload="setup();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=821850">Mozilla Bug 821850</a>
+<p id="display"></p>
+<div id="content">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug844783.html b/dom/xbl/test/test_bug844783.html
new file mode 100644
index 000000000..ba99f08f1
--- /dev/null
+++ b/dom/xbl/test/test_bug844783.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=844783
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 844783</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 XBL running in content scope for XUL-whitelisted domains. **/
+ SimpleTest.waitForExplicitFinish();
+
+ // Disable the automation pref before loading the test to make sure we load
+ // the proper configuration.
+ function setup() {
+ SpecialPowers.pushPrefEnv({clear: [['dom.use_xbl_scopes_for_remote_xul']] }, continueSetup);
+ }
+
+ // Embed the real test. It will take care of everything else.
+ function continueSetup() {
+ $('ifr').setAttribute('src', 'file_bug844783.xhtml');
+ }
+
+ </script>
+</head>
+<body onload="setup();">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=844783">Mozilla Bug 844783</a>
+<p id="display"></p>
+<div id="content">
+<iframe id="ifr"></iframe>
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug872273.xhtml b/dom/xbl/test/test_bug872273.xhtml
new file mode 100644
index 000000000..18417028c
--- /dev/null
+++ b/dom/xbl/test/test_bug872273.xhtml
@@ -0,0 +1,53 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=872273
+-->
+<head>
+ <bindings xmlns="http://www.mozilla.org/xbl">
+ <binding id="foo">
+ <implementation>
+ <method name="throwSomething" exposeToUntrustedContent="true">
+ <body>
+ throw new Error("foopy");
+ </body>
+ </method>
+ </implementation>
+ </binding>
+ </bindings>
+ <title>Test for Bug 872273</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=872273">Mozilla Bug 872273</a>
+<p id="display" style="-moz-binding: url(#foo)"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 872273 **/
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(function() {
+
+ // Prevent the test from failing when the exception hits onerror.
+ SimpleTest.expectUncaughtException();
+
+ // Tell the test to expect exactly one console error with the given parameters,
+ // with SimpleTest.finish as a continuation function.
+ SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('foopy')}]);
+
+ // Schedule the console accounting (and continuation) to run next, right
+ // after we throw (below).
+ SimpleTest.executeSoon(SimpleTest.endMonitorConsole);
+
+ // Throw.
+ $('display').throwSomething();
+});
+
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xbl/test/test_bug944407.xul b/dom/xbl/test/test_bug944407.xul
new file mode 100644
index 000000000..1efc82c03
--- /dev/null
+++ b/dom/xbl/test/test_bug944407.xul
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=944407
+-->
+<window title="Mozilla Bug 944407"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=944407"
+ target="_blank">Mozilla Bug 944407</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for XBL bindings with script disabled. **/
+ SimpleTest.waitForExplicitFinish();
+ const Cu = Components.utils;
+ Cu.import('resource://gre/modules/Services.jsm');
+
+ function go() {
+
+ // Disable javascript, and load the frame.
+ function loadFrame() {
+ ok(!Services.prefs.getBoolPref('javascript.enabled'), "Javascript should be disabled");
+ $('ifr').setAttribute('src', 'http://mochi.test:8888/tests/dom/xbl/test/file_bug944407.html');
+ }
+ SpecialPowers.pushPrefEnv({ set: [['javascript.enabled', false]] }, loadFrame);
+ }
+
+ function finish() {
+ SimpleTest.finish();
+ }
+
+ addLoadEvent(go);
+ ]]>
+ </script>
+ <iframe id='ifr' />
+</window>
diff --git a/dom/xbl/test/test_bug950909.xul b/dom/xbl/test/test_bug950909.xul
new file mode 100644
index 000000000..2147b0fcd
--- /dev/null
+++ b/dom/xbl/test/test_bug950909.xul
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=950909
+-->
+<window title="Mozilla Bug 950909"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=950909"
+ target="_blank">Mozilla Bug 950909</a>
+ </body>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /*
+ * Test for bug 950909. This has to be a chrome tests because content needs
+ * to apply a chrome binding (file_bug950909.xml), which will only be registered
+ * as a chrome:// URI during mochitest-chrome runs. And the binding has to be
+ * served from a chrome origin, because otherwise implements="nsIFoo" attributes
+ * are ignored. So this test needs 3 files, all told. Ugh.
+ */
+
+ // Just wait. When the iframe loads, it'll apply the binding, which will
+ // trigger the constructor for the binding.
+ SimpleTest.waitForExplicitFinish();
+
+ ]]>
+ </script>
+ <iframe src="http://example.com/tests/dom/xbl/test/file_bug950909.html"/>
+</window>
diff --git a/dom/xbl/test/test_fieldScopeChain.html b/dom/xbl/test/test_fieldScopeChain.html
new file mode 100644
index 000000000..c688ca64f
--- /dev/null
+++ b/dom/xbl/test/test_fieldScopeChain.html
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1095660
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug </title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug **/
+ SimpleTest.waitForExplicitFinish();
+ window.baz = 1;
+ document.baz = 2;
+ addLoadEvent(function() {
+ is(document.querySelector("pre").bar, 2,
+ "Should have document on field scope chain");
+ SimpleTest.finish();
+ });
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1095660">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test" style="-moz-binding: url(file_fieldScopeChain.xml#foo)">
+</pre>
+</body>
+</html>