Index: third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html |
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html |
index 8d4b9528773d4de0e1da63489373b9d60e5e40e0..49de1f0ee4bad82f16081e5e96e2e0d968eb75fc 100644 |
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html |
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/create-element-defined-synchronous.html |
@@ -7,14 +7,6 @@ |
<script> |
'use strict'; |
-function assert_rethrown(func, description) { |
- assert_throws({ name: 'rethrown' }, () => { |
- const err = new Error('check this is rethrown'); |
- err.name = 'rethrown'; |
- func(err); |
- }, description); |
-} |
- |
const expectTypeError = TypeError.prototype; |
const expectNotSupportedError = 'NOT_SUPPORTED_ERR'; |
@@ -46,15 +38,17 @@ function test_create_element_synchronous(description, define_and_create_element) |
}, `${description}Pre-flight check should succeed`); |
test_with_window((w) => { |
- assert_rethrown(err => { |
+ const err = new Error('check this is reported'); |
+ err.name = 'reported'; |
+ assert_reports(w, err, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); throw err; } |
}); |
}); |
- }, `${description}6.1.2. Errors in Construct(C) should be rethrown`); |
+ }, `${description}6.1.2. Errors in Construct(C) should be reported`); |
test_with_window((w) => { |
- assert_throws(expectTypeError, () => { |
+ assert_reports(w, expectTypeError, () => { |
define_and_create_element(w, class { |
constructor() {} |
}); |
@@ -62,7 +56,7 @@ function test_create_element_synchronous(description, define_and_create_element) |
}, `${description}6.1.3. If result does not implement the HTMLElement interface, throw a TypeError`); |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); this.setAttribute('a', 'a'); } |
}); |
@@ -70,20 +64,23 @@ function test_create_element_synchronous(description, define_and_create_element) |
}, `${description}6.1.4. If result\'s attribute list is not empty, then throw a NotSupportedError`); |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); this.appendChild(w.document.createElement('a')); } |
}); |
}, 'should throw if it has a child element'); |
- assert_throws(expectNotSupportedError, () => { |
+ }, `${description}6.1.5. If result has children, then throw a NotSupportedError`); |
+ |
+ test_with_window((w) => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
- constructor() { super(); this.appendChild(w.document.createTextNode('a')); } |
+ constructor() { super(); this.append('a'); } |
}); |
}, 'should throw if it has a child text node'); |
}, `${description}6.1.5. If result has children, then throw a NotSupportedError`); |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); w.document.createElement('div').appendChild(this); } |
}); |
@@ -91,25 +88,25 @@ function test_create_element_synchronous(description, define_and_create_element) |
}, `${description}6.1.6. If result\'s parent is not null, then throw a NotSupportedError`); |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); return w.document.implementation.createHTMLDocument().createElement('div'); } |
}); |
}); |
}, `${description}6.1.7. If result\'s node document is not document, then throw a NotSupportedError`); |
- /* This is not testsable today, see https://github.com/whatwg/html/issues/1402 |
+ // See the note in step 6.1.8. In future, it may be possible to throw |
+ // NotSupportedError for some elements. |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectTypeError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); return w.document.createElementNS('http://www.w3.org/2000/svg', 'g'); } |
}); |
}); |
- }, `${description}6.1.8. If result\'s namespace is not the HTML namespace, then throw a NotSupportedError`); |
- */ |
+ }, `${description}6.1.8. If result\'s namespace is not the HTML namespace, then throw (a NotSupportedError, currently TypeError)`); |
test_with_window((w) => { |
- assert_throws(expectNotSupportedError, () => { |
+ assert_reports(w, expectNotSupportedError, () => { |
define_and_create_element(w, class extends w.HTMLElement { |
constructor() { super(); return document.createElement('div'); } |
}); |