summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-10-07 19:17:32 +0000
committermorrita@chromium.org <morrita@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-10-07 19:17:32 +0000
commiteab1bc1ee26aca40ed50792d470f1b8b505bf96e (patch)
tree9ac8063dec9a9e807a70324e7c2e4dc3f24f9a24 /third_party/WebKit
parent453169341325dd09447fd79d66d2a68dd10844e5 (diff)
downloadchromium_src-eab1bc1ee26aca40ed50792d470f1b8b505bf96e.zip
chromium_src-eab1bc1ee26aca40ed50792d470f1b8b505bf96e.tar.gz
chromium_src-eab1bc1ee26aca40ed50792d470f1b8b505bf96e.tar.bz2
[HTML Imports] Add a testcase for "element removed flag".
This change adds a test for "element removed flag" concept in the spec: https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-element-removed-flag Blink already behaves in this way and this test is just for capturing current behavior. TEST=import-element-removed-flag.html R=dglazkov@chromium.org,rafaelw@chromium.org BUG=302312 Review URL: https://codereview.chromium.org/26230002 git-svn-id: svn://svn.chromium.org/blink/trunk@159038 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit')
-rw-r--r--third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag-expected.txt17
-rw-r--r--third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag.html82
-rw-r--r--third_party/WebKit/LayoutTests/fast/html/imports/resources/setting-greet-var.html8
3 files changed, 107 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag-expected.txt b/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag-expected.txt
new file mode 100644
index 0000000..b727671
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag-expected.txt
@@ -0,0 +1,17 @@
+This tests 'element removed flag' behavior defined in https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-element-removed-flag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS staticImport.import is non-null.
+PASS staticImport.import is null
+PASS staticImport.import is null
+PASS dynamicImport.import is non-null.
+PASS dynamicImport.import is null
+PASS dynamicImport.import is null
+PASS dynamicImportEager.import is null
+PASS dynamicImportEager.import is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag.html b/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag.html
new file mode 100644
index 0000000..be22656
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/html/imports/import-element-removed-flag.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<script src="../../js/resources/js-test-pre.js"></script>
+<head>
+<link id="staticImportLink" rel="import" href="resources/hello.html">
+</head>
+<body>
+<script>
+description("This tests 'element removed flag' behavior defined in https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-element-removed-flag.");
+window.jsTestIsAsync = true;
+
+function testStaticImport()
+{
+ // element-removed flag is not set at start
+ staticImport = window.staticImportLink;
+ shouldBeNonNull("staticImport.import");
+
+ // element-removed flag is set when the element removed.
+ staticImport.remove();
+ shouldBeNull("staticImport.import");
+
+ // And never comes back even after re-insertion.
+ document.head.appendChild(staticImport);
+ shouldBeNull("staticImport.import");
+}
+
+function testDynamicImport()
+{
+ function check()
+ {
+ shouldBeNonNull("dynamicImport.import");
+ dynamicImport.remove();
+ shouldBeNull("dynamicImport.import");
+ document.head.appendChild(dynamicImport);
+ shouldBeNull("dynamicImport.import");
+
+ testDynamicImportRemovingEagerly();
+ };
+
+ dynamicImport = document.createElement("link");
+ dynamicImport.setAttribute("rel", "import");
+ dynamicImport.setAttribute("href", "resources/bye.html");
+ dynamicImport.addEventListener("load", check);
+ document.head.appendChild(dynamicImport);
+}
+
+function testDynamicImportRemovingEagerly()
+{
+ dynamicImportEager = document.createElement("link");
+ dynamicImportEager.setAttribute("rel", "import");
+ dynamicImportEager.setAttribute("href", "resources/setting-greet-var.html");
+ dynamicImportEager.addEventListener("load", check);
+ document.head.appendChild(dynamicImportEager);
+
+ // Reoving <link> just after appending it.
+ // This should start import loading, but shouldn't make .import visible.
+ dynamicImportEager.remove();
+
+ function check()
+ {
+ if (window.greet != "Hello") {
+ window.setTimeout(check, 0);
+ return;
+ }
+
+ shouldBeNull("dynamicImportEager.import");
+ document.head.appendChild(dynamicImportEager);
+ shouldBeNull("dynamicImportEager.import");
+
+ finishJSTest();
+ }
+
+ window.setTimeout(check, 0);
+}
+
+testStaticImport();
+testDynamicImport();
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/html/imports/resources/setting-greet-var.html b/third_party/WebKit/LayoutTests/fast/html/imports/resources/setting-greet-var.html
new file mode 100644
index 0000000..8995f4c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/html/imports/resources/setting-greet-var.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+window.greet = "Hello";
+</script>
+</head>
+</html>