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

Unified Diff: LayoutTests/fast/dom/Document/document-current-script.html

Issue 14852011: Implement document.currentScript (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 6 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: LayoutTests/fast/dom/Document/document-current-script.html
diff --git a/LayoutTests/fast/dom/Document/document-current-script.html b/LayoutTests/fast/dom/Document/document-current-script.html
new file mode 100644
index 0000000000000000000000000000000000000000..3084c69da1d61721583b01fd101e22e0df519938
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/document-current-script.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<body>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+
+jsTestIsAsync = true;
+
+description('Test basic usage of document.currentScript')
+
+function logCurrentScript() {
+ var script = document.currentScript
+ var s = '&lt;script id="' + script.id + '"';
+ if (script.src)
+ s += ' src="..."';
+ if (script.defer)
+ s += ' defer';
+ if (script.async)
+ s += ' async';
+ s += '>';
+ debug(s);
+}
+
+</script>
+<script id="a">
+logCurrentScript();
+</script>
+<script id="b">
+logCurrentScript();
+</script>
+<script id="c">
+logCurrentScript();
+document.write('<script id="d">logCurrentScript();<\/script>');
+logCurrentScript();
+</script>
+
+<script id="defer-1" defer src="resources/log-current-script.js"></script>
+<script id="e" src="resources/log-current-script.js"></script>
+
+
+<script id="f">
+logCurrentScript();
+document.write('<script id="g" src="resources/log-current-script.js"><\/script>');
+logCurrentScript();
+</script>
+
+<script id="h">
+logCurrentScript();
+document.write('<script id="defer-2" defer src="resources/log-current-script.js"><\/script>');
+logCurrentScript();
+</script>
+
+<script id="i">
+logCurrentScript();
+
+var script = document.createElement('script');
+script.id = 'j';
+script.textContent = 'logCurrentScript();';
+script.async = false;
+script.defer = false;
+document.head.appendChild(script);
+
+logCurrentScript();
+</script>
+
+<script src="../../js/resources/js-test-post.js"></script>
+<script>
+window.onload = function() {
+ shouldBeNull('document.currentScript');
+ finishJSTest();
+};
+</script>
+</body>
+</html>
+
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Document/document-current-script-async.html » ('j') | Source/core/dom/ScriptElement.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698