[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Wed Apr 7 23:53:45 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit f37b4be37d42c93ee5d9883650be9f7a6fbadadc
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Nov 22 17:22:31 2009 +0000

    2009-11-22  Chris Evans  <cevans at chromium.org>
    
            Reviewed by Adam Barth.
    
            Updates the test to make sure it is disabling universal access for
            file:/// URLs (if the API is supported). This is required to do
            effective intra-file:/// access tests.
            Note that Safari only passes by virtual of supporting no directory
            listings at all.
    
            * fast/xmlhttprequest/resources/xmlhttprequest-nonexistent-file-real.html: Added.
            * fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt:
            * fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html:
            Disable universal access for file:/// URLs (if API available).
            Run the real test in an iframe without universal access.
    2009-11-22  Chris Evans  <cevans at chromium.org>
    
            Reviewed by Adam Barth.
    
            Deny access to directory listings. This needs doing in WebKit for
            WebKit clients that do permit top-level navigation to file:///dir.
            This matches Firefox, plus the existing Safari implementation (which
            does not support any directory access at all). It will fix the
            LayoutTest named below for Chromium.
    
            Test: fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html
    
            * page/SecurityOrigin.cpp: Deny access to directory listings.
            (WebCore::SecurityOrigin::SecurityOrigin):
            (WebCore::SecurityOrigin::canRequest):
    2009-11-22  Chris Evans  <cevans at chromium.org>
    
            Reviewed by Adam Barth.
    
            Implemented setAllowUniversalAccessFromFileURLs to support testing of
            file URL security.
    
            * DumpRenderTree/LayoutTestController.cpp:
            (setAllowUniversalAccessFromFileURLsCallback):
            (LayoutTestController::staticFunctions):
            * DumpRenderTree/LayoutTestController.h:
            * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
            (LayoutTestController::setAllowUniversalAccessFromFileURLs):
            * DumpRenderTree/mac/LayoutTestControllerMac.mm:
            (LayoutTestController::setAllowUniversalAccessFromFileURLs):
            * DumpRenderTree/win/LayoutTestControllerWin.cpp:
            (LayoutTestController::setAllowUniversalAccessFromFileURLs):
            * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
            (LayoutTestController::setAllowUniversalAccessFromFileURLs):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51294 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5709ae3..010fa82 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2009-11-22  Chris Evans  <cevans at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Updates the test to make sure it is disabling universal access for
+        file:/// URLs (if the API is supported). This is required to do
+        effective intra-file:/// access tests.
+        Note that Safari only passes by virtual of supporting no directory
+        listings at all.
+
+        * fast/xmlhttprequest/resources/xmlhttprequest-nonexistent-file-real.html: Added.
+        * fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt:
+        * fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html:
+        Disable universal access for file:/// URLs (if API available).
+        Run the real test in an iframe without universal access.
+
 2009-11-21  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/LayoutTests/fast/xmlhttprequest/resources/xmlhttprequest-nonexistent-file-real.html b/LayoutTests/fast/xmlhttprequest/resources/xmlhttprequest-nonexistent-file-real.html
new file mode 100644
index 0000000..7785172
--- /dev/null
+++ b/LayoutTests/fast/xmlhttprequest/resources/xmlhttprequest-nonexistent-file-real.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+                      "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <script>
+        function log(message)
+        {
+            var console = document.getElementById('console');
+            console.appendChild(document.createTextNode(message));
+            console.appendChild(document.createElement('br'));
+        }
+
+        function errorHandler()
+        {
+            log("Error handler: readyState = " + xhr.readyState);
+            var results = window.top.document.getElementById('results');
+            results.innerHTML = document.body.innerHTML;
+        }
+
+        function readyStateHandlerDirectory()
+        {
+            log("ReadyState handler: readyState = " + xhr.readyState);
+            if (xhr.readyState == 4 && window.layoutTestController) {
+                setTimeout("layoutTestController.notifyDone()", 0);
+            }
+        }
+
+        function testXHRDirectory()
+        {
+            log("");
+            log("Doing an XHR to a directory.");
+            xhr = new XMLHttpRequest();
+            xhr.onerror = errorHandler;
+            xhr.onreadystatechange = readyStateHandlerDirectory;
+
+            try {
+                xhr.open("GET", "../resources/", false);
+                xhr.send("");
+            } catch(e) {
+                log("Exception: " + e.message);
+            }
+        }
+
+        function readyStateHandlerNonExistent()
+        {
+            log("ReadyState handler: readyState = " + xhr.readyState);
+            if (xhr.readyState == 4)
+                setTimeout("testXHRDirectory()", 0);
+        }
+
+        function testXHRNonExistentFile()
+        {
+            log("Doing an XHR to a nonexistent file.");
+            xhr = new XMLHttpRequest();
+            xhr.onerror = errorHandler;
+            xhr.onreadystatechange = readyStateHandlerNonExistent;
+
+            try {
+                xhr.open("GET", "nonexistent.html", true);
+                xhr.send("");
+            } catch(e) {
+                log("Exception: " + e.message);
+                testXHRDirectory();
+            }
+        }
+        </script>
+    </head>
+    <body onload="testXHRNonExistentFile()">
+        <p> Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=22475">22475</a>: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore </p>
+        <p> In both cases, readyState 4 should be reached, and error handler should be invoked. </p>
+        <div id="console"/>
+    </body>
+</html>
diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt
index 77290bb..1e96842 100644
--- a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt
+++ b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt
@@ -1,3 +1,4 @@
+
 Bug 22475: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore
 
 In both cases, readyState 4 should be reached, and error handler should be invoked.
diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html
index 67f07a7..ef0a2d6 100644
--- a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html
+++ b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html
@@ -1,76 +1,15 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-                      "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-    <script>
-        function log(message)
-        {
-            var console = document.getElementById('console');
-            console.appendChild(document.createTextNode(message));
-            console.appendChild(document.createElement('br'));
-        }
-
-        function errorHandler()
-        {
-            log("Error handler: readyState = " + xhr.readyState);
-        }
-
-        function readyStateHandlerDirectory()
-        {
-            log("ReadyState handler: readyState = " + xhr.readyState);
-            if (xhr.readyState == 4 && window.layoutTestController) {
-                setTimeout("layoutTestController.notifyDone()", 0);
-            }
-        }
-
-        function testXHRDirectory()
-        {
-            log("");
-            log("Doing an XHR to a directory.");
-            xhr = new XMLHttpRequest();
-            xhr.onerror = errorHandler;
-            xhr.onreadystatechange = readyStateHandlerDirectory;
-
-            try {
-                xhr.open("GET", "resources", true);
-                xhr.send("");
-            } catch(e) {
-                log("Exception: " + e.message);
-            }
-        }
-
-        function readyStateHandlerNonExistent()
-        {
-            log("ReadyState handler: readyState = " + xhr.readyState);
-            if (xhr.readyState == 4)
-                setTimeout("testXHRDirectory()", 0);
-        }
-
-        function testXHRNonExistentFile()
-        {
-            if (window.layoutTestController) {
-                layoutTestController.dumpAsText();
-                layoutTestController.waitUntilDone();
-            }
-
-            log("Doing an XHR to a nonexistent file.");
-            xhr = new XMLHttpRequest();
-            xhr.onerror = errorHandler;
-            xhr.onreadystatechange = readyStateHandlerNonExistent;
-
-            try {
-                xhr.open("GET", "nonexistent.html", true);
-                xhr.send("");
-            } catch(e) {
-                log("Exception: " + e.message);
-                testXHRDirectory();
-            }
-        }
-        </script>
-    </head>
-    <body onload="testXHRNonExistentFile()">
-        <p> Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=22475">22475</a>: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore </p>
-        <p> In both cases, readyState 4 should be reached, and error handler should be invoked. </p>
-        <div id="console"/>
-    </body>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.setAllowUniversalAccessFromFileURLs(false);
+}
+</script>
+</head>
+<body>
+<iframe src="resources/xmlhttprequest-nonexistent-file-real.html"></iframe>
+<div id="results"></div>
+</body>
 </html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 054bfb3..1b4c652 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2009-11-22  Chris Evans  <cevans at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Deny access to directory listings. This needs doing in WebKit for
+        WebKit clients that do permit top-level navigation to file:///dir.
+        This matches Firefox, plus the existing Safari implementation (which
+        does not support any directory access at all). It will fix the
+        LayoutTest named below for Chromium.
+
+        Test: fast/xmlhttprequest/xmlhttprequest-nonexistent-file.html
+
+        * page/SecurityOrigin.cpp: Deny access to directory listings.
+        (WebCore::SecurityOrigin::SecurityOrigin):
+        (WebCore::SecurityOrigin::canRequest):
+
 2009-11-20  Joseph Pecoraro  <joepeck at webkit.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/page/SecurityOrigin.cpp b/WebCore/page/SecurityOrigin.cpp
index 338bf9f..b625fba 100644
--- a/WebCore/page/SecurityOrigin.cpp
+++ b/WebCore/page/SecurityOrigin.cpp
@@ -112,6 +112,11 @@ SecurityOrigin::SecurityOrigin(const KURL& url)
 
     // By default, only local SecurityOrigins can load local resources.
     m_canLoadLocalResources = isLocal();
+    if (m_canLoadLocalResources) {
+        // Directories should never be readable.
+        if (!url.hasPath() || url.path().endsWith("/"))
+            m_noAccess = true;
+    }
 
     if (isDefaultPortForProtocol(m_port, m_protocol))
         m_port = 0;
@@ -207,6 +212,8 @@ bool SecurityOrigin::canRequest(const KURL& url) const
         return false;
 
     RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);
+    if (targetOrigin->m_noAccess)
+        return false;
 
     // We call isSameSchemeHostPort here instead of canAccess because we want
     // to ignore document.domain effects.
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 66bc657..8ae92be 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2009-11-22  Chris Evans  <cevans at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Implemented setAllowUniversalAccessFromFileURLs to support testing of
+        file URL security.
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (setAllowUniversalAccessFromFileURLsCallback):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::setAllowUniversalAccessFromFileURLs):
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::setAllowUniversalAccessFromFileURLs):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::setAllowUniversalAccessFromFileURLs):
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+        (LayoutTestController::setAllowUniversalAccessFromFileURLs):
+
 2009-11-22  Jakub Wieczorek  <faw217 at gmail.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index 4c28ca7..ed9cb30 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -838,6 +838,18 @@ static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac & windows implementation
@@ -1248,6 +1260,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 0641e99..2fffde9 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -67,6 +67,7 @@ public:
     void removeAllVisitedLinks();
     void setAcceptsEditing(bool acceptsEditing);
     void setAppCacheMaximumSize(unsigned long long quota);
+    void setAllowUniversalAccessFromFileURLs(bool);
     void setAuthorAndUserStylesEnabled(bool);
     void setCacheModel(int);
     void setCustomPolicyDelegate(bool setDelegate, bool permissive);
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index db55fbd..9fd79cc 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -316,6 +316,11 @@ void LayoutTestController::setXSSAuditorEnabled(bool flag)
     g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
 }
 
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
+{
+    // FIXME: implement
+}
+
 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
 {
     // FIXME: implement
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index b435f54..42aa788 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -301,6 +301,11 @@ void LayoutTestController::setXSSAuditorEnabled(bool enabled)
     [[[mainFrame webView] preferences] setXSSAuditorEnabled:enabled];
 }
 
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
+{
+    [[[mainFrame webView] preferences] setAllowUniversalAccessFromFileURLs:enabled];
+}
+
 void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
 {
     [[[mainFrame webView] preferences] setJavaScriptCanOpenWindowsAutomatically:!popupBlockingEnabled];
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index c8649bb..0b77be6 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -372,6 +372,23 @@ void LayoutTestController::setXSSAuditorEnabled(bool enabled)
     prefsPrivate->setXSSAuditorEnabled(enabled);
 }
 
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
+{
+    COMPtr<IWebView> webView;
+    if (FAILED(frame->webView(&webView)))
+        return;
+
+    COMPtr<IWebPreferences> preferences;
+    if (FAILED(webView->preferences(&preferences)))
+        return;
+
+    COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences);
+    if (!prefsPrivate)
+        return;
+
+    prefsPrivate->setAllowUniversalAccessFromFileURLs(enabled);
+}
+
 void LayoutTestController::setPopupBlockingEnabled(bool enabled)
 {
     COMPtr<IWebView> webView;
diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
index 72f85ae..218480f 100644
--- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
@@ -170,6 +170,11 @@ void LayoutTestController::setXSSAuditorEnabled(bool enabled)
     // FIXME: implement
 }
 
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
+{
+    // FIXME: implement
+}
+
 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
 {
     // FIXME: implement

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list