Web Inspector: only allow evaluateForTestInFrontend for front-ends under test.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 17:57:26 +0000 (17:57 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 17:57:26 +0000 (17:57 +0000)
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):

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

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorFrontendClient.h
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/inspector/front-end/DOMExtension.js
Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js
Source/WebCore/inspector/front-end/TestController.js
Source/WebCore/inspector/front-end/externs.js
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebDevToolsFrontendClient.h
Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp
Source/WebKit/chromium/src/InspectorFrontendClientImpl.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/DRTDevToolsClient.cpp
Tools/DumpRenderTree/chromium/DRTDevToolsClient.h

index 40f7487..c6959f7 100644 (file)
@@ -1,3 +1,40 @@
+2013-01-22  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: only allow evaluateForTestInFrontend for front-ends under test.
+        https://bugs.webkit.org/show_bug.cgi?id=107523
+
+        Reviewed by Yury Semikhatsky.
+
+        * 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:
+
 2013-01-23  Andrey Lushnikov  <lushnikov@chromium.org>
 
         Web Inspector: remove invisibleLineRow code from paintLines DTE method
index 344abaa..b3bacc2 100644 (file)
@@ -2388,6 +2388,7 @@ __ZN7WebCore24InspectorInstrumentation17didBeginFrameImplEPNS_19InstrumentingAge
 __ZN7WebCore24InspectorInstrumentation17s_frontendCounterE
 __ZN7WebCore24InspectorInstrumentation18didCancelFrameImplEPNS_19InstrumentingAgentsE
 __ZN7WebCore24InspectorInstrumentation26instrumentingAgentsForPageEPNS_4PageE
+__ZN7WebCore28InspectorFrontendClientLocal11isUnderTestEv
 __ZN7WebCore28InspectorFrontendClientLocal11showConsoleEv
 __ZN7WebCore28InspectorFrontendClientLocal12moveWindowByEff
 __ZN7WebCore28InspectorFrontendClientLocal12openInNewTabERKN3WTF6StringE
index 87d5b20..2e5e5d3 100644 (file)
@@ -86,6 +86,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     , 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();
@@ -299,8 +300,14 @@ void InspectorController::webViewResized(const IntSize& size)
     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);
 }
 
index af86c88..a18a898 100644 (file)
@@ -104,6 +104,7 @@ public:
     void hideHighlight();
     Node* highlightedNode() const;
 
+    bool isUnderTest();
     void evaluateForTestInFrontend(long callId, const String& script);
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -150,6 +151,7 @@ private:
     Page* m_page;
     InspectorClient* m_inspectorClient;
     InspectorAgentRegistry m_agents;
+    bool m_isUnderTest;
 };
 
 }
index be3bf06..ad08d3f 100644 (file)
@@ -76,6 +76,8 @@ public:
     virtual void requestFileSystems() = 0;
     virtual void addFileSystem() = 0;
     virtual void removeFileSystem(const String& fileSystemPath) = 0;
+
+    virtual bool isUnderTest() = 0;
 };
 
 } // namespace WebCore
index 7a7b2b8..078739c 100644 (file)
@@ -166,7 +166,7 @@ bool InspectorFrontendClientLocal::canAttachWindow()
 {
     // 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 @@ void InspectorFrontendClientLocal::sendMessageToBackend(const String& message)
     m_dispatchTask->dispatch(message);
 }
 
+bool InspectorFrontendClientLocal::isUnderTest()
+{
+    return m_inspectorController->isUnderTest();
+}
+
 bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression)
 {
     if (!m_frontendPage->mainFrame())
index 0d6cfc9..a520d3d 100644 (file)
@@ -80,6 +80,7 @@ public:
     virtual void requestFileSystems() { }
     virtual void addFileSystem() { }
     virtual void removeFileSystem(const String&) { }
+    virtual bool isUnderTest();
 
     bool canAttachWindow();
     void setDockingUnavailable(bool);
index 03fd645..fea97fa 100644 (file)
@@ -328,6 +328,11 @@ PassRefPtr<DOMFileSystem> InspectorFrontendHost::isolatedFileSystem(const String
 }
 #endif
 
+bool InspectorFrontendHost::isUnderTest()
+{
+    return m_client && m_client->isUnderTest();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index c8b8d35..00ce917 100644 (file)
@@ -94,6 +94,8 @@ public:
     PassRefPtr<DOMFileSystem> isolatedFileSystem(const String& fileSystemName, const String& rootURL);
 #endif
 
+    bool isUnderTest();
+
 private:
 #if ENABLE(CONTEXT_MENUS)
     friend class FrontendMenuProvider;
index ef50859..36f1c5b 100644 (file)
@@ -72,4 +72,6 @@
     void addFileSystem();
     void removeFileSystem(in DOMString fileSystemPath);
     [Conditional=FILE_SYSTEM] DOMFileSystem isolatedFileSystem(in DOMString fileSystemId, in DOMString registeredName);
+
+    boolean isUnderTest();
 };
index 43436fc..318ff3b 100644 (file)
@@ -573,8 +573,6 @@ function consumeEvent(e)
     e.consume();
 }
 
-window.isUnderTest = false;
-
 /**
  * Mutation observers leak memory. Keep track of them and disconnect
  * on unload.
index 13e1851..6f353d9 100644 (file)
@@ -224,6 +224,11 @@ WebInspector.InspectorFrontendHostStub.prototype = {
     canInspectWorkers: function()
     {
         return true;
+    },
+
+    isUnderTest: function()
+    {
+        return false;
     }
 }
 
index bb400ed..cf0c32e 100644 (file)
  * 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);
 }
index ac95f2d..1b7324a 100644 (file)
@@ -65,8 +65,6 @@ function postMessage(message) {}
 /** @type {*} */
 window.testRunner = null;
 
-window.isUnderTest = false;
-
 /**
  * @constructor
  */
index 7d80ea4..035982a 100644 (file)
@@ -1,3 +1,18 @@
+2013-01-22  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: only allow evaluateForTestInFrontend for front-ends under test.
+        https://bugs.webkit.org/show_bug.cgi?id=107523
+
+        Reviewed by Yury Semikhatsky.
+
+        * public/WebDevToolsFrontendClient.h:
+        (WebKit::WebDevToolsFrontendClient::isUnderTest):
+        (WebDevToolsFrontendClient):
+        * src/InspectorFrontendClientImpl.cpp:
+        (WebKit::InspectorFrontendClientImpl::isUnderTest):
+        * src/InspectorFrontendClientImpl.h:
+        (InspectorFrontendClientImpl):
+
 2013-01-22  Mark Lam  <mark.lam@apple.com>
 
         Change the Supplementable class to not use AtomicString.
index be756b9..e5d5b67 100644 (file)
@@ -57,6 +57,8 @@ public:
     virtual void addFileSystem() { }
     virtual void removeFileSystem(const WebString& fileSystemPath) { }
 
+    virtual bool isUnderTest() { return false; }
+
 protected:
     virtual ~WebDevToolsFrontendClient() {}
 };
index 596f8c9..4a551ea 100644 (file)
@@ -174,5 +174,9 @@ void InspectorFrontendClientImpl::removeFileSystem(const String& fileSystemPath)
     m_client->removeFileSystem(fileSystemPath);
 }
 
+bool InspectorFrontendClientImpl::isUnderTest()
+{
+    return m_client->isUnderTest();
+}
 
 } // namespace WebKit
index f2f61ad..afee003 100644 (file)
@@ -80,6 +80,9 @@ public:
     virtual void requestFileSystems();
     virtual void addFileSystem();
     virtual void removeFileSystem(const String& fileSystemPath);
+
+    virtual bool isUnderTest();
+
 private:
     WebCore::Page* m_frontendPage;
     WebDevToolsFrontendClient* m_client;
index 3629965..17c630c 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-22  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: only allow evaluateForTestInFrontend for front-ends under test.
+        https://bugs.webkit.org/show_bug.cgi?id=107523
+
+        Reviewed by Yury Semikhatsky.
+
+        * DumpRenderTree/chromium/DRTDevToolsClient.cpp:
+        (DRTDevToolsClient::isUnderTest):
+        (DRTDevToolsClient::call):
+        * DumpRenderTree/chromium/DRTDevToolsClient.h:
+        (DRTDevToolsClient):
+
 2013-01-23  Tim 'mithro' Ansell  <mithro@mithis.com>
 
         Removing command line shortening as it makes it difficult to see the command during errors.
index 08df1d5..f458afe 100644 (file)
@@ -92,6 +92,11 @@ void DRTDevToolsClient::undockWindow()
     // Not implemented.
 }
 
+bool DRTDevToolsClient::isUnderTest()
+{
+    return true;
+}
+
 void DRTDevToolsClient::asyncCall(const WebString& args)
 {
     postTask(new AsyncCallTask(this, args));
@@ -101,4 +106,3 @@ void DRTDevToolsClient::call(const WebString& args)
 {
     m_webDevToolsFrontend->dispatchOnInspectorFrontend(args);
 }
-
index 5f486dd..e57fcef 100644 (file)
@@ -60,6 +60,7 @@ public:
     virtual void closeWindow();
     virtual void dockWindow();
     virtual void undockWindow();
+    virtual bool isUnderTest();
 
     void asyncCall(const WebKit::WebString& args);