Chromium Code Reviews| 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..66153186667393bb2e6e53ded5dc90dcb4cb7c9a 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,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)); |
|
Devlin
2016/03/15 00:53:31
This effectively adds 108 more browser tests. Tha
|