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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/dataset-xhtml.xhtml

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 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/fast/dom/dataset-xhtml.xhtml
diff --git a/third_party/WebKit/LayoutTests/fast/dom/dataset-xhtml.xhtml b/third_party/WebKit/LayoutTests/fast/dom/dataset-xhtml.xhtml
index cde5e7bb1058ac337ceea752c54fe7302f5e2e33..522f32c2ab105b5dd6642ef0118f1133430b3552 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/dataset-xhtml.xhtml
+++ b/third_party/WebKit/LayoutTests/fast/dom/dataset-xhtml.xhtml
@@ -5,6 +5,99 @@
<script src="../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/dataset-xhtml.js"></script>
+<script>
+description("This tests element.dataset for XHTML.");
+
+function testGet(attr, expected)
+{
+ var d = document.createElement("div");
+ d.setAttribute(attr, "value");
+ return d.dataset[expected] == "value";
+}
+
+shouldBeTrue("testGet('data-foo', 'foo')");
+shouldBeTrue("testGet('data-foo-bar', 'fooBar')");
+shouldBeTrue("testGet('data--', '-')");
+shouldBeTrue("testGet('data--foo', 'Foo')");
+shouldBeTrue("testGet('data---foo', '-Foo')");
+shouldBeTrue("testGet('data-', '')");
+shouldBeTrue("testGet('data-\xE0', '\xE0')");
+debug("");
+
+function matchesNothingInDataset(attr)
+{
+ var d = document.createElement("div");
+ d.setAttribute(attr, "value");
+
+ var count = 0;
+ for (var item in d.dataset)
+ count++;
+ return count == 0;
+}
+
+shouldBeTrue("matchesNothingInDataset('dataFoo')");
+shouldBeTrue("matchesNothingInDataset('data-Foo')");
+debug("");
+
+function testSet(prop, expected)
+{
+ var d = document.createElement("div");
+ d.dataset[prop] = "value";
+ return d.getAttribute(expected) == "value";
+}
+
+shouldBeTrue("testSet('foo', 'data-foo')");
+shouldBeTrue("testSet('fooBar', 'data-foo-bar')");
+shouldBeTrue("testSet('-', 'data--')");
+shouldBeTrue("testSet('Foo', 'data--foo')");
+shouldBeTrue("testSet('-Foo', 'data---foo')");
+shouldBeTrue("testSet('', 'data-')");
+shouldBeTrue("testSet('\xE0', 'data-\xE0')");
+debug("");
+
+shouldThrow("testSet('-foo', 'dummy')", '"SyntaxError: Failed to set the \'-foo\' property on \'DOMStringMap\': \'-foo\' is not a valid property name."');
+shouldThrow("testSet('foo\x20', 'dummy')", '"InvalidCharacterError: Failed to set the \'foo\x20\' property on \'DOMStringMap\': \'data-foo\x20\' is not a valid attribute name."');
+shouldThrow("testSet('foo\uF900', 'dummy')", '"InvalidCharacterError: Failed to set the \'foo\uF900\' property on \'DOMStringMap\': \'data-foo\uF900\' is not a valid attribute name."');
+debug("");
+
+function testDelete(attr, prop)
+{
+ var d = document.createElement("div");
+ d.setAttribute(attr, "value");
+ delete d.dataset[prop];
+ return d.getAttribute(attr) != "value";
+}
+
+shouldBeTrue("testDelete('data-foo', 'foo')");
+shouldBeTrue("testDelete('data-foo-bar', 'fooBar')");
+shouldBeTrue("testDelete('data--', '-')");
+shouldBeTrue("testDelete('data--foo', 'Foo')");
+shouldBeTrue("testDelete('data---foo', '-Foo')");
+shouldBeTrue("testDelete('data-', '')");
+shouldBeTrue("testDelete('data-\xE0', '\xE0')");
+debug("");
+
+shouldBeFalse("testDelete('dummy', '-foo')");
+debug("");
+
+function testForIn(array)
+{
+ var d = document.createElement("div");
+ for (var i = 0; i &lt; array.length; ++i) {
+ d.setAttribute(array[i], "value");
+ }
+
+ var count = 0;
+ for (var item in d.dataset)
+ count++;
+
+ return count;
+}
+
+shouldBe("testForIn(['data-foo', 'data-bar', 'data-baz'])", "3");
+shouldBe("testForIn(['data-foo', 'data-bar', 'dataFoo'])", "2");
+shouldBe("testForIn(['data-foo', 'data-bar', 'style'])", "2");
+shouldBe("testForIn(['data-foo', 'data-bar', 'data-'])", "3");
+</script>
</body>
</html>
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/dataset-gc.html ('k') | third_party/WebKit/LayoutTests/fast/dom/document-head.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698