| 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));
|
|
|