
This diff was generated by running: find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/assert_throws\(([ \n]*)\{ *[\"']?name[\"']? *: *['\"](TypeError|Error)[\"'] *\} *(, *.)/assert_throws_js(\1\2\3/gs" And then manually fixing up whitespace. Bug: 1051932 Change-Id: I36cd1e17f36e92fe4a28461189f058f0fb11885e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080432 Auto-Submit: Stephen McGruer <smcgruer@chromium.org> Reviewed-by: Luke Z <lpz@chromium.org> Commit-Queue: Stephen McGruer <smcgruer@chromium.org> Cr-Commit-Position: refs/heads/master@{#746022}
31 lines
1.5 KiB
HTML
31 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<script src='../resources/testharness.js'></script>
|
|
<script src='../resources/testharnessreport.js'></script>
|
|
<script src='resources/shadow-dom.js'></script>
|
|
<div id='host1'></div>
|
|
<div id='host2'></div>
|
|
<div id='host3'></div>
|
|
<script>
|
|
'use strict';
|
|
|
|
test(() => {
|
|
let root1 = host1.attachShadow({mode: 'open'});
|
|
assert_not_equals(root1, null, 'Attach open shadow root should succeed.');
|
|
assert_equals(Object.getPrototypeOf(root1), ShadowRoot.prototype,
|
|
'ShadowRoot object should be returned by attachShadow({mode:"open"}).');
|
|
|
|
let root2 = host2.attachShadow({mode: 'closed'});
|
|
assert_not_equals(root2, null, 'Attach closed shadow root should succeed.');
|
|
assert_equals(Object.getPrototypeOf(root2), ShadowRoot.prototype,
|
|
'ShadowRoot object should be returned by attachShadow({mode:"closed"}).');
|
|
|
|
assert_throws_js(TypeError, () => { host3.attachShadow({mode: 'illegal'}); },
|
|
'Attach shadow root whose mode is neither open nor closed should throw TypeError.');
|
|
|
|
assert_throws_dom('NotSupportedError', () => { host1.attachShadow({mode: 'open'}); },
|
|
'Attach shadow on a host which has open shadow root will raise NotSupportedError exception.');
|
|
assert_throws_dom('NotSupportedError', () => { host2.attachShadow({mode: 'open'}); },
|
|
'Attach shadow on a host wich has closed shadow root will raise NotSupportedError exception.');
|
|
}, 'Test for Element.attachShadow() with mode parameter.');
|
|
</script>
|