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

Unified Diff: chrome/browser/extensions/execute_script_apitest.cc

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last nits Created 4 years, 9 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 | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/execute_script_apitest.cc
diff --git a/chrome/browser/extensions/execute_script_apitest.cc b/chrome/browser/extensions/execute_script_apitest.cc
index 7f81895c3c6d752de7c9b9e6df324df5f73bad1e..91d19df97fe59da073fe406e85636b462e99fd6d 100644
--- a/chrome/browser/extensions/execute_script_apitest.cc
+++ b/chrome/browser/extensions/execute_script_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "net/dns/mock_host_resolver.h"
@@ -137,3 +138,80 @@ IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, RemovedFrames) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("executescript/removed_frames")) << message_;
}
+
+// If tests time out because it takes too long to run them, then this value can
+// be increased to split the DestructiveScriptTest tests in approximately equal
+// parts. Each part takes approximately the same time to run.
+const int kDestructiveScriptTestBucketCount = 1;
+
+class DestructiveScriptTest : public ExecuteScriptApiTest,
+ public testing::WithParamInterface<int> {
+ protected:
+ // The test extension selects the sub test based on the host name.
+ bool RunSubtest(const std::string& test_host) {
+ host_resolver()->AddRule(test_host, "127.0.0.1");
+ return RunExtensionSubtest(
+ "executescript/destructive",
+ "test.html?" + test_host +
+ "#bucketcount=" + base::IntToString(kDestructiveScriptTestBucketCount) +
+ "&bucketindex=" + base::IntToString(GetParam()));
+ }
+};
+
+// Removes the frame as soon as the content script is executed.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, SynchronousRemoval) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("synchronous")) << message_;
+}
+
+// Removes the frame at the frame's first scheduled microtask.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, MicrotaskRemoval) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("microtask")) << message_;
+}
+
+// Removes the frame at the frame's first scheduled macrotask.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, MacrotaskRemoval) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("macrotask")) << message_;
+}
+
+// Removes the frame at the first DOMNodeInserted event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMNodeInserted1) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domnodeinserted1")) << message_;
+}
+
+// Removes the frame at the second DOMNodeInserted event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMNodeInserted2) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domnodeinserted2")) << message_;
+}
+
+// Removes the frame at the third DOMNodeInserted event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMNodeInserted3) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domnodeinserted3")) << message_;
+}
+
+// Removes the frame at the first DOMSubtreeModified event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMSubtreeModified1) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domsubtreemodified1")) << message_;
+}
+
+// Removes the frame at the second DOMSubtreeModified event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMSubtreeModified2) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domsubtreemodified2")) << message_;
+}
+
+// Removes the frame at the third DOMSubtreeModified event.
+IN_PROC_BROWSER_TEST_P(DestructiveScriptTest, DOMSubtreeModified3) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ ASSERT_TRUE(RunSubtest("domsubtreemodified3")) << message_;
+}
+
+INSTANTIATE_TEST_CASE_P(ExecuteScriptApiTest,
+ DestructiveScriptTest,
+ ::testing::Range(0, kDestructiveScriptTestBucketCount));
« no previous file with comments | « no previous file | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698