diff options
author | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-10 21:08:08 +0000 |
---|---|---|
committer | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-10 21:08:08 +0000 |
commit | 24e042983baecad0fde78b5b1c5ab3fd5c942b3f (patch) | |
tree | db538c975edde1064067dc427e3902b0a3657cb8 | |
parent | e841144ed0e8cfc957e01d82ced610ac1e624645 (diff) | |
download | chromium_src-24e042983baecad0fde78b5b1c5ab3fd5c942b3f.zip chromium_src-24e042983baecad0fde78b5b1c5ab3fd5c942b3f.tar.gz chromium_src-24e042983baecad0fde78b5b1c5ab3fd5c942b3f.tar.bz2 |
Check for warnings when loading extensions in browser tests.
Test extension should be well-formed. Having warnings is often an early
indicator that something else is wrong (see for example https://chromiumcodereview.appspot.com/10852016/).
Review URL: https://chromiumcodereview.appspot.com/10826157
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151123 0039d316-1c4b-4281-b951-d872f2087c98
108 files changed, 604 insertions, 473 deletions
diff --git a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc index 1b7d599..b6f1cc6 100644 --- a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc @@ -145,7 +145,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionRemovePopup) { // Tests old-style pageActions API that is deprecated but we don't want to // break. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, OldPageActions) { - ASSERT_TRUE(RunExtensionTest("page_action/old_api")) << message_; + ASSERT_TRUE(RunExtensionTestIgnoreManifestWarnings("page_action/old_api")) << + message_; const Extension* extension = GetSingleLoadedExtension(); ASSERT_TRUE(extension) << message_; diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc index 4b0fcef..87e7f83 100644 --- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc @@ -158,11 +158,13 @@ void ExtensionWebRequestApiTest::RunPermissionTest( ExtensionTestMessageListener listener("done", true); ExtensionTestMessageListener listener_incognito("done_incognito", true); - ASSERT_TRUE(LoadExtensionWithOptions( + int load_extension_flags = kFlagNone; + if (load_extension_with_incognito_permission) + load_extension_flags |= kFlagEnableIncognito; + ASSERT_TRUE(LoadExtensionWithFlags( test_data_dir_.AppendASCII("webrequest_permissions") .AppendASCII(extension_directory), - load_extension_with_incognito_permission, - false)); + load_extension_flags)); // Test that navigation in regular window is properly redirected. EXPECT_TRUE(listener.WaitUntilSatisfied()); diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc index cf2821f..86a048a 100644 --- a/chrome/browser/extensions/extension_apitest.cc +++ b/chrome/browser/extensions/extension_apitest.cc @@ -121,6 +121,12 @@ bool ExtensionApiTest::RunExtensionTestIncognito(const char* extension_name) { extension_name, "", kFlagEnableIncognito | kFlagEnableFileAccess); } +bool ExtensionApiTest::RunExtensionTestIgnoreManifestWarnings( + const char* extension_name) { + return RunExtensionTestImpl( + extension_name, "", kFlagEnableFileAccess | kFlagIgnoreManifestWarnings); +} + bool ExtensionApiTest::RunComponentExtensionTest(const char* extension_name) { return RunExtensionTestImpl( extension_name, "", kFlagEnableFileAccess | kFlagLoadAsComponent); @@ -167,8 +173,6 @@ bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, const std::string& page_url, int flags) { - bool enable_incognito = (flags & kFlagEnableIncognito) != 0; - bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; bool load_as_component = (flags & kFlagLoadAsComponent) != 0; bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0; bool use_incognito = (flags & kFlagUseIncognito) != 0; @@ -183,8 +187,14 @@ bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, if (load_as_component) { extension = LoadExtensionAsComponent(extension_path); } else { - extension = LoadExtensionWithOptions(extension_path, - enable_incognito, enable_fileaccess); + int browser_test_flags = ExtensionBrowserTest::kFlagNone; + if (flags & kFlagEnableIncognito) + browser_test_flags |= ExtensionBrowserTest::kFlagEnableIncognito; + if (flags & kFlagEnableFileAccess) + browser_test_flags |= ExtensionBrowserTest::kFlagEnableFileAccess; + if (flags & kFlagIgnoreManifestWarnings) + browser_test_flags |= ExtensionBrowserTest::kFlagIgnoreManifestWarnings; + extension = LoadExtensionWithFlags(extension_path, browser_test_flags); } if (!extension) { message_ = "Failed to load extension."; diff --git a/chrome/browser/extensions/extension_apitest.h b/chrome/browser/extensions/extension_apitest.h index 9d3277a..b5f7e3e 100644 --- a/chrome/browser/extensions/extension_apitest.h +++ b/chrome/browser/extensions/extension_apitest.h @@ -52,7 +52,11 @@ class ExtensionApiTest : public ExtensionBrowserTest { kFlagLoadAsComponent = 1 << 3, // Launch the extension as a platform app. - kFlagLaunchPlatformApp = 1 << 4 + kFlagLaunchPlatformApp = 1 << 4, + + // Don't fail when the loaded manifest has warnings (should only be used + // when testing deprecated features). + kFlagIgnoreManifestWarnings = 1 << 5 }; ExtensionApiTest(); @@ -109,6 +113,9 @@ class ExtensionApiTest : public ExtensionBrowserTest { // Same as RunExtensionTest, but enables the extension for incognito mode. bool RunExtensionTestIncognito(const char* extension_name); + // Same as RunExtensionTest, but ignores any warnings in the manifest. + bool RunExtensionTestIgnoreManifestWarnings(const char* extension_name); + // Same as RunExtensionTest, but loads extension as component. bool RunComponentExtensionTest(const char* extension_name); diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 31f0682..efdbd0fb 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -71,8 +71,8 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { #endif } -const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( - const FilePath& path, bool incognito_enabled, bool fileaccess_enabled) { +const Extension* ExtensionBrowserTest::LoadExtensionWithFlags( + const FilePath& path, int flags) { ExtensionService* service = browser()->profile()->GetExtensionService(); { content::NotificationRegistrar registrar; @@ -100,6 +100,25 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( if (!extension) return NULL; + if (!(flags & kFlagIgnoreManifestWarnings)) { + const Extension::InstallWarningVector& install_warnings = + extension->install_warnings(); + if (!install_warnings.empty()) { + std::string install_warnings_message = StringPrintf( + "Unexpected warnings when loading test extension %s:\n", + path.AsUTF8Unsafe().c_str()); + + for (Extension::InstallWarningVector::const_iterator it = + install_warnings.begin(); it != install_warnings.end(); ++it) { + install_warnings_message += " " + it->message + "\n"; + } + + EXPECT_TRUE(extension->install_warnings().empty()) << + install_warnings_message; + return NULL; + } + } + const std::string extension_id = extension->id(); // The call to OnExtensionInstalled ensures the other extension prefs @@ -118,8 +137,8 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( content::Source<Profile>(browser()->profile())); CHECK(!service->IsIncognitoEnabled(extension_id)); - if (incognito_enabled) { - service->SetIsIncognitoEnabled(extension_id, incognito_enabled); + if (flags & kFlagEnableIncognito) { + service->SetIsIncognitoEnabled(extension_id, true); load_signal.Wait(); extension = service->GetExtensionById(extension_id, false); CHECK(extension) << extension_id << " not found after reloading."; @@ -131,8 +150,8 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( chrome::NOTIFICATION_EXTENSION_LOADED, content::Source<Profile>(browser()->profile())); CHECK(service->AllowFileAccess(extension)); - if (!fileaccess_enabled) { - service->SetAllowFileAccess(extension, fileaccess_enabled); + if (!(flags & kFlagEnableFileAccess)) { + service->SetAllowFileAccess(extension, false); load_signal.Wait(); extension = service->GetExtensionById(extension_id, false); CHECK(extension) << extension_id << " not found after reloading."; @@ -146,12 +165,13 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithOptions( } const Extension* ExtensionBrowserTest::LoadExtension(const FilePath& path) { - return LoadExtensionWithOptions(path, false, true); + return LoadExtensionWithFlags(path, kFlagEnableFileAccess); } const Extension* ExtensionBrowserTest::LoadExtensionIncognito( const FilePath& path) { - return LoadExtensionWithOptions(path, true, true); + return LoadExtensionWithFlags(path, + kFlagEnableFileAccess | kFlagEnableIncognito); } const Extension* ExtensionBrowserTest::LoadExtensionAsComponent( diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h index 1522f73..ffda8b9 100644 --- a/chrome/browser/extensions/extension_browsertest.h +++ b/chrome/browser/extensions/extension_browsertest.h @@ -24,6 +24,21 @@ class ExtensionBrowserTest : virtual public InProcessBrowserTest, public content::NotificationObserver { protected: + // Flags used to configure how the tests are run. + enum Flags { + kFlagNone = 0, + + // Allow the extension to run in incognito mode. + kFlagEnableIncognito = 1 << 0, + + // Allow file access for the extension. + kFlagEnableFileAccess = 1 << 1, + + // Don't fail when the loaded manifest has warnings (should only be used + // when testing deprecated features). + kFlagIgnoreManifestWarnings = 1 << 2 + }; + ExtensionBrowserTest(); virtual ~ExtensionBrowserTest(); @@ -35,10 +50,8 @@ class ExtensionBrowserTest : virtual public InProcessBrowserTest, // Same as above, but enables the extension in incognito mode first. const extensions::Extension* LoadExtensionIncognito(const FilePath& path); - const extensions::Extension* LoadExtensionWithOptions( - const FilePath& path, - bool incognito_enabled, - bool fileaccess_enabled); + const extensions::Extension* LoadExtensionWithFlags( + const FilePath& path, int flags); // Loads extension and imitates that it is a component extension. const extensions::Extension* LoadExtensionAsComponent(const FilePath& path); diff --git a/chrome/browser/extensions/extension_resource_request_policy_apitest.cc b/chrome/browser/extensions/extension_resource_request_policy_apitest.cc index 37d78cf..fe6eb22 100644 --- a/chrome/browser/extensions/extension_resource_request_policy_apitest.cc +++ b/chrome/browser/extensions/extension_resource_request_policy_apitest.cc @@ -27,9 +27,11 @@ class ExtensionResourceRequestPolicyTest : public ExtensionApiTest { IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, OriginPrivileges) { host_resolver()->AddRule("*", "127.0.0.1"); ASSERT_TRUE(test_server()->Start()); - ASSERT_TRUE(LoadExtension(test_data_dir_ + ASSERT_TRUE(LoadExtensionWithFlags(test_data_dir_ .AppendASCII("extension_resource_request_policy") - .AppendASCII("extension"))); + .AppendASCII("extension"), + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionBrowserTest::kFlagIgnoreManifestWarnings)); GURL web_resource( test_server()->GetURL( @@ -82,9 +84,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, OriginPrivileges) { // A different extension. Legacy (manifest_version 1) extensions should always // be able to load each other's resources. - ASSERT_TRUE(LoadExtension(test_data_dir_ + ASSERT_TRUE(LoadExtensionWithFlags(test_data_dir_ .AppendASCII("extension_resource_request_policy") - .AppendASCII("extension2"))); + .AppendASCII("extension2"), + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionBrowserTest::kFlagIgnoreManifestWarnings)); ui_test_utils::NavigateToURL( browser(), GURL("chrome-extension://pbkkcbgdkliohhfaeefcijaghglkahja/index.html")); @@ -97,19 +101,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, OriginPrivileges) { IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, ExtensionCanLoadHostedAppIcons) { - ASSERT_TRUE(LoadExtension(test_data_dir_ + ASSERT_TRUE(LoadExtensionWithFlags(test_data_dir_ .AppendASCII("extension_resource_request_policy") - .AppendASCII("extension"))); + .AppendASCII("extension"), + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionBrowserTest::kFlagIgnoreManifestWarnings)); ASSERT_TRUE(RunExtensionSubtest( "extension_resource_request_policy/extension2/", - "can_load_icons_from_hosted_apps.html")); + "can_load_icons_from_hosted_apps.html", + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionApiTest::kFlagIgnoreManifestWarnings)) << message_; } IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Audio) { EXPECT_TRUE(RunExtensionSubtest( "extension_resource_request_policy/extension2", - "audio.html")); + "audio.html", + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionApiTest::kFlagIgnoreManifestWarnings)) << message_; } #if defined(OS_MACOSX) @@ -122,7 +132,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Audio) { IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, MAYBE_Video) { EXPECT_TRUE(RunExtensionSubtest( "extension_resource_request_policy/extension2", - "video.html")); + "video.html", + // Tests manifest_version 1 behavior, so warnings are expected. + ExtensionApiTest::kFlagIgnoreManifestWarnings)) << message_; } // This test times out regularly on win_rel trybots. See http://crbug.com/122154 @@ -250,7 +262,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionResourceRequestPolicyTest, Iframe) { .AppendASCII("inaccessible"))); EXPECT_TRUE(RunExtensionSubtest( "extension_resource_request_policy/web_accessible", - "iframe.html")); + "iframe.html")) << message_; } #if defined(OS_MACOSX) diff --git a/chrome/test/data/extensions/api_test/accessibility/get_alerts_for_tab/manifest.json b/chrome/test/data/extensions/api_test/accessibility/get_alerts_for_tab/manifest.json index 942f28e..4f86865 100644 --- a/chrome/test/data/extensions/api_test/accessibility/get_alerts_for_tab/manifest.json +++ b/chrome/test/data/extensions/api_test/accessibility/get_alerts_for_tab/manifest.json @@ -1,6 +1,7 @@ { "name": "chrome.experimental.accessibility", "version": "0.1", + "manifest_version": 2, "description": "browser test for chrome.experimental.accessibility.getAlertsForTab API", "background": { "scripts": ["background.js"] diff --git a/chrome/test/data/extensions/api_test/canvas_2d/background.html b/chrome/test/data/extensions/api_test/canvas_2d/background.html index be073ba..73fdb18 100644 --- a/chrome/test/data/extensions/api_test/canvas_2d/background.html +++ b/chrome/test/data/extensions/api_test/canvas_2d/background.html @@ -10,24 +10,6 @@ <body> <div>Below should be a canvas rendered with canvas2D</div> <canvas id="my-canvas" width="100" height="100"></canvas> - <script type="application/javascript"> - canvas = document.getElementById("my-canvas"); - if (canvas) { - if (canvas.getContext) { - context = canvas.getContext("2d"); - if (context) { - context.fillStyle = 'red'; - context.fillRect(20, 20, 40, 40); - chrome.test.notifyPass(); - } else { - chrome.test.notifyFail("unable to getContext('2d')"); - } - } else { - chrome.test.notifyFail("canvas.getContext null"); - } - } else { - chrome.test.notifyFail("couldn't find element my-canvas"); - } - </script> + <script src="background.js"></script> </body> </html> diff --git a/chrome/test/data/extensions/api_test/canvas_2d/background.js b/chrome/test/data/extensions/api_test/canvas_2d/background.js new file mode 100644 index 0000000..19bbbe6 --- /dev/null +++ b/chrome/test/data/extensions/api_test/canvas_2d/background.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +canvas = document.getElementById("my-canvas"); +if (canvas) { + if (canvas.getContext) { + context = canvas.getContext("2d"); + if (context) { + context.fillStyle = 'red'; + context.fillRect(20, 20, 40, 40); + chrome.test.notifyPass(); + } else { + chrome.test.notifyFail("unable to getContext('2d')"); + } + } else { + chrome.test.notifyFail("canvas.getContext null"); + } +} else { + chrome.test.notifyFail("couldn't find element my-canvas"); +} diff --git a/chrome/test/data/extensions/api_test/canvas_2d/manifest.json b/chrome/test/data/extensions/api_test/canvas_2d/manifest.json index 5001c21..d2a8282 100644 --- a/chrome/test/data/extensions/api_test/canvas_2d/manifest.json +++ b/chrome/test/data/extensions/api_test/canvas_2d/manifest.json @@ -4,5 +4,6 @@ "background": { "page": "background.html" }, - "version": "0.1" + "version": "0.1", + "manifest_version": 2 } diff --git a/chrome/test/data/extensions/api_test/extension_resource_request_policy/extension2/can_load_icons_from_hosted_apps.html b/chrome/test/data/extensions/api_test/extension_resource_request_policy/extension2/can_load_icons_from_hosted_apps.html index 096d66f..5504375 100644 --- a/chrome/test/data/extensions/api_test/extension_resource_request_policy/extension2/can_load_icons_from_hosted_apps.html +++ b/chrome/test/data/extensions/api_test/extension_resource_request_policy/extension2/can_load_icons_from_hosted_apps.html @@ -1,3 +1,3 @@ <img src="chrome-extension://fnbdbepgnidhjejikpionpfohdjjogpm/test.png" onload="chrome.test.notifyPass()" - onerror="chrome.test.notifyFail()"> + onerror="chrome.test.notifyFail('Should not have loaded')"> diff --git a/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.html b/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.html index 47d3506..b0340da 100644 --- a/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.html +++ b/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.html @@ -1,25 +1,6 @@ <html> -<head> -<title>Not Loaded</title> -<script type="text/javascript"> - -function load(e) { - document.title = "Loaded"; -} - -function error(e) { - document.title = "Not Loaded"; -} - -</script> - -</head> +<head><title>Not Loaded</title></head> <body> - -<img src="chrome://extension-icon/apocjbpjpkghdepdngjlknfpmabcmlao/24/0" - testsize="24px" - onload="load(event);" - onerror="error(event);"/> - +<script src="index.js"></script> </body> -</head> +</html> diff --git a/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.js b/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.js new file mode 100644 index 0000000..5447286 --- /dev/null +++ b/chrome/test/data/extensions/api_test/icons/extension_no_permission/index.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var img = document.createElement('img'); +img.onload = function() { + document.title = 'Loaded'; +}; +img.onerror = function() { + document.title = 'Not Loaded'; +}; +img.src = 'chrome://extension-icon/apocjbpjpkghdepdngjlknfpmabcmlao/24/0'; +document.body.appendChild(img); diff --git a/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json b/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json index 2833a1c..fa96782 100644 --- a/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json +++ b/chrome/test/data/extensions/api_test/icons/extension_no_permission/manifest.json @@ -3,6 +3,7 @@ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCk/WWuKvmfJx/Q0ldDrtXsP7JbFOPtP7rfasiAlmQoJpW4ECHpqTqj/i/E68MVLzAagp790vUeSgyJF4U0P3eHf8e6pskyrEz0+UYt6PElEIjyOnMu5JY3c6l7NdeJK5DVI0SIsspeA1HmxUQ+7CCv7A4fTCwwp1UNjQsG56feeQIDAQAB", "name": "test", "version": "0.1", + "manifest_version": 2, "permissions": [], "incognito": "split", "icons": { diff --git a/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.html b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.html index 9642617..f9e9efd 100644 --- a/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.html +++ b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.html @@ -1,63 +1,3 @@ -<script type="text/javascript"> - -var TOTAL = 4; -var count = 0; - -function load(e) { - if (++count < TOTAL) - return; - - // Good. All the images have loaded. Now make sure they're the correct size. - var imgs = document.getElementsByTagName('img'); - for (var x = 0; x < imgs.length; x++) { - var style = getComputedStyle(imgs[x]); - var size = imgs[x].getAttribute('testsize'); - if (style.height != size || style.width != size) { - document.title = "Incorrect size on " + imgs[x].src; - return; - } - } - - // Success! - document.title = "Loaded"; -} - -function error(e) { - // We failed to load an image that should have loaded. - document.title = "Not loaded: " + e.target.src; -} - -</script> - -<!-- Tests loading a standard 128px icon. --> -<img src="chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/128/0" - testsize="128px" - onload="load(event);" - onerror="error(event);"/> - -<!-- - Tests loading a standard 48px icon with a MATCH_SMALLER. - This should not be resized to 48px. ---> -<img src="chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/48/2" - testsize="32px" - onload="load(event);" - onerror="error(event);"/> - -<!-- - Tests loading a standard 32px icon, grayscale. We assume that we - actually got a grayscale image back here. ---> -<img src="chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/32/1?grayscale=true" - testsize="32px" - onload="load(event);" - onerror="error(event);"/> - -<!-- - Tests loading a 16px by resizing the 32px version (MATCH_BIGGER). - This should be resized to 16px. ---> -<img src="chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/16/1" - testsize="16px" - onload="load(event);" - onerror="error(event);"/> +<body> +<script src="index.js"></script> +</body> diff --git a/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js new file mode 100644 index 0000000..7600c48 --- /dev/null +++ b/chrome/test/data/extensions/api_test/icons/extension_with_permission/index.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var TEST_CASES = [ + // Tests loading a standard 128px icon. + { + url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/128/0', + expectedSize: 128 + }, + // Tests loading a standard 48px icon with a MATCH_SMALLER. + // This should not be resized to 48px. + { + url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/48/2', + expectedSize: 32 + }, + // Tests loading a standard 32px icon, grayscale. We assume that we actually + // got a grayscale image back here. + { + url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/' + + '32/1?grayscale=true', + expectedSize: 32 + }, + // Tests loading a 16px by resizing the 32px version (MATCH_BIGGER). + // This should be resized to 16px. + { + url: 'chrome://extension-icon/gbmgkahjioeacddebbnengilkgbkhodg/16/1', + expectedSize: 16 + } +]; + +var loadedImageCount = 0; + +TEST_CASES.forEach(function(testCase) { + var img = document.createElement('img'); + img.onload = function() { + if (img.naturalWidth != testCase.expectedSize || + img.naturalHeight != testCase.expectedSize) { + document.title = 'Incorrect size on ' + testCase.url + + ' Expected: ' + testCase.expectedSize + 'x' + testCase.expectedSize + + ' Actual: ' + img.naturalWidth + 'x' + img.naturalHeight; + return; + } + + if (++loadedImageCount == TEST_CASES.length) { + document.title = 'Loaded'; + } + }; + img.onerror = function() { + // We failed to load an image that should have loaded. + document.title = 'Couldn\'t load ' + testCase.url; + }; + img.src = testCase.url; + document.body.appendChild(img); +}); diff --git a/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json b/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json index ea4d279..dea2b91 100644 --- a/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json +++ b/chrome/test/data/extensions/api_test/icons/extension_with_permission/manifest.json @@ -3,6 +3,7 @@ "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuBACa7q+sBalhnUT3lsGuuZ9PEzfoJCBoPJdCS0cfQGqAlgbBsKKqnLLgrUuK9g23PYcGTOryxnJ0eLr3Wl+gkV+CcZ4i64qfBSPt+WCTO4F9XHnqJVWRDjNY+7q0ytf8X6wdgA6ebTx4OE1t52nudNhGgYcFkRYwNAjwV5PKzQIDAQAB", "name": "test", "version": "0.1", + "manifest_version": 2, "permissions": [ "management" ], "incognito": "split", "icons": { diff --git a/chrome/test/data/extensions/api_test/offscreen_tabs/a.html b/chrome/test/data/extensions/api_test/offscreen_tabs/a.html index 872d7fc..747ae5a 100644 --- a/chrome/test/data/extensions/api_test/offscreen_tabs/a.html +++ b/chrome/test/data/extensions/api_test/offscreen_tabs/a.html @@ -1,14 +1,9 @@ <html> <head> <script src="tab_util.js"></script> - <script> - function keyboard(e) { - if (e.charCode == Q_KEY) - window.location = 'c.html'; - } - </script> + <script src="a.js"></script> </head> - <body onkeypress="keyboard(event)"> + <body> <a href="b.html" style="position:absolute; left:10px; top:10px;">b.html</a> </body> </head> diff --git a/chrome/test/data/extensions/api_test/offscreen_tabs/a.js b/chrome/test/data/extensions/api_test/offscreen_tabs/a.js new file mode 100644 index 0000000..39cf26d --- /dev/null +++ b/chrome/test/data/extensions/api_test/offscreen_tabs/a.js @@ -0,0 +1,8 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onkeypress = function(e) { + if (e.charCode == Q_KEY) + window.location = 'c.html'; +}; diff --git a/chrome/test/data/extensions/api_test/offscreen_tabs/manifest.json b/chrome/test/data/extensions/api_test/offscreen_tabs/manifest.json index b7684dc..faf7ba3 100644 --- a/chrome/test/data/extensions/api_test/offscreen_tabs/manifest.json +++ b/chrome/test/data/extensions/api_test/offscreen_tabs/manifest.json @@ -2,5 +2,6 @@ "name": "chrome.experimental.offscreenTabs API test", "description": "tests offscrene tabs API", "version": "1", + "manifest_version": 2, "permissions": [ "experimental", "*://*/*" ] } diff --git a/chrome/test/data/extensions/api_test/permissions/optional_gesture/manifest.json b/chrome/test/data/extensions/api_test/permissions/optional_gesture/manifest.json index 2da308d..9282102 100644 --- a/chrome/test/data/extensions/api_test/permissions/optional_gesture/manifest.json +++ b/chrome/test/data/extensions/api_test/permissions/optional_gesture/manifest.json @@ -6,6 +6,5 @@ "background": { "scripts": ["background.js"] }, - "permissions": ["permissions"], "optional_permissions": ["tabs"] } diff --git a/chrome/test/data/extensions/api_test/stubs/background.html b/chrome/test/data/extensions/api_test/stubs/background.js index f1d207d..1e10767 100644 --- a/chrome/test/data/extensions/api_test/stubs/background.html +++ b/chrome/test/data/extensions/api_test/stubs/background.js @@ -1,4 +1,3 @@ -<script> // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,4 +16,3 @@ chrome.extension.onRequest.addListener(function(msg, sender, responseFunc) { // On first install, send a success message so the test can continue. chrome.test.notifyPass(); -</script> diff --git a/chrome/test/data/extensions/api_test/stubs/content_script.js b/chrome/test/data/extensions/api_test/stubs/content_script.js index dfdb0e7..1b3f2eb 100644 --- a/chrome/test/data/extensions/api_test/stubs/content_script.js +++ b/chrome/test/data/extensions/api_test/stubs/content_script.js @@ -24,6 +24,12 @@ chrome.extension.sendRequest("getApi", function(apis) { if (typeof(module[section]) == "undefined") return; module[section].forEach(function(entry) { + // Ignore entries that are not applicable to the manifest that we're + // running under. + if (entry.maximumManifestVersion && entry.maximumManifestVersion < 2) { + return; + } + var path = namespace + "." + entry.name; if (module.unprivileged || entry.unprivileged) { unprivilegedPaths.push(path); diff --git a/chrome/test/data/extensions/api_test/stubs/manifest.json b/chrome/test/data/extensions/api_test/stubs/manifest.json index 6909f1e..af8bbbb 100644 --- a/chrome/test/data/extensions/api_test/stubs/manifest.json +++ b/chrome/test/data/extensions/api_test/stubs/manifest.json @@ -1,7 +1,10 @@ { "name": "Content Script Extension API Stubs Test", "version": "1.0", - "background_page": "background.html", + "manifest_version": 2, + "background": { + "scripts": ["background.js"] + }, "content_scripts": [ { "matches": ["http://*/*"], diff --git a/chrome/test/data/extensions/api_test/terminal/component_extension/manifest.json b/chrome/test/data/extensions/api_test/terminal/component_extension/manifest.json index 629c551..b21761f 100644 --- a/chrome/test/data/extensions/api_test/terminal/component_extension/manifest.json +++ b/chrome/test/data/extensions/api_test/terminal/component_extension/manifest.json @@ -2,6 +2,7 @@ "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQChptAQ0n4R56N03nWQ1ogR7DVRBjGo80Vw6G9KLjzZv44D8rq5Q5IkeQrtKgWyZfXevlsCe3LaLo18rcz8iZx6lK2xhLdUR+ORjsjuBfdEL5a5cWeRTSxf75AcqndQsmpwMBdrMTCZ8jQNusUI+XlrihLNNJuI5TM4vNINI5bYFQIBIw==", "name": "chrome.terminalPrivate.apitest", "version": "0.1", + "manifest_version": 2, "description": "end-to-end test for terminalPrivate api. Test opens two crosh processes, starts infinite loop that echos 'aaaa' in both of them and observes output.", "permissions": ["terminalPrivate"] } diff --git a/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.html b/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.html index 9c8afe8..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.html @@ -1 +1 @@ -<body onload="document.location='b.html'"></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.js b/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.js new file mode 100644 index 0000000..b54c36e --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/clientRedirect/a.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location='b.html'; +} diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.html index e206db4..f4b9cd5 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.html @@ -1,10 +1,2 @@ <!-- Navigates from an extension URL to a HTTP URL causing a process switch. --> -<script> -function navigate() { - location.href = - "http://127.0.0.1:" + - location.search.substr(1) + - "/files/extensions/api_test/webnavigation/crossProcess/empty.html"; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.js new file mode 100644 index 0000000..5df72cb --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/a.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + setTimeout(function() { + location.href = + "http://127.0.0.1:" + + location.search.substr(1) + + "/files/extensions/api_test/webnavigation/crossProcess/empty.html"; + }, 0); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.html index 60892dc..5da3404 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.html @@ -1,15 +1,3 @@ <!-- Starting on an extension URL, redirects through an app extent to an HTTP URL, causing two process switches. --> -<script> -function navigate() { - var target = - "http://127.0.0.1:" + - location.search.substr(1) + - "/files/extensions/api_test/webnavigation/crossProcess/empty.html"; - location.href = - "http://www.a.com:" + - location.search.substr(1) + - "/server-redirect?" + target; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="c.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.js new file mode 100644 index 0000000..58de17a --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/c.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + setTimeout(function() { + var target = + "http://127.0.0.1:" + + location.search.substr(1) + + "/files/extensions/api_test/webnavigation/crossProcess/empty.html"; + location.href = + "http://www.a.com:" + + location.search.substr(1) + + "/server-redirect?" + target; + }, 0); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.html index bdce6b4..3c4bb96 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.html @@ -1,16 +1,3 @@ <!-- Redirects to a slowly loading page and starts a new navigation before it commits. --> -<script> -var target = - location.origin + location.pathname.replace("d.html", "empty.html"); - -function navigate() { - location.href = - "http://127.0.0.1:" + location.search.substr(1) + "/test1"; -} - -function navigate2() { - location.href = target; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="d.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.js new file mode 100644 index 0000000..ff8bf32 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/d.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var target = + location.origin + location.pathname.replace("d.html", "empty.html"); + +onload = function() { + setTimeout(function() { + location.href = + "http://127.0.0.1:" + location.search.substr(1) + "/test1"; + }, 0); +}; + +function navigate2() { + location.href = target; +} diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.html index a583a44..5b8bf64 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.html @@ -1,13 +1,3 @@ <!-- Redirects to a slowly loading page, and then updates its history state before the new load commits. --> -<script> -function updateHistory() { - history.pushState({}, "", "empty.html"); -} - -function navigate() { - location.href = - "http://127.0.0.1:" + location.search.substr(1) + "/test2"; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="e.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.js new file mode 100644 index 0000000..ed136b8 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/e.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function updateHistory() { + history.pushState({}, "", "empty.html"); +} + +onload = function() { + setTimeout(function() { + location.href = + "http://127.0.0.1:" + location.search.substr(1) + "/test2"; + }, 0); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.html index 2995adf..fdaf6010 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.html @@ -1,15 +1,3 @@ <!-- Redirects to a slowly loading page and then updates its reference fragment before the new page commits. --> -<script> -var target = location.href + "#foo"; - -function updateFragment() { - location.href = target; -} - -function navigate() { - location.href = - "http://127.0.0.1:" + location.search.substr(1) + "/test3"; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="f.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.js new file mode 100644 index 0000000..acbf559 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/f.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var target = location.href + "#foo"; + +function updateFragment() { + location.href = target; +} + +onload = function() { + setTimeout(function() { + location.href = + "http://127.0.0.1:" + location.search.substr(1) + "/test3"; + }, 0); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.html index ee95424..3d69b31 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.html @@ -1,17 +1,6 @@ <!-- Page with a slowly loading iframe that updates its reference fragment before the iframe commits. --> -<script> -var target = location.href + "#foo"; - -function updateFragment() { - location.href = target; -} - -function loadframe() { - var frame = document.getElementById("frame"); - frame.src = "http://127.0.0.1:" + location.search.substr(1) + "/test4"; -} -</script> -<body onload="loadframe()"> +<script src="g.js"></script> +<body> <iframe id="frame"></frame> </body> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.js new file mode 100644 index 0000000..fbda70f --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/g.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var target = location.href + "#foo"; + +function updateFragment() { + location.href = target; +} + +onload = function() { + var frame = document.getElementById("frame"); + frame.src = "http://127.0.0.1:" + location.search.substr(1) + "/test4"; +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.html index c0fa1c5..abc0c7a 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.html @@ -1,15 +1,6 @@ <!-- Page with a slowly loading iframe that updates its history state before the iframe commits. --> -<script> -function updateHistory() { - history.pushState({}, "", "empty.html"); -} - -function loadframe() { - var frame = document.getElementById("frame"); - frame.src = "http://127.0.0.1:" + location.search.substr(1) + "/test5"; -} -</script> -<body onload="loadframe()"> +<script src="h.js"></script> +<body> <iframe id="frame"></frame> </body> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.js new file mode 100644 index 0000000..7870865 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/h.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function updateHistory() { + history.pushState({}, "", "empty.html"); +} + +onload = function() { + var frame = document.getElementById("frame"); + frame.src = "http://127.0.0.1:" + location.search.substr(1) + "/test5"; +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.html b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.html index 41b3982..cea29d8 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.html +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.html @@ -1,13 +1,3 @@ <!-- Redirects to a slowly loading page but then replaces its history state before the page commits. --> -<script> -function updateHistory() { - history.replaceState({}, "", "empty.html"); -} - -function navigate() { - location.href = - "http://127.0.0.1:" + location.search.substr(1) + "/test6"; -} -</script> -<body onload="setTimeout(navigate, 0)"></body> +<script src="i.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.js b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.js new file mode 100644 index 0000000..e9d909f --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/crossProcess/i.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function updateHistory() { + history.replaceState({}, "", "empty.html"); +} + +onload = function() { + setTimeout(function() { + location.href = + "http://127.0.0.1:" + location.search.substr(1) + "/test6"; + }, 0); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/failures/b.html b/chrome/test/data/extensions/api_test/webnavigation/failures/b.html index 33413d3..f5c7be2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/failures/b.html +++ b/chrome/test/data/extensions/api_test/webnavigation/failures/b.html @@ -1 +1 @@ -<body onload="document.location = 'c.html'"></body> +<script src="b.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/failures/b.js b/chrome/test/data/extensions/api_test/webnavigation/failures/b.js new file mode 100644 index 0000000..4956417 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/failures/b.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location = 'c.html'; +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/failures/e.html b/chrome/test/data/extensions/api_test/webnavigation/failures/e.html index 7d554d6..db0ac58 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/failures/e.html +++ b/chrome/test/data/extensions/api_test/webnavigation/failures/e.html @@ -1,4 +1,2 @@ -<script> -stop(); -</script> -<img src="nonexistant/img.gif"> +<script src="e.js"></script> +<img src="nonexistent/img.gif"> diff --git a/chrome/test/data/extensions/api_test/webnavigation/failures/e.js b/chrome/test/data/extensions/api_test/webnavigation/failures/e.js new file mode 100644 index 0000000..e88ddae --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/failures/e.js @@ -0,0 +1,5 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +stop(); diff --git a/chrome/test/data/extensions/api_test/webnavigation/filtered/a.html b/chrome/test/data/extensions/api_test/webnavigation/filtered/a.html index 9c8afe8..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/filtered/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/filtered/a.html @@ -1 +1 @@ -<body onload="document.location='b.html'"></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/filtered/a.js b/chrome/test/data/extensions/api_test/webnavigation/filtered/a.js new file mode 100644 index 0000000..b54c36e --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/filtered/a.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location='b.html'; +} diff --git a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.html b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.html index b0b6c8b..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.html @@ -1,14 +1 @@ -<html> -<head> -<script> -function navigate() { - if (window.sessionStorage['redirected'] != 1) { - window.sessionStorage['redirected'] = 1; - // Required so this results in a history entry being created. - window.setTimeout('document.location = "b.html"', 0); - } -} -</script> -</head> -<body onload="navigate()"></body> -</html> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.js b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.js new file mode 100644 index 0000000..56714f2 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/a.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + if (window.sessionStorage['redirected'] != 1) { + window.sessionStorage['redirected'] = 1; + // Required so this results in a history entry being created. + window.setTimeout(function() {document.location = 'b.html'}, 0); + } +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.html b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.html index 8fb41fd..f5c7be2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.html +++ b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.html @@ -1 +1 @@ -<body onload="history.back();"></body> +<script src="b.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.js b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.js new file mode 100644 index 0000000..de05323 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/forwardBack/b.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + history.back(); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/history/a.html b/chrome/test/data/extensions/api_test/webnavigation/history/a.html index d66558a..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/history/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/history/a.html @@ -1 +1 @@ -<body onload="history.pushState({}, 'foo', 'b.html');"></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/history/a.js b/chrome/test/data/extensions/api_test/webnavigation/history/a.js new file mode 100644 index 0000000..e5ff4ff --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/history/a.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + history.pushState({}, 'foo', 'b.html'); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/b.html b/chrome/test/data/extensions/api_test/webnavigation/iframe/b.html index c5741ef..f5c7be2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/iframe/b.html +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/b.html @@ -1 +1 @@ -<body onload='document.location = "c.html"'></body> +<script src="b.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/b.js b/chrome/test/data/extensions/api_test/webnavigation/iframe/b.js new file mode 100644 index 0000000..4956417 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/b.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location = 'c.html'; +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/d.html b/chrome/test/data/extensions/api_test/webnavigation/iframe/d.html index d34a39b..395ea67 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/iframe/d.html +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/d.html @@ -1,10 +1,5 @@ -<html><body> -<script> - function loadF() { - var iframe = document.createElement('iframe'); - iframe.src = "f.html"; - var div = document.getElementById('f'); - div.appendChild(iframe); - } -</script> -<iframe src="e.html" onload="loadF()"></iframe><div id="f"></div></body></html> +<body> +<script src="d.js"></script> +</body> + + diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/d.js b/chrome/test/data/extensions/api_test/webnavigation/iframe/d.js new file mode 100644 index 0000000..24baf43 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/d.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var eFrame = document.createElement('iframe'); +eFrame.onload = function() { + var fFrame = document.createElement('iframe'); + fFrame.src = 'f.html'; + document.body.appendChild(fFrame); +}; +eFrame.src = 'e.html'; +document.body.appendChild(eFrame); diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/f.html b/chrome/test/data/extensions/api_test/webnavigation/iframe/f.html index 993b37a..8b95e59 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/iframe/f.html +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/f.html @@ -1 +1 @@ -<body onload='document.location = "g.html"'></body> +<script src="f.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/f.js b/chrome/test/data/extensions/api_test/webnavigation/iframe/f.js new file mode 100644 index 0000000..44e51e6 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/f.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location = 'g.html'; +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/i.html b/chrome/test/data/extensions/api_test/webnavigation/iframe/i.html index 89f750c..bcf89c2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/iframe/i.html +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/i.html @@ -1,12 +1 @@ -<html> -<head> -<script> -function navigate() { - parent.location.href='c.html'; - location.replace('about:blank'); -} -</script> -</head> -<body onload="navigate()"></body> -</body> -</html> +<script src="i.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/iframe/i.js b/chrome/test/data/extensions/api_test/webnavigation/iframe/i.js new file mode 100644 index 0000000..5ee0366 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/iframe/i.js @@ -0,0 +1,8 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + parent.location.href = 'c.html'; + location.replace('about:blank'); +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/manifest.json b/chrome/test/data/extensions/api_test/webnavigation/manifest.json index 0b64814..b179c54 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/manifest.json +++ b/chrome/test/data/extensions/api_test/webnavigation/manifest.json @@ -1,6 +1,7 @@ { "name": "webNavigation", "version": "1.0", + "manifest_version": 2, "description": "Tests the webNavigation API events.", "permissions": ["webNavigation", "tabs"] } diff --git a/chrome/test/data/extensions/api_test/webnavigation/openTab/a.html b/chrome/test/data/extensions/api_test/webnavigation/openTab/a.html index f318e9c..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/openTab/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/openTab/a.html @@ -1 +1 @@ -<body onload='window.open("b.html")'></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/openTab/a.js b/chrome/test/data/extensions/api_test/webnavigation/openTab/a.js new file mode 100644 index 0000000..1682ad4 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/openTab/a.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + window.open('b.html'); +} diff --git a/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.html b/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.html index 6a43763..ed52c3d 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.html +++ b/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.html @@ -1 +1 @@ -<body onload='document.location = "a.html#anchor";'></body> +<script src="a.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.js b/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.js new file mode 100644 index 0000000..dabcfa5 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/referenceFragment/a.js @@ -0,0 +1,7 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + document.location = 'a.html#anchor'; +} diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_api.html b/chrome/test/data/extensions/api_test/webnavigation/test_api.html index 3e0f4ca..6890c6f 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_api.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_api.html @@ -1,15 +1 @@ -<script> -chrome.webNavigation.onBeforeNavigate.addListener( - function(details) {}); -chrome.webNavigation.onCommitted.addListener( - function(details) {}); -chrome.webNavigation.onDOMContentLoaded.addListener( - function(details) {}); -chrome.webNavigation.onCompleted.addListener( - function(details) {}); -chrome.webNavigation.onErrorOccurred.addListener( - function(details) {}); -chrome.webNavigation.onCreatedNavigationTarget.addListener( - function(details) {}); -chrome.test.notifyPass(); -</script> +<script src="test_api.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_api.js b/chrome/test/data/extensions/api_test/webnavigation/test_api.js new file mode 100644 index 0000000..146ada9 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/test_api.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +chrome.webNavigation.onBeforeNavigate.addListener( + function(details) {}); +chrome.webNavigation.onCommitted.addListener( + function(details) {}); +chrome.webNavigation.onDOMContentLoaded.addListener( + function(details) {}); +chrome.webNavigation.onCompleted.addListener( + function(details) {}); +chrome.webNavigation.onErrorOccurred.addListener( + function(details) {}); +chrome.webNavigation.onCreatedNavigationTarget.addListener( + function(details) {}); +chrome.test.notifyPass(); diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.html b/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.html index e256495..ebd903f 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.html @@ -1,5 +1,2 @@ <script src="test_clientRedirect.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.js b/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.js index 72534c4..cfdea4f 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_clientRedirect.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -77,4 +77,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.html b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.html index e44bf8e..c6241acb 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.html @@ -1,5 +1,2 @@ <script src="test_crossProcess.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js index ed77310..7dc3098 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; var URL_REGULAR = "http://127.0.0.1:PORT/files/extensions/api_test/webnavigation/crossProcess/empty.html"; @@ -635,4 +635,4 @@ function runTests() { ]); }); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_failures.html b/chrome/test/data/extensions/api_test/webnavigation/test_failures.html index 7fc4139..f7d31a7 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_failures.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_failures.html @@ -1,5 +1,2 @@ <script src="test_failures.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_failures.js b/chrome/test/data/extensions/api_test/webnavigation/test_failures.js index 357b149..4b33bd8 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_failures.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_failures.js @@ -2,36 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; chrome.test.runTests([ - // Navigates to a non-existant page. - function nonExistant() { - expect([ - { label: "onBeforeNavigate", - event: "onBeforeNavigate", - details: { frameId: 0, - processId: 0, - tabId: 0, - timeStamp: 0, - url: getURL('failures/nonexistant.html') }}, - { label: "onErrorOccurred", - event: "onErrorOccurred", - details: { error: "net::ERR_FILE_NOT_FOUND", - frameId: 0, - processId: 0, - tabId: 0, - timeStamp: 0, - url: getURL('failures/nonexistant.html') }}], - [["onBeforeNavigate", "onErrorOccurred"]]); - chrome.tabs.update(tabId, { url: getURL('failures/nonexistant.html') }); - }, - - // An page that tries to load an non-existant iframe. - function nonExistantIframe() { + // An page that tries to load an non-existent iframe. + function nonExistentIframe() { expect([ { label: "a-onBeforeNavigate", event: "onBeforeNavigate", @@ -84,8 +62,8 @@ function runTests() { chrome.tabs.update(tabId, { url: getURL('failures/d.html') }); }, - // An iframe navigates to a non-existant page. - function nonExistantIframeNavigation() { + // An iframe navigates to a non-existent page. + function nonExistentIframeNavigation() { expect([ { label: "a-onBeforeNavigate", event: "onBeforeNavigate", @@ -208,6 +186,32 @@ function runTests() { "onErrorOccurred"]]); chrome.tabs.update(tabId, { url: getURL('failures/e.html') }); }, + + // Navigates to a non-existent page (this test case must be last, + // otherwise the non-existant URL breaks tests that follow, since loading + // those test pages is seen as a non-extension -> extension URL + // transition, which is forbidden by web_accessible_resources enforcement + // in manifest version 2.) + function nonExistent() { + expect([ + { label: "onBeforeNavigate", + event: "onBeforeNavigate", + details: { frameId: 0, + processId: 0, + tabId: 0, + timeStamp: 0, + url: getURL('failures/nonexistent.html') }}, + { label: "onErrorOccurred", + event: "onErrorOccurred", + details: { error: "net::ERR_FILE_NOT_FOUND", + frameId: 0, + processId: 0, + tabId: 0, + timeStamp: 0, + url: getURL('failures/nonexistent.html') }}], + [["onBeforeNavigate", "onErrorOccurred"]]); + chrome.tabs.update(tabId, { url: getURL('failures/nonexistent.html') }); + }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_filtered.html b/chrome/test/data/extensions/api_test/webnavigation/test_filtered.html index dbf62b6..9661f3b 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_filtered.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_filtered.html @@ -1,5 +1,2 @@ <script src="test_filtered.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_filtered.js b/chrome/test/data/extensions/api_test/webnavigation/test_filtered.js index b262b92..66293ea 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_filtered.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_filtered.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -25,4 +25,4 @@ function runTests() { } ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.html b/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.html index 984b60e..7359408 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.html @@ -1,5 +1,2 @@ <script src="test_forwardBack.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.js b/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.js index 2b2c524..7364f21 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_forwardBack.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -108,4 +108,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.html b/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.html index 70f35d8..d4ad155 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.html @@ -1,53 +1 @@ -<script> -var URL = chrome.extension.getURL("getFrame/a.html"); -var tabId = -1; -var processId = -1; - -chrome.test.runTests([ - function testGetFrame() { - chrome.tabs.create({"url": "about:blank"}, function(tab) { - tabId = tab.id; - var done = chrome.test.listenForever( - chrome.webNavigation.onCommitted, - function (details) { - if (details.tabId != tabId) - return; - if (details.url != URL) - return; - processId = details.processId; - chrome.webNavigation.getFrame( - {tabId: tabId, frameId: 0, processId: processId}, - function(details) { - chrome.test.assertEq({errorOccurred: false, url: URL}, - details); - done(); - }); - }); - chrome.tabs.update(tabId, {url: URL}); - }); - }, - - function testGetInvalidFrame() { - chrome.webNavigation.getFrame( - {tabId: tabId, frameId: 1, processId: processId}, - function (details) { - chrome.test.assertEq(null, details); - chrome.test.succeed(); - }); - }, - - function testGetAllFrames() { - chrome.webNavigation.getAllFrames( - {tabId: tabId}, - function (details) { - chrome.test.assertEq( - [{errorOccurred: false, - frameId: 0, - processId: processId, - url: URL}], - details); - chrome.test.succeed(); - }); - } -]); -</script> +<script src="test_getFrame.js"></script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.js b/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.js new file mode 100644 index 0000000..f9f3f22 --- /dev/null +++ b/chrome/test/data/extensions/api_test/webnavigation/test_getFrame.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var URL = chrome.extension.getURL("getFrame/a.html"); +var tabId = -1; +var processId = -1; + +chrome.test.runTests([ + function testGetFrame() { + chrome.tabs.create({"url": "about:blank"}, function(tab) { + tabId = tab.id; + var done = chrome.test.listenForever( + chrome.webNavigation.onCommitted, + function (details) { + if (details.tabId != tabId) + return; + if (details.url != URL) + return; + processId = details.processId; + chrome.webNavigation.getFrame( + {tabId: tabId, frameId: 0, processId: processId}, + function(details) { + chrome.test.assertEq({errorOccurred: false, url: URL}, + details); + done(); + }); + }); + chrome.tabs.update(tabId, {url: URL}); + }); + }, + + function testGetInvalidFrame() { + chrome.webNavigation.getFrame( + {tabId: tabId, frameId: 1, processId: processId}, + function (details) { + chrome.test.assertEq(null, details); + chrome.test.succeed(); + }); + }, + + function testGetAllFrames() { + chrome.webNavigation.getAllFrames( + {tabId: tabId}, + function (details) { + chrome.test.assertEq( + [{errorOccurred: false, + frameId: 0, + processId: processId, + url: URL}], + details); + chrome.test.succeed(); + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_history.html b/chrome/test/data/extensions/api_test/webnavigation/test_history.html index 9a11ed1..605cf9e 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_history.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_history.html @@ -1,5 +1,2 @@ <script src="test_history.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_history.js b/chrome/test/data/extensions/api_test/webnavigation/test_history.js index 2d4b2001..db1b8f5 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_history.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_history.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -55,4 +55,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_iframe.html b/chrome/test/data/extensions/api_test/webnavigation/test_iframe.html index 6f076a5..6ab718c2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_iframe.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_iframe.html @@ -1,5 +1,2 @@ <script src="test_iframe.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_iframe.js b/chrome/test/data/extensions/api_test/webnavigation/test_iframe.js index af72305..b500beb 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_iframe.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_iframe.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -349,4 +349,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_openTab.html b/chrome/test/data/extensions/api_test/webnavigation/test_openTab.html index 1475312..4f06a0e 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_openTab.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_openTab.html @@ -1,5 +1,2 @@ <script src="test_openTab.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_openTab.js b/chrome/test/data/extensions/api_test/webnavigation/test_openTab.js index 707b086..43c5b4c 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_openTab.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_openTab.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -197,4 +197,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_prerender.html b/chrome/test/data/extensions/api_test/webnavigation/test_prerender.html index 8b63601..42ff210 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_prerender.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_prerender.html @@ -1,5 +1,2 @@ <script src="test_prerender.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_prerender.js b/chrome/test/data/extensions/api_test/webnavigation/test_prerender.js index a68c730..dfed276 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_prerender.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_prerender.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; var URL_LOAD = "http://127.0.0.1:PORT/files/prerender/prerender_loader.html"; @@ -96,4 +96,4 @@ function runTests() { ]); }); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.html b/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.html index b705107..82926cb 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.html @@ -1,5 +1,2 @@ <script src="test_referenceFragment.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.js b/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.js index 7366788..b5dab82 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_referenceFragment.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -55,4 +55,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.html b/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.html index fadbdba..5619e37 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.html @@ -1,5 +1,2 @@ <script src="test_requestOpenTab.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.js b/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.js index cdc868e..9a297c3 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_requestOpenTab.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -90,4 +90,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.html b/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.html index 769dc4b..e01ee2e 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.html @@ -1,5 +1,2 @@ <script src="test_serverRedirect.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.js b/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.js index 8cb7091..e05d016 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_serverRedirect.js @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { - var getURL = chrome.extension.getURL; +onload = function() { var URL_LOAD = "http://www.a.com:PORT/files/extensions/api_test/webnavigation/serverRedirect/a.html"; var URL_LOAD_REDIRECT = "http://www.a.com:PORT/server-redirect"; @@ -56,4 +55,4 @@ function runTests() { ]); }); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.html b/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.html index ba2236a..c7b61e8 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.html @@ -1,5 +1,2 @@ <script src="test_simpleLoad.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.js b/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.js index 094f05e..37a6eb2 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_simpleLoad.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -46,4 +46,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.html b/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.html index 0547ef8..3b5f1e5 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.html @@ -1,5 +1,2 @@ <script src="test_targetBlank.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.js b/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.js index e356087..d48cbb7 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_targetBlank.js @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { - var getURL = chrome.extension.getURL; +onload = function() { var URL_LOAD = "http://127.0.0.1:PORT/files/extensions/api_test/webnavigation/targetBlank/a.html"; var URL_TARGET = @@ -102,4 +101,4 @@ function runTests() { ]); }); }); -} +}; diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_userAction.html b/chrome/test/data/extensions/api_test/webnavigation/test_userAction.html index 5520137..b78d498 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_userAction.html +++ b/chrome/test/data/extensions/api_test/webnavigation/test_userAction.html @@ -1,5 +1,2 @@ <script src="test_userAction.js"></script> <script src="framework.js"></script> -<script> - runTests(); -</script> diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_userAction.js b/chrome/test/data/extensions/api_test/webnavigation/test_userAction.js index 7c44d43..0d51379 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/test_userAction.js +++ b/chrome/test/data/extensions/api_test/webnavigation/test_userAction.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function runTests() { +onload = function() { var getURL = chrome.extension.getURL; chrome.tabs.create({"url": "about:blank"}, function(tab) { var tabId = tab.id; @@ -90,4 +90,4 @@ function runTests() { }, ]); }); -} +}; diff --git a/chrome/test/data/extensions/browsertest/crash_44415/ExtA/manifest.json b/chrome/test/data/extensions/browsertest/crash_44415/ExtA/manifest.json index dad5172..e4eb4d2 100644 --- a/chrome/test/data/extensions/browsertest/crash_44415/ExtA/manifest.json +++ b/chrome/test/data/extensions/browsertest/crash_44415/ExtA/manifest.json @@ -1,6 +1,7 @@ { "name": "Popup Test", "version": "1.0", + "manifest_version": 2, "page_action": { "default_icon": "icon.png", "default_popup": "popup.html" diff --git a/chrome/test/data/extensions/native_client/manifest.json b/chrome/test/data/extensions/native_client/manifest.json index 1d64e2e..dba6272 100644 --- a/chrome/test/data/extensions/native_client/manifest.json +++ b/chrome/test/data/extensions/native_client/manifest.json @@ -4,9 +4,8 @@ "version": "0.1", "manifest_version": 2, "description": "Tests Chrome Webstore restriction for Native Client.", - "permissions": ["nativeclient"], "nacl_modules": [{ "path": "dummy.nmf", - "mime_type": "application/pdf" + "mime_type": "application/pdf" }] } diff --git a/chrome/test/data/extensions/platform_apps/iframes/manifest.json b/chrome/test/data/extensions/platform_apps/iframes/manifest.json index 88826b7..70d4d52b 100644 --- a/chrome/test/data/extensions/platform_apps/iframes/manifest.json +++ b/chrome/test/data/extensions/platform_apps/iframes/manifest.json @@ -10,8 +10,5 @@ "background": { "scripts": ["test.js"] } - }, - // Attempt to specify a Content Security Policy that is more relaxed than the - // default (would allow remote iframes). It should be ignored. - "content_security_policy": "script-src 'self'; object-src 'self'" + } } diff --git a/chrome/test/data/extensions/platform_apps/oauth2/manifest.json b/chrome/test/data/extensions/platform_apps/oauth2/manifest.json index 8785218..67f1d5a 100644 --- a/chrome/test/data/extensions/platform_apps/oauth2/manifest.json +++ b/chrome/test/data/extensions/platform_apps/oauth2/manifest.json @@ -2,9 +2,6 @@ "name": "Platform App Test: OAuth2 platform app", "version": "1", "manifest_version": 2, - "permissions": [ - "appWindow" - ], "app": { "background": { "scripts": ["test.js"] diff --git a/chrome/test/data/performance_monitor/extensions/simple_extension_v1/manifest.json b/chrome/test/data/performance_monitor/extensions/simple_extension_v1/manifest.json index 43f6ae4..f7565ba 100644 --- a/chrome/test/data/performance_monitor/extensions/simple_extension_v1/manifest.json +++ b/chrome/test/data/performance_monitor/extensions/simple_extension_v1/manifest.json @@ -1,5 +1,8 @@ { "version": "1", "name": "Simple Extension", - "background_page": "background.html" + "background": { + "page": "background.html" + }, + "manifest_version": 2 } |