Title: [203013] trunk/Source/WebCore
Revision
203013
Author
[email protected]
Date
2016-07-08 17:28:23 -0700 (Fri, 08 Jul 2016)

Log Message

Move shouldInheritSecurityOriginFromOwner() from URL to Document
https://bugs.webkit.org/show_bug.cgi?id=158987

Reviewed by Alex Christensen.

The URL class should not have knowledge of the concept of an origin or the semantics of origin
inheritance as these are higher level concepts. We should make URL::shouldInheritSecurityOriginFromOwner()
a static non-member, non-friend function of Document because its implements the origin semantics
for a Document object as described in section Origin of the HTML5 spec., <https://html.spec.whatwg.org/multipage/browsers.html#origin> (8 July 2016).
These semantics only apply to Documents.

No functionality changed. So, no new tests.

* dom/Document.cpp:
(WebCore::shouldInheritSecurityOriginFromOwner): Added.
(WebCore::Document::initSecurityContext): Modified to call WebCore::shouldInheritSecurityOriginFromOwner().
(WebCore::Document::initContentSecurityPolicy): Ditto.
* platform/URL.cpp:
(WebCore::URL::shouldInheritSecurityOriginFromOwner): Deleted.
* platform/URL.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203012 => 203013)


--- trunk/Source/WebCore/ChangeLog	2016-07-09 00:24:25 UTC (rev 203012)
+++ trunk/Source/WebCore/ChangeLog	2016-07-09 00:28:23 UTC (rev 203013)
@@ -1,5 +1,28 @@
 2016-07-08  Daniel Bates  <[email protected]>
 
+        Move shouldInheritSecurityOriginFromOwner() from URL to Document
+        https://bugs.webkit.org/show_bug.cgi?id=158987
+
+        Reviewed by Alex Christensen.
+
+        The URL class should not have knowledge of the concept of an origin or the semantics of origin
+        inheritance as these are higher level concepts. We should make URL::shouldInheritSecurityOriginFromOwner()
+        a static non-member, non-friend function of Document because its implements the origin semantics
+        for a Document object as described in section Origin of the HTML5 spec., <https://html.spec.whatwg.org/multipage/browsers.html#origin> (8 July 2016).
+        These semantics only apply to Documents.
+
+        No functionality changed. So, no new tests.
+
+        * dom/Document.cpp:
+        (WebCore::shouldInheritSecurityOriginFromOwner): Added.
+        (WebCore::Document::initSecurityContext): Modified to call WebCore::shouldInheritSecurityOriginFromOwner().
+        (WebCore::Document::initContentSecurityPolicy): Ditto.
+        * platform/URL.cpp:
+        (WebCore::URL::shouldInheritSecurityOriginFromOwner): Deleted.
+        * platform/URL.h:
+
+2016-07-08  Daniel Bates  <[email protected]>
+
         Setting table.tFoot or calling table.createTFoot() should append HTML tfont element to the end of the table
         https://bugs.webkit.org/show_bug.cgi?id=159583
         <rdar://problem/27255292>

Modified: trunk/Source/WebCore/dom/Document.cpp (203012 => 203013)


--- trunk/Source/WebCore/dom/Document.cpp	2016-07-09 00:24:25 UTC (rev 203012)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-07-09 00:28:23 UTC (rev 203013)
@@ -5248,6 +5248,20 @@
     return m_xpathEvaluator->evaluate(_expression_, contextNode, WTFMove(resolver), type, result, ec);
 }
 
+static bool shouldInheritSecurityOriginFromOwner(const URL& url)
+{
+    // Paraphrased from <https://html.spec.whatwg.org/multipage/browsers.html#origin> (8 July 2016)
+    //
+    // If a Document has the address "about:blank"
+    //      The origin of the document is the origin it was assigned when its browsing context was created.
+    // If a Document has the address "about:srcdoc"
+    //      The origin of the document is the origin of its parent document.
+    //
+    // Note: We generalize this to invalid URLs because we treat such URLs as about:blank.
+    //
+    return url.isEmpty() || equalIgnoringASCIICase(url.string(), blankURL()) || equalLettersIgnoringASCIICase(url.string(), "about:srcdoc");
+}
+
 void Document::initSecurityContext()
 {
     if (haveInitializedSecurityOrigin()) {
@@ -5300,7 +5314,7 @@
         setBaseURLOverride(parentDocument->baseURL());
     }
 
-    if (!m_url.shouldInheritSecurityOriginFromOwner())
+    if (!shouldInheritSecurityOriginFromOwner(m_url))
         return;
 
     // If we do not obtain a meaningful origin from the URL, then we try to
@@ -5343,7 +5357,7 @@
 
 void Document::initContentSecurityPolicy()
 {
-    if (!m_frame->tree().parent() || (!m_url.shouldInheritSecurityOriginFromOwner() && !isPluginDocument()))
+    if (!m_frame->tree().parent() || (!shouldInheritSecurityOriginFromOwner(m_url) && !isPluginDocument()))
         return;
 
     contentSecurityPolicy()->copyStateFrom(m_frame->tree().parent()->document()->contentSecurityPolicy());

Modified: trunk/Source/WebCore/platform/URL.cpp (203012 => 203013)


--- trunk/Source/WebCore/platform/URL.cpp	2016-07-09 00:24:25 UTC (rev 203012)
+++ trunk/Source/WebCore/platform/URL.cpp	2016-07-09 00:28:23 UTC (rev 203013)
@@ -2062,13 +2062,6 @@
     return protocolIs("about");
 }
 
-bool URL::shouldInheritSecurityOriginFromOwner() const
-{
-    return isEmpty()
-        || equalIgnoringASCIICase(m_string, blankURL().string())
-        || equalLettersIgnoringASCIICase(m_string, "about:srcdoc");
-}
-
 typedef HashMap<String, unsigned short, ASCIICaseInsensitiveHash> DefaultPortsMap;
 static const DefaultPortsMap& defaultPortsMap()
 {

Modified: trunk/Source/WebCore/platform/URL.h (203012 => 203013)


--- trunk/Source/WebCore/platform/URL.h	2016-07-09 00:24:25 UTC (rev 203012)
+++ trunk/Source/WebCore/platform/URL.h	2016-07-09 00:28:23 UTC (rev 203013)
@@ -131,7 +131,6 @@
     bool protocolIsInHTTPFamily() const;
     WEBCORE_EXPORT bool isLocalFile() const;
     bool isBlankURL() const;
-    bool shouldInheritSecurityOriginFromOwner() const;
 
     WEBCORE_EXPORT bool setProtocol(const String&);
     void setHost(const String&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to