summaryrefslogtreecommitdiffstats
path: root/dom/html/test/test_bug1081037.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/html/test/test_bug1081037.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/html/test/test_bug1081037.html')
-rw-r--r--dom/html/test/test_bug1081037.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/dom/html/test/test_bug1081037.html b/dom/html/test/test_bug1081037.html
new file mode 100644
index 000000000..9d8782580
--- /dev/null
+++ b/dom/html/test/test_bug1081037.html
@@ -0,0 +1,133 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1081037
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1081037</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 1081037 **/
+
+function shouldThrow(fun, msg, ex, todo) {
+ try {
+ fun();
+ ok(todo, msg);
+ } catch (e) {
+ ok(new RegExp(ex).test(e), msg + " (thrown:" + e + ")")
+ }
+}
+
+var Foo = document.registerElement('x-foo', {
+ prototype: {bar: 5}
+});
+
+Foo.prototype.bar = 6;
+var foo = new Foo();
+is(foo.bar, 6, "prototype of the ctor returned from registerElement works");
+
+var protoDesc = Object.getOwnPropertyDescriptor(Foo, "prototype");
+is(protoDesc.configurable, false, "proto should be non-configurable");
+is(protoDesc.enumerable, false, "proto should be non-enumerable");
+is(protoDesc.writable, false, "proto should be non-writable");
+
+// TODO: FIXME!
+shouldThrow(function() {
+ document.registerElement('x-foo2', {
+ prototype: Foo.prototype
+ });
+ },
+ "if proto is an interface prototype object, registerElement should throw",
+ "not supported",
+ /* todo = */ true);
+
+var nonConfigReadonlyProto = Object.create(HTMLElement.prototype,
+ { constructor: { configurable: false, writable: false, value: 42 } });
+
+shouldThrow(function() {
+ document.registerElement('x-nonconfig-readonly', {
+ prototype: nonConfigReadonlyProto
+ });
+ },
+ "non-configurable and not-writable constructor property",
+ "not supported");
+
+
+// this is not defined in current spec:
+var readonlyProto = Object.create(HTMLElement.prototype,
+ { constructor: { configurable: true, writable: false, value: 42 } });
+
+var Readonly = document.registerElement('x-nonconfig-readonly', {
+ prototype: readonlyProto
+});
+
+is(Readonly.prototype, readonlyProto, "configurable readonly constructor property");
+
+var handler = {
+ getOwnPropertyDescriptor: function(target, name) {
+ return name == "constructor" ? undefined : Object.getOwnPropertyDescriptor(target,name);
+ },
+ defineProperty: function(target, name, propertyDescriptor) {
+ if (name == "constructor") {
+ throw "spec this";
+ }
+
+ return Object.defineProperty(target, name, propertyDescriptor);
+ },
+ has: function(target, name) {
+ if (name == "constructor") {
+ return false;
+ }
+ return name in target;
+ }
+};
+var proxy = new Proxy({}, handler);
+
+shouldThrow(function() {
+ document.registerElement('x-proxymagic', {
+ prototype: proxy
+ });
+ },
+ "proxy magic",
+ "spec this");
+
+var getOwn = 0;
+var defineProp = 0;
+var handler2 = {
+ getOwnPropertyDescriptor: function(target, name) {
+ if (name == "constructor") {
+ getOwn++;
+ }
+ return Object.getOwnPropertyDescriptor(target,name);
+ },
+ defineProperty: function(target, name, propertyDescriptor) {
+ if (name == "constructor") {
+ defineProp++;
+ }
+ return Object.defineProperty(target, name, propertyDescriptor);
+ }
+};
+var proxy2 = new Proxy({}, handler2);
+
+document.registerElement('x-proxymagic2', {
+ prototype: proxy2
+});
+
+is(getOwn, 1, "number of getOwnPropertyDescriptor calls from registerElement: " + getOwn);
+is(defineProp, 1, "number of defineProperty calls from registerElement: " + defineProp);
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1081037">Mozilla Bug 1081037</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>