Title: [113945] trunk
Revision
113945
Author
aba...@webkit.org
Date
2012-04-11 23:35:40 -0700 (Wed, 11 Apr 2012)

Log Message

Implement Location.ancestorOrigins
https://bugs.webkit.org/show_bug.cgi?id=83493

Reviewed by David Levin.

Source/WebCore:

Test: fast/dom/Window/Location/ancestor-origins.html

This patch implements Location.ancestorOrigins(), which returns a list
of the origins of the enclosing frames.  This API has been discussed
both on webkit-dev (see discussion following
https://lists.webkit.org/pipermail/webkit-dev/2012-March/020090.html)
and on the whatwg list (see discussion following
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-March/035188.html).

* page/Location.cpp:
(WebCore::Location::ancestorOrigins):
(WebCore):
* page/Location.h:
(Location):
* page/Location.idl:

LayoutTests:

* fast/dom/Window/Location/ancestor-origins-expected.txt: Added.
* fast/dom/Window/Location/ancestor-origins.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (113944 => 113945)


--- trunk/LayoutTests/ChangeLog	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/LayoutTests/ChangeLog	2012-04-12 06:35:40 UTC (rev 113945)
@@ -1,3 +1,13 @@
+2012-04-11  Adam Barth  <aba...@webkit.org>
+
+        Implement Location.ancestorOrigins
+        https://bugs.webkit.org/show_bug.cgi?id=83493
+
+        Reviewed by David Levin.
+
+        * fast/dom/Window/Location/ancestor-origins-expected.txt: Added.
+        * fast/dom/Window/Location/ancestor-origins.html: Added.
+
 2012-04-11  Antonio Gomes  <ago...@rim.com>
 
         Unreviewed rebaseline.

Added: trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins-expected.txt (0 => 113945)


--- trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins-expected.txt	2012-04-12 06:35:40 UTC (rev 113945)
@@ -0,0 +1,7 @@
+ancestorOrigins.length = 0 
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+ancestorOrigins.length = 1
+ancestorOrigins[0] = file://

Added: trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins.html (0 => 113945)


--- trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/Location/ancestor-origins.html	2012-04-12 06:35:40 UTC (rev 113945)
@@ -0,0 +1,16 @@
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.dumpChildFramesAsText();
+}
+
+var origins = location.ancestorOrigins;
+document.write('ancestorOrigins.length = ' + origins.length);
+</script>
+<iframe srcdoc="
+  <script>
+  var origins = location.ancestorOrigins;
+  document.write('ancestorOrigins.length = ' + origins.length + '<br>');
+  document.write('ancestorOrigins[0] = ' + origins[0]);
+  </script>
+"></iframe>

Modified: trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt (113944 => 113945)


--- trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt	2012-04-12 06:35:40 UTC (rev 113945)
@@ -5,6 +5,7 @@
 PASS history.pushState == "LEFTOVER" is false
 PASS history.replaceState == "LEFTOVER" is false
 PASS history.state == "LEFTOVER" is false
+PASS location.ancestorOrigins == "LEFTOVER" is false
 PASS location.assign == "LEFTOVER" is false
 PASS location.hash == "LEFTOVER" is false
 PASS location.host == "LEFTOVER" is false

Modified: trunk/Source/WebCore/ChangeLog (113944 => 113945)


--- trunk/Source/WebCore/ChangeLog	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/Source/WebCore/ChangeLog	2012-04-12 06:35:40 UTC (rev 113945)
@@ -1,3 +1,26 @@
+2012-04-11  Adam Barth  <aba...@webkit.org>
+
+        Implement Location.ancestorOrigins
+        https://bugs.webkit.org/show_bug.cgi?id=83493
+
+        Reviewed by David Levin.
+
+        Test: fast/dom/Window/Location/ancestor-origins.html
+
+        This patch implements Location.ancestorOrigins(), which returns a list
+        of the origins of the enclosing frames.  This API has been discussed
+        both on webkit-dev (see discussion following
+        https://lists.webkit.org/pipermail/webkit-dev/2012-March/020090.html)
+        and on the whatwg list (see discussion following
+        http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-March/035188.html).
+
+        * page/Location.cpp:
+        (WebCore::Location::ancestorOrigins):
+        (WebCore):
+        * page/Location.h:
+        (Location):
+        * page/Location.idl:
+
 2012-04-11  Raymond Liu  <raymond....@intel.com>
 
         AudioContext createChannelSplitter() method should have optional argument for number of outputs

Modified: trunk/Source/WebCore/page/Location.cpp (113944 => 113945)


--- trunk/Source/WebCore/page/Location.cpp	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/Source/WebCore/page/Location.cpp	2012-04-12 06:35:40 UTC (rev 113945)
@@ -124,6 +124,16 @@
     return SecurityOrigin::create(url())->toString();
 }
 
+PassRefPtr<DOMStringList> Location::ancestorOrigins() const
+{
+    RefPtr<DOMStringList> origins = DOMStringList::create();
+    if (!m_frame)
+        return origins.release();
+    for (Frame* frame = m_frame->tree()->parent(true); frame; frame = frame->tree()->parent(true))
+        origins->append(frame->document()->securityOrigin()->toString());
+    return origins.release();
+}
+
 String Location::hash() const
 {
     if (!m_frame)

Modified: trunk/Source/WebCore/page/Location.h (113944 => 113945)


--- trunk/Source/WebCore/page/Location.h	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/Source/WebCore/page/Location.h	2012-04-12 06:35:40 UTC (rev 113945)
@@ -29,6 +29,7 @@
 #ifndef Location_h
 #define Location_h
 
+#include "DOMStringList.h"
 #include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -71,6 +72,8 @@
 
     String toString() const { return href(); }
 
+    PassRefPtr<DOMStringList> ancestorOrigins() const;
+
 private:
     explicit Location(Frame*);
 

Modified: trunk/Source/WebCore/page/Location.idl (113944 => 113945)


--- trunk/Source/WebCore/page/Location.idl	2012-04-12 06:05:29 UTC (rev 113944)
+++ trunk/Source/WebCore/page/Location.idl	2012-04-12 06:35:40 UTC (rev 113945)
@@ -64,6 +64,8 @@
                  readonly attribute DOMString origin;
 #endif
 
+        readonly attribute DOMStringList ancestorOrigins;
+
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
         [NotEnumerable, Custom, V8Unforgeable, V8ReadOnly, ImplementedAs=toStringFunction] DOMString toString();
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to