[chromium] move webpermissionclient related methods to TestRunner library
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 21:02:53 +0000 (21:02 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 21:02:53 +0000 (21:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106548

Patch by Dan Carney <dcarney@google.com> on 2013-01-10
Reviewed by Jochen Eisinger.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/DRTTestRunner.cpp:
(DRTTestRunner::DRTTestRunner):
(DRTTestRunner::reset):
* DumpRenderTree/chromium/DRTTestRunner.h:
(DRTTestRunner):
* DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
(WebTestRunner::WebTestDelegate::normalizeLayoutTestURL):
* DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
(WebKit):
(WebTestRunner::WebTestRunner::webPermissions):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner::TestRunner::setDelegate):
(WebTestRunner):
(WebTestRunner::TestRunner::reset):
(WebTestRunner::TestRunner::webPermissions):
(WebTestRunner::TestRunner::dumpPermissionClientCallbacks):
(WebTestRunner::TestRunner::setImagesAllowed):
(WebTestRunner::TestRunner::setScriptsAllowed):
(WebTestRunner::TestRunner::setStorageAllowed):
(WebTestRunner::TestRunner::setPluginsAllowed):
(WebTestRunner::TestRunner::setAllowDisplayOfInsecureContent):
(WebTestRunner::TestRunner::setAllowRunningOfInsecureContent):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(WebTestRunner):
(TestRunner):
* DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.cpp.
(WebTestRunner):
(WebTestRunner::WebPermissions::WebPermissions):
(WebTestRunner::WebPermissions::~WebPermissions):
(WebTestRunner::WebPermissions::allowImage):
(WebTestRunner::WebPermissions::allowScriptFromSource):
(WebTestRunner::WebPermissions::allowStorage):
(WebTestRunner::WebPermissions::allowPlugins):
(WebTestRunner::WebPermissions::allowDisplayingInsecureContent):
(WebTestRunner::WebPermissions::allowRunningInsecureContent):
(WebTestRunner::WebPermissions::setImagesAllowed):
(WebTestRunner::WebPermissions::setScriptsAllowed):
(WebTestRunner::WebPermissions::setStorageAllowed):
(WebTestRunner::WebPermissions::setPluginsAllowed):
(WebTestRunner::WebPermissions::setDisplayingInsecureContentAllowed):
(WebTestRunner::WebPermissions::setRunningInsecureContentAllowed):
(WebTestRunner::WebPermissions::setDelegate):
(WebTestRunner::WebPermissions::setDumpCallbacks):
(WebTestRunner::WebPermissions::reset):
* DumpRenderTree/chromium/TestRunner/src/WebPermissions.h: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.h.
(WebTestRunner):
(WebPermissions):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::initialize):
(TestShell::resetTestController):
(TestShell::createNewWindow):
* DumpRenderTree/chromium/TestShell.h:
(TestShell):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::normalizeLayoutTestURL):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.gypi
Tools/DumpRenderTree/chromium/DRTTestRunner.cpp
Tools/DumpRenderTree/chromium/DRTTestRunner.h
Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h
Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp [moved from Tools/DumpRenderTree/chromium/WebPermissions.cpp with 77% similarity]
Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.h [moved from Tools/DumpRenderTree/chromium/WebPermissions.h with 85% similarity]
Tools/DumpRenderTree/chromium/TestShell.cpp
Tools/DumpRenderTree/chromium/TestShell.h
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index 51a8127..b78bfe1 100644 (file)
@@ -1,3 +1,70 @@
+2013-01-10  Dan Carney  <dcarney@google.com>
+
+        [chromium] move webpermissionclient related methods to TestRunner library
+        https://bugs.webkit.org/show_bug.cgi?id=106548
+
+        Reviewed by Jochen Eisinger.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/DRTTestRunner.cpp:
+        (DRTTestRunner::DRTTestRunner):
+        (DRTTestRunner::reset):
+        * DumpRenderTree/chromium/DRTTestRunner.h:
+        (DRTTestRunner):
+        * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
+        (WebTestRunner::WebTestDelegate::normalizeLayoutTestURL):
+        * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
+        (WebKit):
+        (WebTestRunner::WebTestRunner::webPermissions):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
+        (WebTestRunner::TestRunner::TestRunner):
+        (WebTestRunner::TestRunner::setDelegate):
+        (WebTestRunner):
+        (WebTestRunner::TestRunner::reset):
+        (WebTestRunner::TestRunner::webPermissions):
+        (WebTestRunner::TestRunner::dumpPermissionClientCallbacks):
+        (WebTestRunner::TestRunner::setImagesAllowed):
+        (WebTestRunner::TestRunner::setScriptsAllowed):
+        (WebTestRunner::TestRunner::setStorageAllowed):
+        (WebTestRunner::TestRunner::setPluginsAllowed):
+        (WebTestRunner::TestRunner::setAllowDisplayOfInsecureContent):
+        (WebTestRunner::TestRunner::setAllowRunningOfInsecureContent):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
+        (WebTestRunner):
+        (TestRunner):
+        * DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.cpp.
+        (WebTestRunner):
+        (WebTestRunner::WebPermissions::WebPermissions):
+        (WebTestRunner::WebPermissions::~WebPermissions):
+        (WebTestRunner::WebPermissions::allowImage):
+        (WebTestRunner::WebPermissions::allowScriptFromSource):
+        (WebTestRunner::WebPermissions::allowStorage):
+        (WebTestRunner::WebPermissions::allowPlugins):
+        (WebTestRunner::WebPermissions::allowDisplayingInsecureContent):
+        (WebTestRunner::WebPermissions::allowRunningInsecureContent):
+        (WebTestRunner::WebPermissions::setImagesAllowed):
+        (WebTestRunner::WebPermissions::setScriptsAllowed):
+        (WebTestRunner::WebPermissions::setStorageAllowed):
+        (WebTestRunner::WebPermissions::setPluginsAllowed):
+        (WebTestRunner::WebPermissions::setDisplayingInsecureContentAllowed):
+        (WebTestRunner::WebPermissions::setRunningInsecureContentAllowed):
+        (WebTestRunner::WebPermissions::setDelegate):
+        (WebTestRunner::WebPermissions::setDumpCallbacks):
+        (WebTestRunner::WebPermissions::reset):
+        * DumpRenderTree/chromium/TestRunner/src/WebPermissions.h: Renamed from Tools/DumpRenderTree/chromium/WebPermissions.h.
+        (WebTestRunner):
+        (WebPermissions):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::initialize):
+        (TestShell::resetTestController):
+        (TestShell::createNewWindow):
+        * DumpRenderTree/chromium/TestShell.h:
+        (TestShell):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::normalizeLayoutTestURL):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2013-01-10  Alan Cutter  <alancutter@chromium.org>
 
         Split EWS tool cold-boot.sh into modular components
index 681c22e..065532f 100644 (file)
@@ -46,8 +46,6 @@
             'chromium/TestShellStub.cpp',
             'chromium/TestShellWin.cpp',
             'chromium/TestShellX11.cpp',
-            'chromium/WebPermissions.cpp',
-            'chromium/WebPermissions.h',
             'chromium/WebThemeControlDRTWin.cpp',
             'chromium/WebThemeControlDRTWin.h',
             'chromium/WebThemeEngineDRTMac.mm',
@@ -91,6 +89,8 @@
             'chromium/TestRunner/src/TestRunner.h',
             'chromium/TestRunner/src/WebAccessibilityController.cpp',
             'chromium/TestRunner/src/WebEventSender.cpp',
+            'chromium/TestRunner/src/WebPermissions.cpp',
+            'chromium/TestRunner/src/WebPermissions.h',
             'chromium/TestRunner/src/WebPreferences.cpp',
             'chromium/TestRunner/src/WebTask.cpp',
             'chromium/TestRunner/src/WebTestInterfaces.cpp',
index 79091bd..4d006ec 100644 (file)
@@ -52,7 +52,6 @@
 #include "WebInputElement.h"
 #include "WebKit.h"
 #include "WebNotificationPresenter.h"
-#include "WebPermissions.h"
 #include "WebPrintParams.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
@@ -121,7 +120,6 @@ DRTTestRunner::DRTTestRunner(TestShell* shell)
     bindMethod("dumpProgressFinishedCallback", &DRTTestRunner::dumpProgressFinishedCallback);
     bindMethod("dumpSelectionRect", &DRTTestRunner::dumpSelectionRect);
     bindMethod("dumpStatusCallbacks", &DRTTestRunner::dumpWindowStatusChanges);
-    bindMethod("dumpPermissionClientCallbacks", &DRTTestRunner::dumpPermissionClientCallbacks);
     bindMethod("enableAutoResizeMode", &DRTTestRunner::enableAutoResizeMode);
     bindMethod("evaluateInWebInspector", &DRTTestRunner::evaluateInWebInspector);
 #if ENABLE(NOTIFICATIONS)
@@ -138,8 +136,6 @@ DRTTestRunner::DRTTestRunner(TestShell* shell)
     bindMethod("queueNonLoadingScript", &DRTTestRunner::queueNonLoadingScript);
     bindMethod("queueReload", &DRTTestRunner::queueReload);
     bindMethod("repaintSweepHorizontally", &DRTTestRunner::repaintSweepHorizontally);
-    bindMethod("setAllowDisplayOfInsecureContent", &DRTTestRunner::setAllowDisplayOfInsecureContent);
-    bindMethod("setAllowRunningOfInsecureContent", &DRTTestRunner::setAllowRunningOfInsecureContent);
     bindMethod("setAlwaysAcceptCookies", &DRTTestRunner::setAlwaysAcceptCookies);
     bindMethod("setCloseRemainingWindowsWhenComplete", &DRTTestRunner::setCloseRemainingWindowsWhenComplete);
     bindMethod("setCustomPolicyDelegate", &DRTTestRunner::setCustomPolicyDelegate);
@@ -170,10 +166,6 @@ DRTTestRunner::DRTTestRunner(TestShell* shell)
     bindMethod("waitForPolicyDelegate", &DRTTestRunner::waitForPolicyDelegate);
     bindMethod("waitUntilDone", &DRTTestRunner::waitUntilDone);
     bindMethod("windowCount", &DRTTestRunner::windowCount);
-    bindMethod("setImagesAllowed", &DRTTestRunner::setImagesAllowed);
-    bindMethod("setScriptsAllowed", &DRTTestRunner::setScriptsAllowed);
-    bindMethod("setStorageAllowed", &DRTTestRunner::setStorageAllowed);
-    bindMethod("setPluginsAllowed", &DRTTestRunner::setPluginsAllowed);
 
     bindMethod("setShouldStayOnPageAfterHandlingBeforeUnload", &DRTTestRunner::setShouldStayOnPageAfterHandlingBeforeUnload);
 
@@ -254,12 +246,6 @@ void DRTTestRunner::dumpWindowStatusChanges(const CppArgumentList&, CppVariant*
     result->setNull();
 }
 
-void DRTTestRunner::dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant* result)
-{
-    m_dumpPermissionClientCallbacks = true;
-    result->setNull();
-}
-
 void DRTTestRunner::waitUntilDone(const CppArgumentList&, CppVariant* result)
 {
     if (!webkit_support::BeingDebugged())
@@ -448,7 +434,6 @@ void DRTTestRunner::reset()
     m_dumpBackForwardList = false;
     m_dumpWindowStatusChanges = false;
     m_dumpSelectionRect = false;
-    m_dumpPermissionClientCallbacks = false;
     m_waitUntilDone = false;
     m_testRepaint = false;
     m_sweepHorizontally = false;
@@ -530,34 +515,6 @@ void DRTTestRunner::setWindowIsKey(const CppArgumentList& arguments, CppVariant*
     result->setNull();
 }
 
-void DRTTestRunner::setImagesAllowed(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setImagesAllowed(arguments[0].toBoolean());
-    result->setNull();
-}
-
-void DRTTestRunner::setScriptsAllowed(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setScriptsAllowed(arguments[0].toBoolean());
-    result->setNull();
-}
-
-void DRTTestRunner::setStorageAllowed(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setStorageAllowed(arguments[0].toBoolean());
-    result->setNull();
-}
-
-void DRTTestRunner::setPluginsAllowed(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setPluginsAllowed(arguments[0].toBoolean());
-    result->setNull();
-}
-
 void DRTTestRunner::setCustomPolicyDelegate(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {
@@ -758,22 +715,6 @@ void DRTTestRunner::repaintSweepHorizontally(const CppArgumentList&, CppVariant*
     result->setNull();
 }
 
-void DRTTestRunner::setAllowDisplayOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setDisplayingInsecureContentAllowed(arguments[0].toBoolean());
-
-    result->setNull();
-}
-
-void DRTTestRunner::setAllowRunningOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() > 0 && arguments[0].isBool())
-        m_shell->webPermissions()->setRunningInsecureContentAllowed(arguments[0].value.boolValue);
-
-    result->setNull();
-}
-
 void DRTTestRunner::clearAllDatabases(const CppArgumentList& arguments, CppVariant* result)
 {
     result->setNull();
index db26cdb..4c29618 100644 (file)
@@ -162,9 +162,6 @@ public:
     void testRepaint(const CppArgumentList&, CppVariant*);
     void repaintSweepHorizontally(const CppArgumentList&, CppVariant*);
 
-    void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*);
-    void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*);
-
     // Clears all databases.
     void clearAllDatabases(const CppArgumentList&, CppVariant*);
     // Sets the default quota for all origins
@@ -202,13 +199,6 @@ public:
     void wasMockSpeechRecognitionAborted(const CppArgumentList&, CppVariant*);
 #endif
 
-    // WebPermissionClient related.
-    void setImagesAllowed(const CppArgumentList&, CppVariant*);
-    void setScriptsAllowed(const CppArgumentList&, CppVariant*);
-    void setStorageAllowed(const CppArgumentList&, CppVariant*);
-    void setPluginsAllowed(const CppArgumentList&, CppVariant*);
-    void dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant*);
-
     void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, CppVariant*);
 
 #if ENABLE(POINTER_LOCK)
@@ -231,7 +221,6 @@ public:
     bool shouldDumpStatusCallbacks() { return m_dumpWindowStatusChanges; }
     bool shouldDumpSelectionRect() { return m_dumpSelectionRect; }
     bool shouldDumpBackForwardList() { return m_dumpBackForwardList; }
-    bool shouldDumpPermissionClientCallbacks() { return m_dumpPermissionClientCallbacks; }
     bool deferMainResourceDataLoad() { return m_deferMainResourceDataLoad; }
     void setShowDebugLayerTree(bool value) { m_showDebugLayerTree = value; }
     void setTitleTextDirection(WebKit::WebTextDirection dir)
@@ -336,10 +325,6 @@ private:
     // If true, the test_shell will dump all changes to window.status.
     bool m_dumpWindowStatusChanges;
 
-    // If true, output a descriptive line each time a permission client
-    // callback is invoked. Currently only implemented for allowImage.
-    bool m_dumpPermissionClientCallbacks;
-
     // When reset is called, go through and close all but the main test shell
     // window. By default, set to true but toggled to false using
     // setCloseRemainingWindowsWhenComplete().
index b2a93ba..f84ddc8 100644 (file)
@@ -77,6 +77,7 @@ public:
     virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) { };
     virtual WebKit::WebIntentRequest* currentWebIntentRequest() { return 0; }
     virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) { return std::string(); }
+    virtual std::string normalizeLayoutTestURL(const std::string&) { return std::string(); }
 };
 
 }
index 17bbcb7..fb3f68e 100644 (file)
@@ -33,6 +33,7 @@
 
 namespace WebKit {
 class WebArrayBufferView;
+class WebPermissionClient;
 }
 
 namespace WebTestRunner {
@@ -61,6 +62,7 @@ public:
     virtual bool shouldDumpResourceLoadCallbacks() const { return false; }
     virtual bool shouldDumpResourceRequestCallbacks() const { return false; }
     virtual bool shouldDumpResourceResponseMIMETypes() const { return false; }
+    virtual WebKit::WebPermissionClient* webPermissions() const { return 0; }
 };
 
 }
index bb965f4..2e3c396 100644 (file)
@@ -41,6 +41,7 @@
 #include "WebInputElement.h"
 #include "WebIntent.h"
 #include "WebIntentRequest.h"
+#include "WebPermissions.h"
 #include "WebPreferences.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
@@ -82,6 +83,7 @@ TestRunner::TestRunner()
     , m_delegate(0)
     , m_webView(0)
     , m_intentClient(adoptPtr(new EmptyWebDeliveredIntentClient))
+    , m_webPermissions(adoptPtr(new WebPermissions))
 {
     // Methods implemented in terms of chromium's public WebKit API.
     bindMethod("setTabKeyCyclesThroughElements", &TestRunner::setTabKeyCyclesThroughElements);
@@ -147,6 +149,13 @@ TestRunner::TestRunner()
     bindMethod("dumpResourceLoadCallbacks", &TestRunner::dumpResourceLoadCallbacks);
     bindMethod("dumpResourceRequestCallbacks", &TestRunner::dumpResourceRequestCallbacks);
     bindMethod("dumpResourceResponseMIMETypes", &TestRunner::dumpResourceResponseMIMETypes);
+    bindMethod("dumpPermissionClientCallbacks", &TestRunner::dumpPermissionClientCallbacks);
+    bindMethod("setImagesAllowed", &TestRunner::setImagesAllowed);
+    bindMethod("setScriptsAllowed", &TestRunner::setScriptsAllowed);
+    bindMethod("setStorageAllowed", &TestRunner::setStorageAllowed);
+    bindMethod("setPluginsAllowed", &TestRunner::setPluginsAllowed);
+    bindMethod("setAllowDisplayOfInsecureContent", &TestRunner::setAllowDisplayOfInsecureContent);
+    bindMethod("setAllowRunningOfInsecureContent", &TestRunner::setAllowRunningOfInsecureContent);
 
     // The following methods interact with the WebTestProxy.
     bindMethod("sendWebIntentResponse", &TestRunner::sendWebIntentResponse);
@@ -193,6 +202,12 @@ TestRunner::~TestRunner()
 {
 }
 
+void TestRunner::setDelegate(WebTestDelegate* delegate)
+{
+    m_delegate = delegate;
+    m_webPermissions->setDelegate(delegate);
+}
+
 void TestRunner::reset()
 {
     if (m_webView) {
@@ -231,6 +246,8 @@ void TestRunner::reset()
     m_platformName.set("chromium");
 
     m_userStyleSheetLocation = WebURL();
+
+    m_webPermissions->reset();
 }
 
 void TestRunner::setTestIsRunning(bool running)
@@ -333,6 +350,61 @@ bool TestRunner::shouldDumpResourceResponseMIMETypes() const
     return m_testIsRunning && m_dumpResourceResponseMIMETypes;
 }
 
+WebPermissionClient* TestRunner::webPermissions() const
+{
+    return m_webPermissions.get();
+}
+
+void TestRunner::dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant* result)
+{
+    m_webPermissions->setDumpCallbacks(true);
+    result->setNull();
+}
+
+void TestRunner::setImagesAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setImagesAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void TestRunner::setScriptsAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setScriptsAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void TestRunner::setStorageAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setStorageAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void TestRunner::setPluginsAllowed(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setPluginsAllowed(arguments[0].toBoolean());
+    result->setNull();
+}
+
+void TestRunner::setAllowDisplayOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setDisplayingInsecureContentAllowed(arguments[0].toBoolean());
+
+    result->setNull();
+}
+
+void TestRunner::setAllowRunningOfInsecureContent(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_webPermissions->setRunningInsecureContentAllowed(arguments[0].value.boolValue);
+
+    result->setNull();
+}
+
 void TestRunner::setTabKeyCyclesThroughElements(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool())
index bf15518..b937be5 100644 (file)
@@ -44,6 +44,7 @@ class WebView;
 
 namespace WebTestRunner {
 
+class WebPermissions;
 class WebTestDelegate;
 
 class TestRunner : public CppBoundClass, public WebTestRunner {
@@ -53,7 +54,7 @@ public:
 
     // FIXME: once DRTTestRunner is moved entirely to this class, change this
     // method to take a TestDelegate* instead.
-    void setDelegate(WebTestDelegate* delegate) { m_delegate = delegate; }
+    void setDelegate(WebTestDelegate*);
     void setWebView(WebKit::WebView* webView) { m_webView = webView; }
 
     void reset();
@@ -79,6 +80,7 @@ public:
     virtual bool shouldDumpResourceLoadCallbacks() const OVERRIDE;
     virtual bool shouldDumpResourceRequestCallbacks() const OVERRIDE;
     virtual bool shouldDumpResourceResponseMIMETypes() const OVERRIDE;
+    virtual WebKit::WebPermissionClient* webPermissions() const OVERRIDE;
 
 protected:
     // FIXME: make these private once the move from DRTTestRunner to TestRunner
@@ -259,6 +261,15 @@ private:
     // that may be present.
     void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
 
+    // WebPermissionClient related.
+    void setImagesAllowed(const CppArgumentList&, CppVariant*);
+    void setScriptsAllowed(const CppArgumentList&, CppVariant*);
+    void setStorageAllowed(const CppArgumentList&, CppVariant*);
+    void setPluginsAllowed(const CppArgumentList&, CppVariant*);
+    void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*);
+    void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*);
+    void dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant*);
+
     ///////////////////////////////////////////////////////////////////////////
     // Methods interacting with the WebTestProxy
 
@@ -369,6 +380,9 @@ private:
 
     // Mock object for testing delivering web intents.
     OwnPtr<WebKit::WebDeliveredIntentClient> m_intentClient;
+
+    // WebPermissionClient mock object.
+    OwnPtr<WebPermissions> m_webPermissions;
 };
 
 }
 #include "config.h"
 #include "WebPermissions.h"
 
-#include "DRTTestRunner.h"
-#include "TestShell.h"
+#include "WebTestDelegate.h"
 #include "platform/WebCString.h"
 #include "platform/WebURL.h"
 
-WebPermissions::WebPermissions(TestShell* shell)
-    : m_shell(shell)
+namespace WebTestRunner {
+
+WebPermissions::WebPermissions()
+    : m_delegate(0)
 {
     reset();
 }
@@ -49,16 +50,16 @@ WebPermissions::~WebPermissions()
 bool WebPermissions::allowImage(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebURL& imageURL)
 {
     bool allowed = enabledPerSettings && m_imagesAllowed;
-    if (testRunner()->shouldDumpPermissionClientCallbacks())
-        fprintf(stdout, "PERMISSION CLIENT: allowImage(%s): %s\n", m_shell->normalizeLayoutTestURL(imageURL.spec()).c_str(), allowed ? "true" : "false");
+    if (m_dumpCallbacks && m_delegate)
+        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + m_delegate->normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     return allowed;
 }
 
 bool WebPermissions::allowScriptFromSource(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebURL& scriptURL)
 {
     bool allowed = enabledPerSettings && m_scriptsAllowed;
-    if (testRunner()->shouldDumpPermissionClientCallbacks())
-        fprintf(stdout, "PERMISSION CLIENT: allowScriptFromSource(%s): %s\n", m_shell->normalizeLayoutTestURL(scriptURL.spec()).c_str(), allowed ? "true" : "false");
+    if (m_dumpCallbacks && m_delegate)
+        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + m_delegate->normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     return allowed;
 }
 
@@ -72,14 +73,12 @@ bool WebPermissions::allowPlugins(WebKit::WebFrame*, bool enabledPerSettings)
     return enabledPerSettings && m_pluginsAllowed;
 }
 
-bool WebPermissions::allowDisplayingInsecureContent(WebKit::WebFrame*, bool enabledPerSettings,
-                                                    const WebKit::WebSecurityOrigin&, const WebKit::WebURL&)
+bool WebPermissions::allowDisplayingInsecureContent(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebSecurityOrigin&, const WebKit::WebURL&)
 {
     return enabledPerSettings || m_displayingInsecureContentAllowed;
 }
 
-bool WebPermissions::allowRunningInsecureContent(WebKit::WebFrame*, bool enabledPerSettings,
-                                                 const WebKit::WebSecurityOrigin&, const WebKit::WebURL&)
+bool WebPermissions::allowRunningInsecureContent(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebSecurityOrigin&, const WebKit::WebURL&)
 {
     return enabledPerSettings || m_runningInsecureContentAllowed;
 }
@@ -114,8 +113,19 @@ void WebPermissions::setRunningInsecureContentAllowed(bool allowed)
     m_runningInsecureContentAllowed = allowed;
 }
 
+void WebPermissions::setDelegate(WebTestDelegate* delegate)
+{
+    m_delegate = delegate;
+}
+
+void WebPermissions::setDumpCallbacks(bool dumpCallbacks)
+{
+    m_dumpCallbacks = dumpCallbacks;
+}
+
 void WebPermissions::reset()
 {
+    m_dumpCallbacks = false;
     m_imagesAllowed = true;
     m_scriptsAllowed = true;
     m_storageAllowed = true;
@@ -124,9 +134,4 @@ void WebPermissions::reset()
     m_runningInsecureContentAllowed = false;
 }
 
-// Private functions ----------------------------------------------------------
-
-DRTTestRunner* WebPermissions::testRunner() const
-{
-    return m_shell->testRunner();
 }
 
 #include "WebPermissionClient.h"
 
-class DRTTestRunner;
-class TestShell;
+namespace WebTestRunner {
+
+class WebTestDelegate;
 
 class WebPermissions : public WebKit::WebPermissionClient {
 public:
-    WebPermissions(TestShell*);
+    WebPermissions();
     virtual ~WebPermissions();
 
     // Override WebPermissionClient methods.
@@ -46,10 +47,8 @@ public:
     virtual bool allowScriptFromSource(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebURL& scriptURL);
     virtual bool allowStorage(WebKit::WebFrame*, bool local);
     virtual bool allowPlugins(WebKit::WebFrame*, bool enabledPerSettings);
-    virtual bool allowDisplayingInsecureContent(WebKit::WebFrame*, bool enabledPerSettings,
-                                                const WebKit::WebSecurityOrigin&, const WebKit::WebURL&);
-    virtual bool allowRunningInsecureContent(WebKit::WebFrame*, bool enabledPerSettings,
-                                             const WebKit::WebSecurityOrigin&, const WebKit::WebURL&);
+    virtual bool allowDisplayingInsecureContent(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebSecurityOrigin&, const WebKit::WebURL&);
+    virtual bool allowRunningInsecureContent(WebKit::WebFrame*, bool enabledPerSettings, const WebKit::WebSecurityOrigin&, const WebKit::WebURL&);
 
     // Hooks to set the different policies.
     void setImagesAllowed(bool);
@@ -62,11 +61,12 @@ public:
     // Resets the policy to allow everything, except for running insecure content.
     void reset();
 
-private:
-    DRTTestRunner* testRunner() const;
+    void setDelegate(WebTestDelegate*);
+    void setDumpCallbacks(bool);
 
-    // Non-owning pointer. The WebPermissions instance is owned by this TestShell instance.
-    TestShell* m_shell;
+private:
+    WebTestDelegate* m_delegate;
+    bool m_dumpCallbacks;
 
     bool m_imagesAllowed;
     bool m_scriptsAllowed;
@@ -76,4 +76,6 @@ private:
     bool m_runningInsecureContentAllowed;
 };
 
+}
+
 #endif
index 37d0b6d..48e8be1 100644 (file)
@@ -43,7 +43,6 @@
 #include "WebHistoryItem.h"
 #include "WebIDBFactory.h"
 #include "WebTestingSupport.h"
-#include "WebPermissions.h"
 #include "WebRuntimeFeatures.h"
 #include "WebScriptController.h"
 #include "WebSettings.h"
@@ -161,7 +160,6 @@ TestShell::TestShell()
 
 void TestShell::initialize()
 {
-    m_webPermissions = adoptPtr(new WebPermissions(this));
     m_testInterfaces = adoptPtr(new WebTestInterfaces());
     m_testRunner = adoptPtr(new DRTTestRunner(this));
     m_testInterfaces->setTestRunner(m_testRunner.get());
@@ -318,7 +316,6 @@ void TestShell::resizeWindowForTest(WebViewHost* window, const WebURL& url)
 void TestShell::resetTestController()
 {
     resetWebSettings(*webView());
-    m_webPermissions->reset();
     m_testInterfaces->resetAll();
     m_testRunner->reset();
     m_webViewHost->reset();
@@ -763,7 +760,7 @@ WebViewHost* TestShell::createNewWindow(const WebKit::WebURL& url, DRTDevToolsAg
         host->setDelegate(host);
     host->setProxy(host);
     WebView* view = WebView::create(host);
-    view->setPermissionClient(webPermissions());
+    view->setPermissionClient(m_testInterfaces->testRunner()->webPermissions());
     view->setDevToolsAgentClient(devToolsAgent);
     host->setWebWidget(view);
     m_prefs.applyTo(view);
index 1c6dd8f..5bf54cb 100644 (file)
@@ -57,7 +57,6 @@ class DRTDevToolsAgent;
 class DRTDevToolsCallArgs;
 class DRTDevToolsClient;
 class MockWebPrerenderingSupport;
-class WebPermissions;
 
 struct TestParams {
     bool dumpTree;
@@ -96,8 +95,6 @@ public:
     WebTestRunner::WebPreferences* preferences() { return &m_prefs; }
     void applyPreferences() { m_prefs.applyTo(m_webView); }
 
-    WebPermissions* webPermissions() { return m_webPermissions.get(); }
-
     void bindJSObjectsToWindow(WebKit::WebFrame*);
     void runFileTest(const TestParams&, bool shouldDumpPixelTests);
     void callJSGC();
@@ -210,7 +207,6 @@ private:
 
     // Be careful of the destruction order of the following objects.
     TestEventPrinter m_printer;
-    OwnPtr<WebPermissions> m_webPermissions;
     OwnPtr<DRTDevToolsAgent> m_drtDevToolsAgent;
     OwnPtr<DRTDevToolsClient> m_drtDevToolsClient;
     OwnPtr<WebTestRunner::WebTestInterfaces> m_testInterfaces;
index 14779fa..aff2a55 100644 (file)
@@ -1058,6 +1058,11 @@ std::string WebViewHost::makeURLErrorDescription(const WebKit::WebURLError& erro
     return webkit_support::MakeURLErrorDescription(error);
 }
 
+std::string WebViewHost::normalizeLayoutTestURL(const std::string& url)
+{
+    return m_shell->normalizeLayoutTestURL(url);
+}
+
 // Public functions -----------------------------------------------------------
 
 WebViewHost::WebViewHost(TestShell* shell)
index fc8bbf4..c8e138d 100644 (file)
@@ -149,6 +149,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
     virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) OVERRIDE;
     virtual WebKit::WebIntentRequest* currentWebIntentRequest() OVERRIDE;
     virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVERRIDE;
+    virtual std::string normalizeLayoutTestURL(const std::string&) OVERRIDE;
 
     // NavigationHost
     virtual bool navigate(const TestNavigationEntry&, bool reload);