diff options
author | battre <battre@chromium.org> | 2016-03-24 04:52:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-24 11:53:28 +0000 |
commit | 46c66a666056b2bca1e991442a42e09af4cbee5b (patch) | |
tree | 0e9cb780cbfa81e2ac9b0688706ebc3b67c53d3f | |
parent | 513bc4519eaf958471a4d169fe3169addfe2f5b3 (diff) | |
download | chromium_src-46c66a666056b2bca1e991442a42e09af4cbee5b.zip chromium_src-46c66a666056b2bca1e991442a42e09af4cbee5b.tar.gz chromium_src-46c66a666056b2bca1e991442a42e09af4cbee5b.tar.bz2 |
Revert of [DevTools] Use InspectorFrontendHost.readyForTest for layout tests. (patchset #3 id:40001 of https://codereview.chromium.org/1819243002/ )
Reason for revert:
http/tests/inspector/resource-tree/resource-tree-reload.html is flaky
BUG=597572
Original issue's description:
> [DevTools] Use InspectorFrontendHost.readyForTest for layout tests.
>
> BUG=none
>
> Committed: https://crrev.com/89f7238cebbf5d77e4caa84d0a2750f6faa7e983
> Cr-Commit-Position: refs/heads/master@{#383015}
TBR=pfeldman@chromium.org,dgozman@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=none
Review URL: https://codereview.chromium.org/1828983002
Cr-Commit-Position: refs/heads/master@{#383053}
23 files changed, 89 insertions, 124 deletions
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index a02f9fc..d1e4779 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -716,8 +716,7 @@ DevToolsWindow::DevToolsWindow(Profile* profile, // Passing "dockSide=undocked" parameter ensures proper UI. life_stage_(can_dock ? kNotLoaded : kIsDockedSet), action_on_load_(DevToolsToggleAction::NoOp()), - intercepted_page_beforeunload_(false), - ready_for_test_(false) { + intercepted_page_beforeunload_(false) { // Set up delegate, so we get fully-functional window immediately. // It will not appear in UI though until |life_stage_ == kLoadCompleted|. main_web_contents_->SetDelegate(this); @@ -1176,7 +1175,6 @@ void DevToolsWindow::OnLoadCompleted() { } void DevToolsWindow::ReadyForTest() { - ready_for_test_ = true; if (!ready_for_test_callback_.is_null()) { ready_for_test_callback_.Run(); ready_for_test_callback_ = base::Closure(); diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h index 71b2b0e..38161b6 100644 --- a/chrome/browser/devtools/devtools_window.h +++ b/chrome/browser/devtools/devtools_window.h @@ -338,7 +338,6 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate, bool intercepted_page_beforeunload_; base::Closure load_completed_callback_; base::Closure close_callback_; - bool ready_for_test_; base::Closure ready_for_test_callback_; base::TimeTicks inspect_element_start_time_; diff --git a/chrome/browser/devtools/devtools_window_testing.cc b/chrome/browser/devtools/devtools_window_testing.cc index 6782d31..f87939d 100644 --- a/chrome/browser/devtools/devtools_window_testing.cc +++ b/chrome/browser/devtools/devtools_window_testing.cc @@ -96,12 +96,10 @@ void DevToolsWindowTesting::WindowClosed(DevToolsWindow* window) { // static void DevToolsWindowTesting::WaitForDevToolsWindowLoad(DevToolsWindow* window) { - if (!window->ready_for_test_) { - scoped_refptr<content::MessageLoopRunner> runner = - new content::MessageLoopRunner; - window->ready_for_test_callback_ = runner->QuitClosure(); - runner->Run(); - } + scoped_refptr<content::MessageLoopRunner> runner = + new content::MessageLoopRunner; + window->ready_for_test_callback_ = runner->QuitClosure(); + runner->Run(); base::string16 harness = base::UTF8ToUTF16( content::DevToolsFrontendHost::GetFrontendResource(kHarnessScript)); window->main_web_contents_->GetMainFrame()->ExecuteJavaScript(harness); diff --git a/components/test_runner/web_test_delegate.h b/components/test_runner/web_test_delegate.h index f0b2afa..ef5dddf 100644 --- a/components/test_runner/web_test_delegate.h +++ b/components/test_runner/web_test_delegate.h @@ -136,7 +136,7 @@ class WebTestDelegate { virtual void CloseDevTools() = 0; // Evaluate the given script in the DevTools agent. - virtual void EvaluateInWebInspector(int call_id, + virtual void EvaluateInWebInspector(long call_id, const std::string& script) = 0; // Evaluate the given script in the inspector overlay page. diff --git a/content/shell/browser/layout_test/blink_test_controller.cc b/content/shell/browser/layout_test/blink_test_controller.cc index 9f4b1b7..b823e7f 100644 --- a/content/shell/browser/layout_test/blink_test_controller.cc +++ b/content/shell/browser/layout_test/blink_test_controller.cc @@ -413,8 +413,6 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, OnClearDevToolsLocalStorage) IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) - IPC_MESSAGE_HANDLER(ShellViewHostMsg_EvaluateInDevTools, - OnEvaluateInDevTools) IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) @@ -767,12 +765,6 @@ void BlinkTestController::OnShowDevTools(const std::string& settings, devtools_frontend_->Focus(); } -void BlinkTestController::OnEvaluateInDevTools( - int call_id, const std::string& script) { - if (devtools_frontend_) - devtools_frontend_->EvaluateInFrontend(call_id, script); -} - void BlinkTestController::OnCloseDevTools() { if (devtools_frontend_) devtools_frontend_->DisconnectFromTarget(); diff --git a/content/shell/browser/layout_test/blink_test_controller.h b/content/shell/browser/layout_test/blink_test_controller.h index 4bcc36f..10d4a44 100644 --- a/content/shell/browser/layout_test/blink_test_controller.h +++ b/content/shell/browser/layout_test/blink_test_controller.h @@ -202,7 +202,6 @@ class BlinkTestController : public base::NonThreadSafe, void OnClearDevToolsLocalStorage(); void OnShowDevTools(const std::string& settings, const std::string& frontend_url); - void OnEvaluateInDevTools(int call_id, const std::string& script); void OnCloseDevTools(); void OnGoToOffset(int offset); void OnReload(); diff --git a/content/shell/browser/layout_test/layout_test_devtools_frontend.cc b/content/shell/browser/layout_test/layout_test_devtools_frontend.cc index f30846a..7da2af53 100644 --- a/content/shell/browser/layout_test/layout_test_devtools_frontend.cc +++ b/content/shell/browser/layout_test/layout_test_devtools_frontend.cc @@ -5,13 +5,9 @@ #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" #include "base/command_line.h" -#include "base/json/json_reader.h" -#include "base/json/json_writer.h" #include "base/path_service.h" #include "base/strings/stringprintf.h" -#include "base/strings/utf_string_conversions.h" #include "build/build_config.h" -#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/shell/browser/layout_test/blink_test_controller.h" #include "content/shell/browser/shell.h" @@ -71,34 +67,13 @@ void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings, const std::string frontend_url) { DisconnectFromTarget(); preferences()->Clear(); - ready_for_test_ = false; - pending_evaluations_.clear(); frontend_shell()->LoadURL(GetDevToolsPathAsURL(settings, frontend_url)); } -void LayoutTestDevToolsFrontend::EvaluateInFrontend( - int call_id, - const std::string& script) { - if (!ready_for_test_) { - pending_evaluations_.push_back(std::make_pair(call_id, script)); - return; - } - - std::string encoded_script; - base::JSONWriter::Write(base::StringValue(script), &encoded_script); - std::string source = - base::StringPrintf("DevToolsAPI.evaluateForTestInFrontend(%d, %s);", - call_id, - encoded_script.c_str()); - web_contents()->GetMainFrame()->ExecuteJavaScriptForTests( - base::UTF8ToUTF16(source)); -} - LayoutTestDevToolsFrontend::LayoutTestDevToolsFrontend( Shell* frontend_shell, WebContents* inspected_contents) - : ShellDevToolsFrontend(frontend_shell, inspected_contents), - ready_for_test_(false) { + : ShellDevToolsFrontend(frontend_shell, inspected_contents) { } LayoutTestDevToolsFrontend::~LayoutTestDevToolsFrontend() { @@ -109,25 +84,6 @@ void LayoutTestDevToolsFrontend::AgentHostClosed( // Do not close the front-end shell. } -void LayoutTestDevToolsFrontend::HandleMessageFromDevToolsFrontend( - const std::string& message) { - std::string method; - base::DictionaryValue* dict = nullptr; - scoped_ptr<base::Value> parsed_message = base::JSONReader::Read(message); - if (parsed_message && - parsed_message->GetAsDictionary(&dict) && - dict->GetString("method", &method) && - method == "readyForTest") { - ready_for_test_ = true; - for (const auto& pair : pending_evaluations_) - EvaluateInFrontend(pair.first, pair.second); - pending_evaluations_.clear(); - return; - } - - ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend(message); -} - void LayoutTestDevToolsFrontend::RenderProcessGone( base::TerminationStatus status) { BlinkTestController::Get()->DevToolsProcessCrashed(); diff --git a/content/shell/browser/layout_test/layout_test_devtools_frontend.h b/content/shell/browser/layout_test/layout_test_devtools_frontend.h index 839a9a5..db2dc41 100644 --- a/content/shell/browser/layout_test/layout_test_devtools_frontend.h +++ b/content/shell/browser/layout_test/layout_test_devtools_frontend.h @@ -26,7 +26,6 @@ class LayoutTestDevToolsFrontend : public ShellDevToolsFrontend { void ReuseFrontend(const std::string& settings, const std::string frontend_url); - void EvaluateInFrontend(int call_id, const std::string& expression); private: LayoutTestDevToolsFrontend(Shell* frontend_shell, @@ -36,15 +35,9 @@ class LayoutTestDevToolsFrontend : public ShellDevToolsFrontend { // content::DevToolsAgentHostClient implementation. void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override; - // ShellDevToolsFrontend overrides. - void HandleMessageFromDevToolsFrontend(const std::string& message) override; - // WebContentsObserver implementation. void RenderProcessGone(base::TerminationStatus status) override; - bool ready_for_test_; - std::vector<std::pair<int, std::string>> pending_evaluations_; - DISALLOW_COPY_AND_ASSIGN(LayoutTestDevToolsFrontend); }; diff --git a/content/shell/browser/shell_devtools_frontend.h b/content/shell/browser/shell_devtools_frontend.h index 3258a5a..b1be4a6 100644 --- a/content/shell/browser/shell_devtools_frontend.h +++ b/content/shell/browser/shell_devtools_frontend.h @@ -55,7 +55,6 @@ class ShellDevToolsFrontend : public WebContentsObserver, void DispatchProtocolMessage(DevToolsAgentHost* agent_host, const std::string& message) override; base::DictionaryValue* preferences() { return &preferences_; } - virtual void HandleMessageFromDevToolsFrontend(const std::string& message); private: // WebContentsObserver overrides @@ -63,6 +62,8 @@ class ShellDevToolsFrontend : public WebContentsObserver, void DocumentAvailableInMainFrame() override; void WebContentsDestroyed() override; + void HandleMessageFromDevToolsFrontend(const std::string& message); + // net::URLFetcherDelegate overrides. void OnURLFetchComplete(const net::URLFetcher* source) override; diff --git a/content/shell/common/shell_messages.h b/content/shell/common/shell_messages.h index 0535dd3..8937138 100644 --- a/content/shell/common/shell_messages.h +++ b/content/shell/common/shell_messages.h @@ -114,9 +114,6 @@ IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ClearDevToolsLocalStorage) IPC_MESSAGE_ROUTED2(ShellViewHostMsg_ShowDevTools, std::string /* settings */, std::string /* frontend_url */) -IPC_MESSAGE_ROUTED2(ShellViewHostMsg_EvaluateInDevTools, - int /* call_id */, - std::string /* script */) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseDevTools) IPC_MESSAGE_ROUTED1(ShellViewHostMsg_GoToOffset, int /* offset */) diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc index 842caec..76f1fcc 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.cc +++ b/content/shell/renderer/layout_test/blink_test_runner.cc @@ -429,10 +429,12 @@ void BlinkTestRunner::CloseDevTools() { agent->detach(); } -void BlinkTestRunner::EvaluateInWebInspector(int call_id, +void BlinkTestRunner::EvaluateInWebInspector(long call_id, const std::string& script) { - Send(new ShellViewHostMsg_EvaluateInDevTools( - routing_id(), call_id, script)); + WebDevToolsAgent* agent = + render_view()->GetMainRenderFrame()->GetWebFrame()->devToolsAgent(); + if (agent) + agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); } std::string BlinkTestRunner::EvaluateInWebInspectorOverlay( diff --git a/content/shell/renderer/layout_test/blink_test_runner.h b/content/shell/renderer/layout_test/blink_test_runner.h index 74edc83..a919b84 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.h +++ b/content/shell/renderer/layout_test/blink_test_runner.h @@ -91,7 +91,7 @@ class BlinkTestRunner : public RenderViewObserver, void ShowDevTools(const std::string& settings, const std::string& frontend_url) override; void CloseDevTools() override; - void EvaluateInWebInspector(int call_id, const std::string& script) override; + void EvaluateInWebInspector(long call_id, const std::string& script) override; std::string EvaluateInWebInspectorOverlay(const std::string& script) override; void ClearAllDatabases() override; void SetDatabaseQuota(int quota) override; diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html index 2d1a92ae..9d14a2b 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.html @@ -137,12 +137,6 @@ InspectorTest.sendRawCommand = function(command, handler) return this._requestId; } -InspectorTest.readyForTest = function() -{ - var embedderMessage = { "id": ++this._embedderRequestId, "method": "readyForTest" }; - DevToolsHost.sendMessageToEmbedder(JSON.stringify(embedderMessage)); -} - /** * @param {string|!Object} messageOrObject */ @@ -170,20 +164,6 @@ DevToolsAPI.dispatchMessage = function(messageOrObject) } /** - * @param {number} callId - * @param {string} script - */ -DevToolsAPI.evaluateForTestInFrontend = function(callId, script) -{ - try { - eval(script); - } catch (e) { - InspectorTest.log("FAIL: exception in evaluateForTestInFrontend: " + e); - InspectorTest.completeTest(); - } -} - -/** * Logs message to document. * @param {string} message */ @@ -400,7 +380,22 @@ InspectorTest.didInvokePageFunctionPromise = function(callId, value, didResolve) callback(value); } -window.addEventListener("load", InspectorTest.readyForTest.bind(InspectorTest), false); +InspectorTest.eventHandler["Inspector.evaluateForTestInFrontend"] = function(message) +{ + try { + eval(message.params.script); + } catch (e) { + InspectorTest.log("FAIL: exception in evaluateForTestInFrontend: " + e); + InspectorTest.completeTest(); + } +}; + +function enableInspectorAgent() +{ + InspectorTest.sendCommand("Inspector.enable", { }); +} + +window.addEventListener("load", enableInspectorAgent, false); </script> </head> diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/json-parse.html b/third_party/WebKit/LayoutTests/inspector-protocol/json-parse.html index d91d9b9c..aebf020 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/json-parse.html +++ b/third_party/WebKit/LayoutTests/inspector-protocol/json-parse.html @@ -11,7 +11,6 @@ function test() function step2(msg) { - msg.id = 1; InspectorTest.logObject(msg); InspectorTest.completeTest(); } diff --git a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp index e88b11b..c5e0a62 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp @@ -57,11 +57,33 @@ InspectorInspectorAgent::~InspectorInspectorAgent() void InspectorInspectorAgent::enable(ErrorString*) { m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, true); + for (Vector<std::pair<long, String>>::iterator it = m_pendingEvaluateTestCommands.begin(); frontend() && it != m_pendingEvaluateTestCommands.end(); ++it) + frontend()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second); + m_pendingEvaluateTestCommands.clear(); } void InspectorInspectorAgent::disable(ErrorString*) { m_state->setBoolean(InspectorAgentState::inspectorAgentEnabled, false); + m_pendingEvaluateTestCommands.clear(); +} + +void InspectorInspectorAgent::restore() +{ + if (m_state->booleanProperty(InspectorAgentState::inspectorAgentEnabled, false)) { + ErrorString error; + enable(&error); + } +} + +void InspectorInspectorAgent::evaluateForTestInFrontend(long callId, const String& script) +{ + if (m_state->booleanProperty(InspectorAgentState::inspectorAgentEnabled, false)) { + frontend()->evaluateForTestInFrontend(static_cast<int>(callId), script); + frontend()->flush(); + } else { + m_pendingEvaluateTestCommands.append(std::pair<long, String>(callId, script)); + } } void InspectorInspectorAgent::inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassOwnPtr<protocol::DictionaryValue> hints) diff --git a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h index ba8fc69..41e6012 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h @@ -37,6 +37,8 @@ namespace blink { +class LocalFrame; + namespace protocol { class DictionaryValue; } @@ -53,12 +55,20 @@ public: // Inspector front-end API. void enable(ErrorString*) override; + + // InspectorAgent overrides. void disable(ErrorString*) override; + void restore() override; + + // Generic code called from custom implementations. + void evaluateForTestInFrontend(long testCallId, const String& script); void inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassOwnPtr<protocol::DictionaryValue> hints); private: InspectorInspectorAgent(); + + Vector<std::pair<long, String>> m_pendingEvaluateTestCommands; }; } // namespace blink diff --git a/third_party/WebKit/Source/devtools/front_end/devtools.js b/third_party/WebKit/Source/devtools/front_end/devtools.js index 84325f7..e98419d 100644 --- a/third_party/WebKit/Source/devtools/front_end/devtools.js +++ b/third_party/WebKit/Source/devtools/front_end/devtools.js @@ -161,15 +161,6 @@ DevToolsAPIImpl.prototype = { }, /** - * @param {number} callId - * @param {string} script - */ - evaluateForTestInFrontend: function(callId, script) - { - this._dispatchOnInspectorFrontendAPI("evaluateForTestInFrontend", [callId, script]); - }, - - /** * @param {!Array.<!{fileSystemName: string, rootURL: string, fileSystemPath: string}>} fileSystems */ fileSystemsLoaded: function(fileSystems) diff --git a/third_party/WebKit/Source/devtools/front_end/host/InspectorFrontendHostAPI.js b/third_party/WebKit/Source/devtools/front_end/host/InspectorFrontendHostAPI.js index 98f2717..79bfed4 100644 --- a/third_party/WebKit/Source/devtools/front_end/host/InspectorFrontendHostAPI.js +++ b/third_party/WebKit/Source/devtools/front_end/host/InspectorFrontendHostAPI.js @@ -39,7 +39,6 @@ InspectorFrontendHostAPI.Events = { DispatchMessage: "dispatchMessage", DispatchMessageChunk: "dispatchMessageChunk", EnterInspectElementMode: "enterInspectElementMode", - EvaluateForTestInFrontend: "evaluateForTestInFrontend", FileSystemsLoaded: "fileSystemsLoaded", FileSystemRemoved: "fileSystemRemoved", FileSystemAdded: "fileSystemAdded", @@ -70,7 +69,6 @@ InspectorFrontendHostAPI.EventDescriptors = [ [InspectorFrontendHostAPI.Events.DispatchMessage, ["messageObject"]], [InspectorFrontendHostAPI.Events.DispatchMessageChunk, ["messageChunk", "messageSize"]], [InspectorFrontendHostAPI.Events.EnterInspectElementMode, []], - [InspectorFrontendHostAPI.Events.EvaluateForTestInFrontend, ["callId", "script"]], [InspectorFrontendHostAPI.Events.FileSystemsLoaded, ["fileSystems"]], [InspectorFrontendHostAPI.Events.FileSystemRemoved, ["fileSystemPath"]], [InspectorFrontendHostAPI.Events.FileSystemAdded, ["errorMessage", "fileSystem"]], diff --git a/third_party/WebKit/Source/devtools/front_end/main/Main.js b/third_party/WebKit/Source/devtools/front_end/main/Main.js index b67f01d..d7953f7 100644 --- a/third_party/WebKit/Source/devtools/front_end/main/Main.js +++ b/third_party/WebKit/Source/devtools/front_end/main/Main.js @@ -318,20 +318,22 @@ WebInspector.Main.prototype = { this._mainTarget.registerInspectorDispatcher(this); InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.ReloadInspectedPage, this._reloadInspectedPage, this); - InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.EvaluateForTestInFrontend, this._evaluateForTestInFrontend, this); if (this._mainTarget.isServiceWorker() || this._mainTarget.isPage()) this._mainTarget.runtimeAgent().run(); - this._mainTarget.inspectorAgent().enable(); - InspectorFrontendHost.readyForTest(); + this._mainTarget.inspectorAgent().enable(inspectorAgentEnableCallback); - // Asynchronously run the extensions. - setTimeout(lateInitialization, 0); + function inspectorAgentEnableCallback() + { + console.timeStamp("Main.inspectorAgentEnableCallback"); + InspectorFrontendHost.readyForTest(); + // Asynchronously run the extensions. + setTimeout(lateInitialization, 0); + } function lateInitialization() { - console.timeStamp("Main.lateInitialization"); WebInspector.extensionServer.initializeExtensions(); } }, @@ -609,16 +611,15 @@ WebInspector.Main.prototype = { }, /** - * @param {!WebInspector.Event} event + * @override + * @param {number} callId + * @param {string} script */ - _evaluateForTestInFrontend: function(event) + evaluateForTestInFrontend: function(callId, script) { if (!InspectorFrontendHost.isUnderTest()) return; - var callId = /** @type {number} */ (event.data["callId"]); - var script = /** @type {number} */ (event.data["script"]); - /** * @suppressGlobalPropertiesCheck */ diff --git a/third_party/WebKit/Source/devtools/protocol.json b/third_party/WebKit/Source/devtools/protocol.json index 9462985..7fafc54 100644 --- a/third_party/WebKit/Source/devtools/protocol.json +++ b/third_party/WebKit/Source/devtools/protocol.json @@ -17,6 +17,13 @@ ], "events": [ { + "name": "evaluateForTestInFrontend", + "parameters": [ + { "name": "testCallId", "type": "integer" }, + { "name": "script", "type": "string" } + ] + }, + { "name": "inspect", "parameters": [ { "name": "object", "$ref": "Runtime.RemoteObject" }, diff --git a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp index 6ed085e..31c776e 100644 --- a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp +++ b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp @@ -676,6 +676,11 @@ void WebDevToolsAgentImpl::waitForCreateWindow(LocalFrame* frame) ClientMessageLoopAdapter::pauseForCreateWindow(m_webLocalFrameImpl); } +void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString& script) +{ + m_inspectorAgent->evaluateForTestInFrontend(callId, script); +} + WebString WebDevToolsAgentImpl::evaluateInWebInspectorOverlay(const WebString& script) { if (!m_overlay) diff --git a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h index 75adf6e..c0bded7 100644 --- a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h +++ b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h @@ -110,6 +110,7 @@ public: void dispatchOnInspectorBackend(int sessionId, const WebString& message) override; void inspectElementAt(const WebPoint&) override; void failedToRequestDevTools() override; + void evaluateInWebInspector(long callId, const WebString& script) override; WebString evaluateInWebInspectorOverlay(const WebString& script) override; private: diff --git a/third_party/WebKit/public/web/WebDevToolsAgent.h b/third_party/WebKit/public/web/WebDevToolsAgent.h index 4a6019e..8cba0af 100644 --- a/third_party/WebKit/public/web/WebDevToolsAgent.h +++ b/third_party/WebKit/public/web/WebDevToolsAgent.h @@ -55,6 +55,7 @@ public: virtual void failedToRequestDevTools() = 0; // Exposed for TestRunner. + virtual void evaluateInWebInspector(long callId, const WebString& script) = 0; virtual WebString evaluateInWebInspectorOverlay(const WebString& script) = 0; class MessageDescriptor { |