Title: [106434] trunk
Revision
106434
Author
[email protected]
Date
2012-01-31 22:55:17 -0800 (Tue, 31 Jan 2012)

Log Message

Add APIs, getElementsByXXX family, to ShadowRoot IDL.
https://bugs.webkit.org/show_bug.cgi?id=77323

Reviewed by Dimitri Glazkov.

Add APIs (getElementById, getElemesntByTagName, getElementsByClassName and getElementsByTagNameNS)
to ShadowRoot IDL.

Source/WebCore:

* dom/ShadowRoot.idl:

LayoutTests:

* fast/dom/shadow/shadow-root-js-api-expected.txt:
* fast/dom/shadow/shadow-root-js-api.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106433 => 106434)


--- trunk/LayoutTests/ChangeLog	2012-02-01 06:49:26 UTC (rev 106433)
+++ trunk/LayoutTests/ChangeLog	2012-02-01 06:55:17 UTC (rev 106434)
@@ -1,3 +1,16 @@
+2012-01-31  Hayato Ito  <[email protected]>
+
+        Add APIs, getElementsByXXX family, to ShadowRoot IDL.
+        https://bugs.webkit.org/show_bug.cgi?id=77323
+
+        Reviewed by Dimitri Glazkov.
+
+        Add APIs (getElementById, getElemesntByTagName, getElementsByClassName and getElementsByTagNameNS)
+        to ShadowRoot IDL.
+
+        * fast/dom/shadow/shadow-root-js-api-expected.txt:
+        * fast/dom/shadow/shadow-root-js-api.html:
+
 2012-01-31  Shinya Kawanaka  <[email protected]>
 
         Content element should be able to be dynamically added/removed/replaced in a shadow tree.

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt (106433 => 106434)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt	2012-02-01 06:49:26 UTC (rev 106433)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api-expected.txt	2012-02-01 06:55:17 UTC (rev 106434)
@@ -11,6 +11,15 @@
 PASS new WebKitShadowRoot(shadowHost) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
 The previous test should not have side effects.
 PASS shadowHost is shadowRoot.host
+PASS shadowRoot.getElementById('div1') is div1
+PASS shadowRoot.getElementById('foo') is null
+PASS shadowRoot.getElementsByClassName('class2') is [div2]
+PASS shadowRoot.getElementsByClassName('foo') is []
+PASS shadowRoot.getElementsByTagName('div') is [div1, div2]
+PASS shadowRoot.getElementsByTagName('foo') is []
+PASS shadowRoot.getElementsByTagNameNS('*', 'div') is [div1, div2]
+PASS shadowRoot.getElementsByTagNameNS('', 'div') is []
+PASS shadowRoot.getElementsByTagNameNS('*', 'foo') is []
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html (106433 => 106434)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html	2012-02-01 06:49:26 UTC (rev 106433)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-js-api.html	2012-02-01 06:55:17 UTC (rev 106434)
@@ -15,12 +15,38 @@
 shouldThrow("new WebKitShadowRoot(null)");
 shouldThrow("new WebKitShadowRoot(1)");
 var shadowHost = document.createElement('div');
+document.body.appendChild(shadowHost);
 var shadowRoot = new WebKitShadowRoot(shadowHost);
 shouldBe("shadowHost", "shadowRoot.host");
 shouldThrow("new WebKitShadowRoot(shadowHost)");
 debug('The previous test should not have side effects.');
 shouldBe("shadowHost", "shadowRoot.host");
 
+var div1 = document.createElement("div");
+div1.setAttribute("id", "div1");
+shadowRoot.appendChild(div1);
+
+var div2 = document.createElement("div");
+div2.setAttribute("id", "div2");
+div2.classList.add("class2");
+shadowRoot.appendChild(div2);
+
+// Tests for Document should cover most cases for the following APIs.
+// We have basic tests here. More tests are welcome, but we should avoid unnecssary duplications.
+shouldBe("shadowRoot.getElementById('div1')", "div1");
+shouldBeNull("shadowRoot.getElementById('foo')");
+
+shouldBe("shadowRoot.getElementsByClassName('class2')", "[div2]");
+shouldBe("shadowRoot.getElementsByClassName('foo')", "[]");
+
+shouldBe("shadowRoot.getElementsByTagName('div')", "[div1, div2]");
+shouldBe("shadowRoot.getElementsByTagName('foo')", "[]");
+
+// FIXME: Add more tests using XML documents.
+shouldBe("shadowRoot.getElementsByTagNameNS('*', 'div')", "[div1, div2]");
+shouldBe("shadowRoot.getElementsByTagNameNS('', 'div')", "[]");
+shouldBe("shadowRoot.getElementsByTagNameNS('*', 'foo')", "[]");
+
 </script>
 <script src=""
 </body>

Modified: trunk/Source/WebCore/ChangeLog (106433 => 106434)


--- trunk/Source/WebCore/ChangeLog	2012-02-01 06:49:26 UTC (rev 106433)
+++ trunk/Source/WebCore/ChangeLog	2012-02-01 06:55:17 UTC (rev 106434)
@@ -1,3 +1,15 @@
+2012-01-31  Hayato Ito  <[email protected]>
+
+        Add APIs, getElementsByXXX family, to ShadowRoot IDL.
+        https://bugs.webkit.org/show_bug.cgi?id=77323
+
+        Reviewed by Dimitri Glazkov.
+
+        Add APIs (getElementById, getElemesntByTagName, getElementsByClassName and getElementsByTagNameNS)
+        to ShadowRoot IDL.
+
+        * dom/ShadowRoot.idl:
+
 2012-01-31  Shinya Kawanaka  <[email protected]>
 
         Content element should be able to be dynamically added/removed/replaced in a shadow tree.

Modified: trunk/Source/WebCore/dom/ShadowRoot.idl (106433 => 106434)


--- trunk/Source/WebCore/dom/ShadowRoot.idl	2012-02-01 06:49:26 UTC (rev 106433)
+++ trunk/Source/WebCore/dom/ShadowRoot.idl	2012-02-01 06:55:17 UTC (rev 106434)
@@ -33,6 +33,11 @@
         ConstructorRaisesException
     ] ShadowRoot : Node {
         readonly attribute Element host;
+        Element getElementById(in [Optional=CallWithDefaultValue] DOMString elementId);
+        NodeList getElementsByClassName(in [Optional=CallWithDefaultValue] DOMString className);
+        NodeList getElementsByTagName(in [Optional=CallWithDefaultValue] DOMString tagName);
+        [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString namespaceURI,
+                                                       in [Optional=CallWithDefaultValue] DOMString localName);
     };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to