Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/extensions/extension_apitest.h"
      6 #include "chrome/browser/extensions/extension_service.h"
      7 #include "chrome/common/extensions/extension.h"
      8 #include "chrome/test/ui_test_utils.h"
      9 #include "net/base/mock_host_resolver.h"
     10 
     11 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptAllFrames) {
     12   ASSERT_TRUE(StartTestServer());
     13   ASSERT_TRUE(RunExtensionTest("content_scripts/all_frames")) << message_;
     14 }
     15 
     16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionIframe) {
     17   ASSERT_TRUE(StartTestServer());
     18   ASSERT_TRUE(RunExtensionTest("content_scripts/extension_iframe")) << message_;
     19 }
     20 
     21 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptExtensionProcess) {
     22   ASSERT_TRUE(StartTestServer());
     23   ASSERT_TRUE(
     24       RunExtensionTest("content_scripts/extension_process")) << message_;
     25 }
     26 
     27 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptFragmentNavigation) {
     28   ASSERT_TRUE(StartTestServer());
     29   const char* extension_name = "content_scripts/fragment";
     30   ASSERT_TRUE(RunExtensionTest(extension_name)) << message_;
     31 }
     32 
     33 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptIsolatedWorlds) {
     34   // This extension runs various bits of script and tests that they all run in
     35   // the same isolated world.
     36   ASSERT_TRUE(StartTestServer());
     37   ASSERT_TRUE(RunExtensionTest("content_scripts/isolated_world1")) << message_;
     38 
     39   // Now load a different extension, inject into same page, verify worlds aren't
     40   // shared.
     41   ASSERT_TRUE(RunExtensionTest("content_scripts/isolated_world2")) << message_;
     42 }
     43 
     44 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentScriptIgnoreHostPermissions) {
     45   ASSERT_TRUE(StartTestServer());
     46   host_resolver()->AddRule("a.com", "127.0.0.1");
     47   host_resolver()->AddRule("b.com", "127.0.0.1");
     48   ASSERT_TRUE(RunExtensionTest(
     49       "content_scripts/dont_match_host_permissions")) << message_;
     50 }
     51