Bug 1348099 part 2 - Add tests for DOM Xrays that properties are exposed to only proper object types. r=bz
authorTing-Yu Chou <janus926@gmail.com>
Thu, 22 Jun 2017 14:43:11 +0800
changeset 366825 c2b306e94329
parent 366824 3c9580f79684
child 366826 246124863988
push id45755
push usertchou@mozilla.com
push dateFri, 30 Jun 2017 05:37:58 +0000
treeherderautoland@246124863988 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1348099
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1348099 part 2 - Add tests for DOM Xrays that properties are exposed to only proper object types. r=bz MozReview-Commit-ID: Iu86lAviFJK
dom/bindings/test/test_dom_xrays.html
--- a/dom/bindings/test/test_dom_xrays.html
+++ b/dom/bindings/test/test_dom_xrays.html
@@ -214,16 +214,73 @@ function test()
   is(storage.foo, "bar", "Should have a 'foo' property");
   ok('foo' in storage, "Really should have a 'foo' property");
   is(storage.getItem("foo"), "bar", "Should have an item named 'foo'");
   delete storage.foo
   is(storage.foo, undefined, "Should not have a 'foo' property again");
   ok(!('foo' in storage), "Really should not have a 'foo' property again");
   is(storage.getItem("foo"), null, "Should not have an item named 'foo' again");
 
+  // Non-static properties are not exposed on interface objects or instances.
+  is(win.HTMLInputElement.checkValidity, undefined,
+     "Shouldn't see non-static property on interface objects");
+  is(Object.getOwnPropertyDescriptor(win.HTMLInputElement, "checkValidity"), undefined,
+     "Shouldn't see non-static property on interface objects");
+  is(Object.getOwnPropertyNames(win.HTMLInputElement).indexOf("checkValidity"), -1,
+     "Shouldn't see non-static property on interface objects");
+  isnot(typeof doc.createElement("input").checkValidity, "undefined",
+        "Should see non-static property on prototype objects");
+  is(Object.getOwnPropertyDescriptor(doc.createElement("input"), "checkValidity"), undefined,
+     "Shouldn't see non-static property on instances");
+  isnot(typeof Object.getOwnPropertyDescriptor(win.HTMLInputElement.prototype, "checkValidity"), "undefined",
+        "Should see non-static property on prototype objects");
+
+  // Static properties are not exposed on prototype objects or instances.
+  isnot(typeof win.URL.createObjectURL, "undefined",
+        "Should see static property on interface objects");
+  isnot(typeof Object.getOwnPropertyDescriptor(win.URL, "createObjectURL"), "undefined",
+        "Should see static property on interface objects");
+  isnot(Object.getOwnPropertyNames(win.URL).indexOf("createObjectURL"), -1,
+        "Should see static property on interface objects");
+  is(new URL('http://example.org').createObjectURL, undefined,
+     "Shouldn't see static property on instances and prototype ojbects");
+  is(Object.getOwnPropertyDescriptor(new URL('http://example.org'), "createObjectURL"), undefined,
+     "Shouldn't see static property on instances");
+  is(Object.getOwnPropertyDescriptor(win.URL.prototype, "createObjectURL"), undefined,
+     "Shouldn't see static property on prototype objects");
+
+  // Unforgeable properties are not exposed on prototype objects or interface
+  // objects.
+  is(Window.document, undefined,
+     "Shouldn't see unforgeable property on interface objects");
+  is(Object.getOwnPropertyDescriptor(Window, "document"), undefined,
+     "Shouldn't see unforgeable property on interface objects");
+  is(Object.getOwnPropertyNames(Window).indexOf("document"), -1,
+     "Shouldn't see unforgeable property on interface objects");
+  isnot(typeof win.document, "undefined",
+        "Should see unforgeable property on instances");
+  isnot(typeof Object.getOwnPropertyDescriptor(win, "document"), "undefined",
+        "Should see unforgeable property on instances");
+  is(Object.getOwnPropertyDescriptor(Window.prototype, "document"), undefined,
+     "Shouldn't see unforgeable property on prototype objects");
+
+  // Constant properties are not exposted on instances.
+  isnot(typeof win.Node.ELEMENT_NODE, "undefined",
+        "Should see constant property on interface objects");
+  isnot(typeof Object.getOwnPropertyDescriptor(win.Node, "ELEMENT_NODE"), "undefined",
+        "Should see constant property on interface objects");
+  isnot(Object.getOwnPropertyNames(win.Node).indexOf("ELEMENT_NODE"), -1,
+        "Should see constant property on interface objects");
+  isnot(typeof elem.ELEMENT_NODE, "undefined",
+        "Should see constant property on prototype objects");
+  is(Object.getOwnPropertyDescriptor(elem, "ELEMENT_NODE"), undefined,
+     "Shouldn't see constant property on instances");
+  isnot(typeof Object.getOwnPropertyDescriptor(win.Node.prototype, "ELEMENT_NODE"), "undefined",
+        "Should see constant property on prototype objects");
+
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(test);
 
 </script>
 </pre>