Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Document-prototype-currentScript.html

Issue 1962003002: Import web-platform-tests@41d6911b288a9624c249a406b9bf51607a2dd04d (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Skip submit-entity-body.html Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Document-prototype-currentScript.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Document-prototype-currentScript.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Document-prototype-currentScript.html
new file mode 100644
index 0000000000000000000000000000000000000000..e902ec514951d4769daa843868fc24383e0f2e9b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/Document-prototype-currentScript.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>HTML: Document.prototype.currentScript</title>
+<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
+<meta name="assert" content="If the script element is in a document, then set the script element's node document's currentScript attribute to the script element.">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script id="outerScriptElement">
+
+var outerScriptElement = document.currentScript;
+
+function testInlineScript(mode)
+{
+ test(function () {
+ var host = document.createElement('div');
+ var shadowRoot = host.attachShadow({mode: mode});
+ var scriptElement = document.createElement('script');
+ scriptElement.textContent = 'assert_equals(document.currentScript, outerScriptElement)';
+ shadowRoot.appendChild(scriptElement);
+
+ assert_equals(document.currentScript, outerScriptElement,
+ 'document.currentScript must be set to the currently excusing script element in a document tree before executing a script in a shadow tree');
+ document.body.appendChild(host);
+ assert_equals(document.currentScript, outerScriptElement,
+ 'document.currentScript must be set to the currently excusing script element in a document tree after executing a script in a shadow tree');
+
+ }, 'document.currentScript must not to be set to a script element in a shadow tree in ' + mode + ' mode');
+}
+
+testInlineScript('open');
+testInlineScript('closed');
+
+var executeExternalScript = null;
+var testedScriptElement = null;
+function executeNextTest()
+{
+ var testCase = asyncScriptTests.shift();
+ var mode = testCase.mode;
+ if (!testCase)
+ return;
+
+ testCase.test.step(function () {
+ testedScriptElement = document.createElement('script');
+ testedScriptElement.src = 'resources/Document-prototype-currentScript-helper.js';
+
+ if (mode !== null) {
+ var host = document.createElement('div');
+ var shadowRoot = host.attachShadow({mode: mode});
+ shadowRoot.appendChild(testedScriptElement);
+ document.body.appendChild(host);
+ } else {
+ document.body.appendChild(testedScriptElement);
+ }
+
+ if (testCase.remove)
+ testedScriptElement.parentNode.removeChild(testedScriptElement);
+ });
+
+ executeExternalScript = function () {
+ testCase.test.step(function () {
+ assert_equals(document.currentScript, testCase.expected());
+ });
+ testCase.test.done();
+ setTimeout(executeNextTest, 1);
+ }
+}
+
+var asyncScriptTests = [
+ {
+ test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
+ mode: null, remove: false, expected: function () { return testedScriptElement; }},
+ {
+ test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
+ mode: null, remove: true, expected: function () { return testedScriptElement; }},
+ {
+ test: async_test('document.currentScript must not be set to a script element that loads an external script in an open shadow tree'),
+ mode: 'open', remove: false, expected: function () { return null; }},
+ {
+ test: async_test('document.currentScript must not be set to a script element that loads an external script in a closed shadow tree'),
+ mode: 'closed', remove: false, expected: function () { return null; }},
+ {
+ test: async_test('document.currentScript must be set to a script element that loads an external script that was in an open shadow tree and then removed'),
+ mode: 'open', remove: true, expected: function () { return testedScriptElement; }},
+ {
+ test: async_test('document.currentScript must be set to a script element that loads an external script that was in a closed shadow tree and then removed'),
+ mode: 'closed', remove: true, expected: function () { return testedScriptElement; }},
+];
+
+executeNextTest();
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698