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

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/TestExpectations » ('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..1e4fba8da8eb9fde8bf8bfca5e89e055ef47f520 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,56 @@ 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* object_id;
+ ASSERT_TRUE(root->Get("result.result.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"));
+}
+
} // namespace content
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698