Bug 1396761, add a testcase ensuring creating customized built-in elements rethrow the exception from the constructor, r=mrbkap
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 21 Jun 2018 20:59:28 +0300
changeset 477511 cc4b83096613ad445e0951e98dfd2b6fcc24bb63
parent 477510 8fc73342ecd9e600923f210d19e458257626f007
child 477512 9483bb48c57a4da7f9dfeba01d1573038a49d9c2
push id9385
push userdluca@mozilla.com
push dateFri, 22 Jun 2018 15:47:18 +0000
treeherdermozilla-beta@82a9a1027e2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1396761
milestone62.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 1396761, add a testcase ensuring creating customized built-in elements rethrow the exception from the constructor, r=mrbkap
testing/web-platform/tests/custom-elements/Document-createElement.html
--- a/testing/web-platform/tests/custom-elements/Document-createElement.html
+++ b/testing/web-platform/tests/custom-elements/Document-createElement.html
@@ -358,16 +358,41 @@ test(function () {
 
     exceptionToThrow = false;
     var instance = document.createElement('throw-custom-element');
     assert_true(instance instanceof ThrowCustomElement);
     assert_equals(instance.localName, 'throw-custom-element');
 
 }, 'document.createElement must report an exception thrown by a custom element constructor');
 
+test(function () {
+    var exceptionToThrow = {name: 'exception thrown by a custom constructor'};
+    class ThrowCustomBuiltinElement extends HTMLDivElement {
+        constructor()
+        {
+            super();
+            if (exceptionToThrow)
+                throw exceptionToThrow;
+        }
+    };
+    customElements.define('throw-custom-builtin-element', ThrowCustomBuiltinElement, { extends: 'div' });
+
+    assert_throws(exceptionToThrow, function () { new ThrowCustomBuiltinElement; });
+    var instance;
+    assert_reports(exceptionToThrow, function () { instance = document.createElement('div', { is: 'throw-custom-builtin-element' }); });
+    assert_equals(instance.localName, 'div');
+    assert_true(instance instanceof HTMLDivElement);
+
+    exceptionToThrow = false;
+    var instance = document.createElement('div', { is: 'throw-custom-builtin-element' });
+    assert_true(instance instanceof ThrowCustomBuiltinElement);
+    assert_equals(instance.localName, 'div');
+
+}, 'document.createElement must report an exception thrown by a custom built-in element constructor');
+
 test(() => {
   class MyElement extends HTMLDivElement {}
 
   // createElement with unknown 'is' should not throw.
   // https://github.com/w3c/webcomponents/issues/608
   let div = document.createElement('div', { is: 'my-div' });
   assert_false(div instanceof MyElement);
   assert_false(div.hasAttribute('is'));