| 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 82f3eab110072e7ee9d4c58779053f68c46a49e9..ae3cc9208f9156257c983b760a868ad4f19a73c2 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"
|
| @@ -131,3 +132,76 @@ IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, RemovedFrames) {
|
| ASSERT_TRUE(StartEmbeddedTestServer());
|
| ASSERT_TRUE(RunExtensionTest("executescript/removed_frames")) << message_;
|
| }
|
| +
|
| +const int kNumberOfDestructiveScriptTests = 12;
|
| +
|
| +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 +
|
| + "#instance=" + base::IntToString(GetParam()) +
|
| + "&count=" + base::IntToString(kNumberOfDestructiveScriptTests));
|
| + }
|
| +};
|
| +
|
| +// 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, kNumberOfDestructiveScriptTests));
|
|
|