Title: [108226] trunk
Revision
108226
Author
[email protected]
Date
2012-02-20 01:33:15 -0800 (Mon, 20 Feb 2012)

Log Message

Attached/Detached state must be testable
https://bugs.webkit.org/show_bug.cgi?id=79010

Reviewed by Hajime Morita.

Source/WebCore:

Added a method to check an element attached or not.

Test: fast/dom/shadow/shadow-root-attached.html

* testing/Internals.cpp:
(WebCore::Internals::attached):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

LayoutTests:

* fast/dom/shadow/shadow-root-attached-expected.txt: Added.
* fast/dom/shadow/shadow-root-attached.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (108225 => 108226)


--- trunk/LayoutTests/ChangeLog	2012-02-20 09:30:24 UTC (rev 108225)
+++ trunk/LayoutTests/ChangeLog	2012-02-20 09:33:15 UTC (rev 108226)
@@ -1,3 +1,13 @@
+2012-02-20  Shinya Kawanaka  <[email protected]>
+
+        Attached/Detached state must be testable
+        https://bugs.webkit.org/show_bug.cgi?id=79010
+
+        Reviewed by Hajime Morita.
+
+        * fast/dom/shadow/shadow-root-attached-expected.txt: Added.
+        * fast/dom/shadow/shadow-root-attached.html: Added.
+
 2012-02-20  Philippe Normand  <[email protected]>
 
         Unreviewed, GTK baselines for a new fast/css-generated-content

Added: trunk/LayoutTests/fast/dom/shadow/shadow-root-attached-expected.txt (0 => 108226)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-attached-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-attached-expected.txt	2012-02-20 09:33:15 UTC (rev 108226)
@@ -0,0 +1,10 @@
+This test checks nodes are reallyed attached.
+
+PASS internals.attached(light) is false
+PASS internals.attached(light) is true
+PASS internals.attached(light) is false
+PASS internals.attached(light) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+LIGHT

Added: trunk/LayoutTests/fast/dom/shadow/shadow-root-attached.html (0 => 108226)


--- trunk/LayoutTests/fast/dom/shadow/shadow-root-attached.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-root-attached.html	2012-02-20 09:33:15 UTC (rev 108226)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p>This test checks nodes are reallyed attached.</p>
+<pre id="console"></pre>
+<div id="container"></div>
+
+<script>
+var container = document.getElementById("container");
+
+(function testAttachedInLightChildren() {
+    var root = document.createElement('div');
+    window.light = createSpanWithText('LIGHT');
+    root.appendChild(light);
+
+    var shadowRoot = new WebKitShadowRoot(root);
+
+    shouldBe('internals.attached(light)', 'false');
+    document.getElementById('container').appendChild(root);
+    shouldBe('internals.attached(light)', 'true');
+})();
+
+(function testNotDistributedElementAttached() {
+    var root = document.createElement('div');
+    window.light = createSpanWithText('LIGHT');
+    root.appendChild(light);
+
+    var shadowRoot = new WebKitShadowRoot(root);
+    shadowRoot.appendChild(createContentWithSelect('span'));
+
+    shouldBe('internals.attached(light)', 'false');
+    document.getElementById('container').appendChild(root);
+    shouldBe('internals.attached(light)', 'true');
+})();
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (108225 => 108226)


--- trunk/Source/WebCore/ChangeLog	2012-02-20 09:30:24 UTC (rev 108225)
+++ trunk/Source/WebCore/ChangeLog	2012-02-20 09:33:15 UTC (rev 108226)
@@ -1,3 +1,21 @@
+2012-02-20  Shinya Kawanaka  <[email protected]>
+
+        Attached/Detached state must be testable
+        https://bugs.webkit.org/show_bug.cgi?id=79010
+
+        Reviewed by Hajime Morita.
+
+        Added a method to check an element attached or not.
+
+        Test: fast/dom/shadow/shadow-root-attached.html
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::attached):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-02-20  Kenichi Ishibashi  <[email protected]>
 
         [WebSocket] Add deflater/inflater classes

Modified: trunk/Source/WebCore/testing/Internals.cpp (108225 => 108226)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-02-20 09:30:24 UTC (rev 108225)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-02-20 09:33:15 UTC (rev 108226)
@@ -156,6 +156,16 @@
     return toHTMLContentElement(contentElement)->isSelectValid();
 }
 
+bool Internals::attached(Node* node, ExceptionCode& ec)
+{
+    if (!node) {
+        ec = INVALID_ACCESS_ERR;
+        return false;
+    }
+
+    return node->attached();
+}
+
 String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
 {
     if (!element) {

Modified: trunk/Source/WebCore/testing/Internals.h (108225 => 108226)


--- trunk/Source/WebCore/testing/Internals.h	2012-02-20 09:30:24 UTC (rev 108225)
+++ trunk/Source/WebCore/testing/Internals.h	2012-02-20 09:33:15 UTC (rev 108226)
@@ -76,6 +76,8 @@
     Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
     bool isValidContentSelect(Element* contentElement, ExceptionCode&);
 
+    bool attached(Node*, ExceptionCode&);
+
 #if ENABLE(INPUT_COLOR)
     void selectColorInColorChooser(Element*, const String& colorValue);
 #endif

Modified: trunk/Source/WebCore/testing/Internals.idl (108225 => 108226)


--- trunk/Source/WebCore/testing/Internals.idl	2012-02-20 09:30:24 UTC (rev 108225)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-02-20 09:33:15 UTC (rev 108226)
@@ -51,6 +51,8 @@
         Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
         boolean isValidContentSelect(in Element contentElement) raises(DOMException);
 
+        boolean attached(in Node node) raises(DOMException);
+
 #if defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR
         void selectColorInColorChooser(in Element element, in DOMString colorValue);
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to