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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1940783002: [DevTools] Don't run microtasks after call to InjectedScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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 8d7a40af8ff3f281dcd314d2e372253783165953..c4c10b66c8421edc45c80c0076b1ba5c010c2c93 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"
@@ -405,8 +406,10 @@ class DevToolsAgentTest : public RenderViewImplTest {
void OnDevToolsMessage(
int, int, const std::string& message, const std::string&) {
- scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>(
- base::JSONReader::Read(message).release()));
+ last_received_message_ = message;
+ std::unique_ptr<base::DictionaryValue> root(
+ static_cast<base::DictionaryValue*>(
+ base::JSONReader::Read(message).release()));
int id;
if (!root->GetInteger("id", &id)) {
std::string notification;
@@ -424,12 +427,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 {
@@ -2398,4 +2404,51 @@ TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) {
EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated"));
}
+TEST_F(DevToolsAgentTest, RuntimeEvaluateRunMicrotasks) {
+ LoadHTML("<body>page</body>");
+ Attach();
+ DispatchDevToolsMessage("{\"id\":1,\"method\":\"Console.enable\"}");
+ DispatchDevToolsMessage("{\"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("{\"id\":1,\"method\":\"Console.enable\"}");
+ DispatchDevToolsMessage("{\"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("{\"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