Title: [142085] branches/chromium/1364
Revision
142085
Author
pfeld...@chromium.org
Date
2013-02-07 01:37:42 -0800 (Thu, 07 Feb 2013)

Log Message

Merge 140539
> Web Inspector: only allow evaluateForTestInFrontend for front-ends under test.
> https://bugs.webkit.org/show_bug.cgi?id=107523
> 
> Reviewed by Yury Semikhatsky.
> 
> Source/WebCore:
> 
> * inspector/InspectorController.cpp:
> (WebCore::InspectorController::InspectorController):
> (WebCore::InspectorController::isUnderTest):
> (WebCore):
> (WebCore::InspectorController::evaluateForTestInFrontend):
> * inspector/InspectorController.h:
> (InspectorController):
> * inspector/InspectorFrontendClient.h:
> (InspectorFrontendClient):
> * inspector/InspectorFrontendClientLocal.cpp:
> (WebCore::InspectorFrontendClientLocal::canAttachWindow):
> (WebCore::InspectorFrontendClientLocal::isUnderTest):
> (WebCore):
> * inspector/InspectorFrontendClientLocal.h:
> (InspectorFrontendClientLocal):
> * inspector/InspectorFrontendHost.cpp:
> (WebCore::InspectorFrontendHost::isUnderTest):
> (WebCore):
> * inspector/InspectorFrontendHost.h:
> (InspectorFrontendHost):
> * inspector/InspectorFrontendHost.idl:
> * inspector/front-end/DOMExtension.js:
> * inspector/front-end/InspectorFrontendHostStub.js:
> (.WebInspector.InspectorFrontendHostStub.prototype.canInspectWorkers):
> (.WebInspector.InspectorFrontendHostStub.prototype.isUnderTest):
> * inspector/front-end/TestController.js:
> (.invokeMethod):
> (WebInspector.evaluateForTestInFrontend):
> * inspector/front-end/externs.js:
> 
> Source/WebKit/chromium:
> 
> * public/WebDevToolsFrontendClient.h:
> (WebKit::WebDevToolsFrontendClient::isUnderTest):
> (WebDevToolsFrontendClient):
> * src/InspectorFrontendClientImpl.cpp:
> (WebKit::InspectorFrontendClientImpl::isUnderTest):
> * src/InspectorFrontendClientImpl.h:
> (InspectorFrontendClientImpl):
> 
> Tools:
> 
> * DumpRenderTree/chromium/DRTDevToolsClient.cpp:
> (DRTDevToolsClient::isUnderTest):
> (DRTDevToolsClient::call):
> * DumpRenderTree/chromium/DRTDevToolsClient.h:
> (DRTDevToolsClient):

TBR=pfeld...@chromium.org
Review URL: https://codereview.chromium.org/12224049

Modified Paths

Diff

Modified: branches/chromium/1364/Source/WebCore/WebCore.exp.in (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/WebCore.exp.in	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/WebCore.exp.in	2013-02-07 09:37:42 UTC (rev 142085)
@@ -2363,6 +2363,7 @@
 __ZN7WebCore24InspectorInstrumentation17s_frontendCounterE
 __ZN7WebCore24InspectorInstrumentation18didCancelFrameImplEPNS_19InstrumentingAgentsE
 __ZN7WebCore24InspectorInstrumentation26instrumentingAgentsForPageEPNS_4PageE
+__ZN7WebCore28InspectorFrontendClientLocal11isUnderTestEv
 __ZN7WebCore28InspectorFrontendClientLocal11showConsoleEv
 __ZN7WebCore28InspectorFrontendClientLocal12moveWindowByEff
 __ZN7WebCore28InspectorFrontendClientLocal12openInNewTabERKN3WTF6StringE

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorController.cpp (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorController.cpp	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorController.cpp	2013-02-07 09:37:42 UTC (rev 142085)
@@ -86,6 +86,7 @@
     , m_overlay(InspectorOverlay::create(page, inspectorClient))
     , m_page(page)
     , m_inspectorClient(inspectorClient)
+    , m_isUnderTest(false)
 {
     OwnPtr<InspectorAgent> inspectorAgentPtr(InspectorAgent::create(page, m_injectedScriptManager.get(), m_instrumentingAgents.get(), m_state.get()));
     m_inspectorAgent = inspectorAgentPtr.get();
@@ -298,8 +299,14 @@
     m_pageAgent->webViewResized(size);
 }
 
+bool InspectorController::isUnderTest()
+{
+    return m_isUnderTest;
+}
+
 void InspectorController::evaluateForTestInFrontend(long callId, const String& script)
 {
+    m_isUnderTest = true;
     m_inspectorAgent->evaluateForTestInFrontend(callId, script);
 }
 

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorController.h (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorController.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorController.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -103,6 +103,7 @@
     void hideHighlight();
     Node* highlightedNode() const;
 
+    bool isUnderTest();
     void evaluateForTestInFrontend(long callId, const String& script);
 
 #if ENABLE(_javascript__DEBUGGER)
@@ -148,6 +149,7 @@
     Page* m_page;
     InspectorClient* m_inspectorClient;
     InspectorAgentRegistry m_agents;
+    bool m_isUnderTest;
 };
 
 }

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClient.h (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClient.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClient.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -71,6 +71,8 @@
     virtual void inspectedURLChanged(const String&) = 0;
 
     virtual void sendMessageToBackend(const String&) = 0;
+
+    virtual bool isUnderTest() = 0;
 };
 
 } // namespace WebCore

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2013-02-07 09:37:42 UTC (rev 142085)
@@ -166,7 +166,7 @@
 {
     // Don't allow the attach if the window would be too small to accommodate the minimum inspector height.
     // Also don't allow attaching to another inspector -- two inspectors in one window is too much!
-    bool isInspectorPage = m_inspectorController->inspectedPage()->inspectorController()->hasInspectorFrontendClient();
+    bool isInspectorPage = m_inspectorController->hasInspectorFrontendClient();
     unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
     unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
     return minimumAttachedHeight <= maximumAttachedHeight && !isInspectorPage;
@@ -297,6 +297,11 @@
     m_dispatchTask->dispatch(message);
 }
 
+bool InspectorFrontendClientLocal::isUnderTest()
+{
+    return m_inspectorController->isUnderTest();
+}
+
 bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& _expression_)
 {
     if (!m_frontendPage->mainFrame())

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.h (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -76,6 +76,8 @@
 
     virtual void sendMessageToBackend(const String& message);
 
+    virtual bool isUnderTest();
+
     bool canAttachWindow();
     void setDockingUnavailable(bool);
 

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.cpp (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.cpp	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.cpp	2013-02-07 09:37:42 UTC (rev 142085)
@@ -294,6 +294,11 @@
     return String(data.data(), data.size());
 }
 
+bool InspectorFrontendHost::isUnderTest()
+{
+    return m_client && m_client->isUnderTest();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.h (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -85,6 +85,8 @@
 
     String loadResourceSynchronously(const String& url);
 
+    bool isUnderTest();
+
 private:
 #if ENABLE(CONTEXT_MENUS)
     friend class FrontendMenuProvider;

Modified: branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.idl (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.idl	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/InspectorFrontendHost.idl	2013-02-07 09:37:42 UTC (rev 142085)
@@ -66,4 +66,6 @@
     [Custom] void recordSettingChanged(in unsigned long settingChanged);
     
     DOMString loadResourceSynchronously(in DOMString url);
+
+    boolean isUnderTest();
 };

Modified: branches/chromium/1364/Source/WebCore/inspector/front-end/DOMExtension.js (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/front-end/DOMExtension.js	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/front-end/DOMExtension.js	2013-02-07 09:37:42 UTC (rev 142085)
@@ -548,8 +548,6 @@
     e.consume();
 }
 
-window.isUnderTest = false;
-
 /**
  * Mutation observers leak memory. Keep track of them and disconnect
  * on unload.

Modified: branches/chromium/1364/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2013-02-07 09:37:42 UTC (rev 142085)
@@ -202,6 +202,11 @@
     canInspectWorkers: function()
     {
         return true;
+    },
+
+    isUnderTest: function()
+    {
+        return false;
     }
 }
 

Modified: branches/chromium/1364/Source/WebCore/inspector/front-end/TestController.js (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/front-end/TestController.js	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/front-end/TestController.js	2013-02-07 09:37:42 UTC (rev 142085)
@@ -28,33 +28,22 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/**
- * @constructor
- */
-WebInspector.TestController = function()
-{
-}
-
-WebInspector.TestController.prototype = {
-    notifyDone: function(callId, result)
-    {
-        var message = typeof result === "undefined" ? "\"<undefined>\"" : JSON.stringify(result);
-        RuntimeAgent.evaluate("didEvaluateForTestInFrontend(" + callId + ", " + message + ")", "test");
-    }
-}
-
 WebInspector.evaluateForTestInFrontend = function(callId, script)
 {
-    window.isUnderTest = true;
+    if (!InspectorFrontendHost.isUnderTest())
+        return;
+
     function invokeMethod()
     {
+        var message;
         try {
             script = script + "//@ sourceURL=evaluateInWebInspector" + callId + ".js";
             var result = window.eval(script);
-            WebInspector.TestController.prototype.notifyDone(callId, result);
+            message = typeof result === "undefined" ? "\"<undefined>\"" : JSON.stringify(result);
         } catch (e) {
-            WebInspector.TestController.prototype.notifyDone(callId, e.toString());
+            message = e.toString();
         }
+        RuntimeAgent.evaluate("didEvaluateForTestInFrontend(" + callId + ", " + message + ")", "test");
     }
     InspectorBackend.runAfterPendingDispatches(invokeMethod);
 }

Modified: branches/chromium/1364/Source/WebCore/inspector/front-end/externs.js (142084 => 142085)


--- branches/chromium/1364/Source/WebCore/inspector/front-end/externs.js	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebCore/inspector/front-end/externs.js	2013-02-07 09:37:42 UTC (rev 142085)
@@ -65,8 +65,6 @@
 /** @type {*} */
 window.testRunner = null;
 
-window.isUnderTest = false;
-
 /**
  * @constructor
  */

Modified: branches/chromium/1364/Source/WebKit/chromium/public/WebDevToolsFrontendClient.h (142084 => 142085)


--- branches/chromium/1364/Source/WebKit/chromium/public/WebDevToolsFrontendClient.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebKit/chromium/public/WebDevToolsFrontendClient.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -53,6 +53,8 @@
     virtual void save(const WebString& url, const WebString& content, bool saveAs) { }
     virtual void append(const WebString& url, const WebString& content) { }
 
+    virtual bool isUnderTest() { return false; }
+
 protected:
     virtual ~WebDevToolsFrontendClient() {}
 };

Modified: branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp (142084 => 142085)


--- branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp	2013-02-07 09:37:42 UTC (rev 142085)
@@ -154,4 +154,9 @@
     m_client->sendMessageToBackend(message);
 }
 
+bool InspectorFrontendClientImpl::isUnderTest()
+{
+    return m_client->isUnderTest();
+}
+
 } // namespace WebKit

Modified: branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h (142084 => 142085)


--- branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Source/WebKit/chromium/src/InspectorFrontendClientImpl.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -75,6 +75,9 @@
     virtual void inspectedURLChanged(const WTF::String&);
 
     virtual void sendMessageToBackend(const WTF::String&);
+
+    virtual bool isUnderTest();
+
 private:
     WebCore::Page* m_frontendPage;
     WebDevToolsFrontendClient* m_client;

Modified: branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp (142084 => 142085)


--- branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp	2013-02-07 09:37:42 UTC (rev 142085)
@@ -92,6 +92,11 @@
     // Not implemented.
 }
 
+bool DRTDevToolsClient::isUnderTest()
+{
+    return true;
+}
+
 void DRTDevToolsClient::asyncCall(const WebString& args)
 {
     postTask(new AsyncCallTask(this, args));
@@ -101,4 +106,3 @@
 {
     m_webDevToolsFrontend->dispatchOnInspectorFrontend(args);
 }
-

Modified: branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h (142084 => 142085)


--- branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h	2013-02-07 09:24:51 UTC (rev 142084)
+++ branches/chromium/1364/Tools/DumpRenderTree/chromium/DRTDevToolsClient.h	2013-02-07 09:37:42 UTC (rev 142085)
@@ -60,6 +60,7 @@
     virtual void closeWindow();
     virtual void dockWindow();
     virtual void undockWindow();
+    virtual bool isUnderTest();
 
     void asyncCall(const WebKit::WebString& args);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to