Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2398)

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1932343002: [DevTools] Don't run microtasks after call to InjectedScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-doesnt-step-into-injected-script.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index e66c4c3075bfea7a57b44d3c07ff9f6012e0a47b..08590a4a51e6ca55443ca232d397ef422f91cf72 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/json/json_reader.h"
+#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
@@ -407,6 +408,7 @@ class DevToolsAgentTest : public RenderViewImplTest {
void OnDevToolsMessage(
int, int, const std::string& message, const std::string&) {
+ last_received_message_ = message;
std::unique_ptr<base::DictionaryValue> root(
static_cast<base::DictionaryValue*>(
base::JSONReader::Read(message).release()));
@@ -427,12 +429,15 @@ class DevToolsAgentTest : public RenderViewImplTest {
return result;
}
+ std::string LastReceivedMessage() const { return last_received_message_; }
+
private:
DevToolsAgent* agent() {
return frame()->devtools_agent();
}
std::vector<std::string> notifications_;
+ std::string last_received_message_;
};
class RenderViewImplBlinkSettingsTest : public RenderViewImplTest {
@@ -2404,4 +2409,64 @@ TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) {
EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated"));
}
+TEST_F(DevToolsAgentTest, RuntimeEvaluateRunMicrotasks) {
+ LoadHTML("<body>page</body>");
+ Attach();
+ DispatchDevToolsMessage("Console.enable",
+ "{\"id\":1,\"method\":\"Console.enable\"}");
+ DispatchDevToolsMessage("Runtime.evaluate",
+ "{\"id\":2,"
+ "\"method\":\"Runtime.evaluate\","
+ "\"params\":{"
+ "\"expression\":\"Promise.resolve().then("
+ "() => console.log(42));\""
+ "}"
+ "}");
+ EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
+}
+
+TEST_F(DevToolsAgentTest, RuntimeCallFunctionOnRunMicrotasks) {
+ LoadHTML("<body>page</body>");
+ Attach();
+ DispatchDevToolsMessage("Console.enable",
+ "{\"id\":1,\"method\":\"Console.enable\"}");
+ DispatchDevToolsMessage("Runtime.evaluate",
+ "{\"id\":2,"
+ "\"method\":\"Runtime.evaluate\","
+ "\"params\":{"
+ "\"expression\":\"window\""
+ "}"
+ "}");
+
+ std::unique_ptr<base::DictionaryValue> root(
+ static_cast<base::DictionaryValue*>(
+ base::JSONReader::Read(LastReceivedMessage()).release()));
+ const base::Value* result;
+ EXPECT_TRUE(static_cast<const base::DictionaryValue*>(root.get())
dgozman 2016/04/30 02:26:07 No need to cast.
kozy 2016/04/30 03:08:30 Done.
+ ->Get("result", &result));
+ const base::Value* object;
+ EXPECT_TRUE(static_cast<const base::DictionaryValue*>(result)->Get("result",
+ &object));
+ const base::Value* object_id;
+ EXPECT_TRUE(static_cast<const base::DictionaryValue*>(object)->Get(
dgozman 2016/04/30 02:26:06 std::string object_id; root->GetStringASCII("resul
kozy 2016/04/30 03:08:30 Done.
+ "objectId", &object_id));
+
+ std::string object_id_str;
+ EXPECT_TRUE(base::JSONWriter::Write(*object_id, &object_id_str));
+
+ DispatchDevToolsMessage("Runtime.callFunctionOn",
+ "{\"id\":3,"
+ "\"method\":\"Runtime.callFunctionOn\","
+ "\"params\":{"
+ "\"objectId\":" +
+ object_id_str +
+ ","
+ "\"functionDeclaration\":\"function foo(){ "
+ "Promise.resolve().then(() => "
+ "console.log(239))}\""
+ "}"
+ "}");
+ EXPECT_EQ(1, CountNotifications("Console.messageAdded"));
dgozman 2016/04/30 02:26:07 Could we also add test for "Runtime.getProperties"
kozy 2016/04/30 03:08:30 I'll add a test for this in follow up.
+}
+
} // namespace content
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-doesnt-step-into-injected-script.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698