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

Unified Diff: third_party/WebKit/LayoutTests/svg/dom/href-semantics.html

Issue 1681553002: Add support for 'href' (w/o XLink NS) for various SVG elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; update comment Created 4 years, 10 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/svg/dom/href-semantics.html
diff --git a/third_party/WebKit/LayoutTests/svg/dom/href-semantics.html b/third_party/WebKit/LayoutTests/svg/dom/href-semantics.html
new file mode 100644
index 0000000000000000000000000000000000000000..4d4298232ec8d54620d803430b0b7f4211f5fbcc
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/dom/href-semantics.html
@@ -0,0 +1,137 @@
+<!DOCTYPE html>
+<title>SVGURIReference.href IDL semantics</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+const svgNs = 'http://www.w3.org/2000/svg';
+const xlinkNs = 'http://www.w3.org/1999/xlink';
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(null, 'href', 'foo');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
+ assert_equals(element.href.baseVal, 'foo');
+
+ element.href.baseVal = 'bar';
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still does not exist');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists');
+ assert_equals(element.getAttributeNS(null, 'href'), 'bar');
+}, document.title+', IDL href backed by "href" after setAttribute(href).');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(xlinkNs, 'href', 'foo');
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_equals(element.href.baseVal, 'foo');
+
+ element.href.baseVal = 'bar';
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" still does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists');
+ assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar');
+}, document.title+', IDL href backed by "xlink:href" after setAttribute(xlink:href).');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.href.baseVal = 'foo';
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_equals(element.href.baseVal, 'foo');
+}, document.title+', IDL href backed by "href" after baseVal setter.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.href.baseVal = 'foo';
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_equals(element.href.baseVal, 'foo');
+
+ element.setAttributeNS(xlinkNs, 'href', 'bar');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists');
+ assert_equals(element.href.baseVal, 'foo', 'baseVal still reflects "href"');
+ assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar');
+}, document.title+', IDL href reflects "href"; setAttribute(xlink:href) does not override baseVal setter.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(xlinkNs, 'href', 'baz');
+ element.href.baseVal = 'foo';
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_equals(element.href.baseVal, 'foo');
+ assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
+
+ element.setAttributeNS(null, 'href', 'bar');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_equals(element.href.baseVal, 'bar', 'baseVal prefers "href" to "xlink:href"');
+ assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
+ assert_equals(element.getAttributeNS(null, 'href'), 'bar');
+}, document.title+', IDL href prefers "href" over "xlink:href" after setAttribute(href) overrides.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(xlinkNs, 'href', 'foo');
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_equals(element.href.baseVal, 'foo');
+ assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo');
+
+ element.setAttributeNS(xlinkNs, 'xlink:href', 'bar');
+ assert_equals(element.href.baseVal, 'bar');
+}, document.title+', IDL href reflects "xlink:href"; setAttribute(xlink:href) w/ NS-prefix.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(null, 'href', 'foo');
+ element.setAttributeNS(xlinkNs, 'href', 'bar');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
+
+ element.removeAttributeNS(null, 'href');
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" no longer exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exist');
+ assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
+}, document.title+', IDL href reflects "xlink:href" after removeAttribute(href).');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(null, 'href', 'foo');
+ element.setAttributeNS(xlinkNs, 'href', 'bar');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" exists');
+ assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
+
+ element.removeAttributeNS(xlinkNs, 'href');
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
+ assert_true(element.hasAttributeNS(null, 'href'), '"href" still exist');
+ assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"');
+}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) has no effect.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(xlinkNs, 'href', 'bar');
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
+
+ element.removeAttributeNS(xlinkNs, 'href');
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
+ assert_equals(element.href.baseVal, '');
+}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) resets to default.');
+
+test(function() {
+ var element = document.createElementNS(svgNs, 'a');
+ element.setAttributeNS(xlinkNs, 'xlink:href', 'bar');
+ assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist');
+ assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists');
+ assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"');
+
+ element.removeAttributeNS(xlinkNs, 'href');
+ assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist');
+ assert_equals(element.href.baseVal, '');
+}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) w/o NS-prefix resets to default.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698