4 https://bugzilla.mozilla.org/show_bug.cgi?id=1021066
8 <title>Test for Bug
1021066</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1021066">Mozilla Bug
1021066</a>
15 <div id=
"content" style=
"display: none">
16 <iframe id=
"t" src=
"http://example.org/tests/dom/bindings/test/file_proxies_via_xray.html"></iframe>
19 <script type=
"application/javascript">
21 /** Test for Bug
1021066 **/
24 "use strict"; // So we'll get exceptions on sets
25 var doc = document.getElementById(
"t").contentWindow.document;
26 ok(!(
"x" in doc),
"Should have an Xray here");
27 is(doc.x, undefined,
"Really should have an Xray here");
28 is(doc.wrappedJSObject.x,
5,
"And wrapping the right thing");
30 // Test overridebuiltins binding without named setter
31 is(doc.y, doc.getElementById(
"y"),
32 "Named getter should work on Document");
35 ok(false,
"Should have thrown on set of readonly property on Document");
37 ok(/read-only/.test(e.message),
38 "Threw the right exception on set of readonly property on Document");
42 is(doc.w,
5,
"Should be able to set things that are not named props");
44 // Test non-overridebuiltins binding without named setter
45 var l = doc.getElementsByTagName(
"img");
46 is(l.y, doc.getElementById(
"y"),
47 "Named getter should work on HTMLCollection");
50 ok(false,
"Should have thrown on set of readonly property on HTMLCollection");
52 ok(/read-only/.test(e.message),
53 "Should throw the right exception on set of readonly property on HTMLCollection");
57 ok(false,
"Should have thrown on set of indexed property on HTMLCollection");
59 ok(/doesn't have an indexed property setter/.test(e.message),
60 "Should throw the right exception on set of indexed property on HTMLCollection");
63 // Test overridebuiltins binding with named setter
64 var d = doc.documentElement.dataset;
66 // Check that this actually got passed on to the underlying object.
67 is(d.wrappedJSObject.foo,
"bar",
68 "Set should get forwarded to the underlying object");
69 is(doc.documentElement.getAttribute(
"data-foo"),
"bar",
70 "Attribute setter should have been called");
72 // Check that this actually got passed on to the underlying object.
73 is(d.wrappedJSObject.foo,
"baz",
74 "Set should get forwarded to the underlying object again");
75 is(doc.documentElement.getAttribute(
"data-foo"),
"baz",
76 "Attribute setter should have been called again");
78 // Test non-overridebuiltins binding with named setter
79 var s = doc.defaultView.localStorage;
80 s.test_proxies_via_xray =
"bar";
81 // Check that this actually got passed on to the underlying object.
82 is(s.wrappedJSObject.test_proxies_via_xray,
"bar",
83 "Set should get forwarded to the underlying object without overridebuiltins");
84 s.test_proxies_via_xray =
"baz";
85 // Check that this actually got passed on to the underlying object.
86 is(s.wrappedJSObject.test_proxies_via_xray,
"baz",
87 "Set should get forwarded to the underlying object again without overridebuiltins");
92 SimpleTest.waitForExplicitFinish();