diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 05:25:22 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 05:25:22 +0000 |
commit | f0488f2fa6fb1dea3b18f806dbd46f6a828063de (patch) | |
tree | 274a930929cbd862a14bfdc3bf92a9c59e468c78 /chrome/test | |
parent | befd8d82ec47c02d6b17d9fa7b6c1f3bb703150f (diff) | |
download | chromium_src-f0488f2fa6fb1dea3b18f806dbd46f6a828063de.zip chromium_src-f0488f2fa6fb1dea3b18f806dbd46f6a828063de.tar.gz chromium_src-f0488f2fa6fb1dea3b18f806dbd46f6a828063de.tar.bz2 |
Adds a browser_test for extension startup, content script
injection, and user script injection.
Also adds unit tests that EXTENSIONS_READY always gets fired.
Also removes some old test data that we weren't using.
Review URL: http://codereview.chromium.org/149120
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
12 files changed, 4 insertions, 152 deletions
diff --git a/chrome/test/data/extensions/content_script_inject/js_test.js b/chrome/test/data/extensions/content_script_inject/js_test.js deleted file mode 100644 index 87a0930..0000000 --- a/chrome/test/data/extensions/content_script_inject/js_test.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2009 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. - -// A quick and dirty JavaScript test runner.
-
-function assert(truth) {
- if (!truth) {
- throw new Error('Assertion failed');
- }
-}
-
-function runAllTests() {
- // If there was already an error, do nothing. We don't want to muddy
- // up the results.
- if (document.title.indexOf("Error: ") == 0) {
- return;
- }
-
- for (var propName in window) {
- if (typeof window[propName] == "function" &&
- propName.indexOf("test") == 0) {
- try {
- window[propName]();
- document.title += propName + ",";
- } catch (e) {
- // We use document.title to communicate results back to the browser.
- document.title = "Error: " + propName + ': ' + e.message;
- return;
- }
- }
- }
-}
diff --git a/chrome/test/data/extensions/content_script_inject/manifest.json b/chrome/test/data/extensions/content_script_inject/manifest.json deleted file mode 100644 index 48e4496..0000000 --- a/chrome/test/data/extensions/content_script_inject/manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0.0", - "name": "User script inject", - "content_scripts": [ - { - "matches": ["file://*/content_script_inject_page.html"], - "css": ["script1.css"], - "js": ["js_test.js", "script1a.js", "script1b.js"] - }, - { - "matches": ["file://*/content_script_inject_page.html"], - "js": ["js_test.js", "script2.js"] - }, - { - "matches": ["file://*/content_script_inject_page.html"], - "js": ["js_test.js", "script3.js"], - "run_at": "document_start" - } - ] -} diff --git a/chrome/test/data/extensions/content_script_inject/script1.css b/chrome/test/data/extensions/content_script_inject/script1.css deleted file mode 100644 index 521b501b..0000000 --- a/chrome/test/data/extensions/content_script_inject/script1.css +++ /dev/null @@ -1,10 +0,0 @@ -/* -Copyright (c) 2006-2009 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. -*/ - -/* script1b.js tests that this rule was applied. */ -body { - background:red; -} diff --git a/chrome/test/data/extensions/content_script_inject/script1a.js b/chrome/test/data/extensions/content_script_inject/script1a.js deleted file mode 100644 index 87f4f55..0000000 --- a/chrome/test/data/extensions/content_script_inject/script1a.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2009 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. - -// create a global variable. script1b.js tests to make sure it is visible and -// script2.js tests to make sure it is not. -var script1_var = 1; diff --git a/chrome/test/data/extensions/content_script_inject/script1b.js b/chrome/test/data/extensions/content_script_inject/script1b.js deleted file mode 100644 index 8e7e102..0000000 --- a/chrome/test/data/extensions/content_script_inject/script1b.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2009 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. - -// This tests that we are running in the same global context as script1a.js. -function testScriptFilesRunInSameContext() { - assert(script1_var === 1); -} - -// This tests that our relationship to content is working correctly. -// a) We should not see content globals in our global scope. -// b) We should have a contentWindow object that looks like a DOM Window. -// c) We should be able to access content globals via contentWindow. -function testContentInteraction() { - assert(typeof content_var == "undefined"); - assert(typeof contentWindow != "undefined"); - assert(contentWindow.location.href.match(/content_script_inject_page.html$/)); - assert(contentWindow.content_var == "hello"); -} - -// Test that our css in script1.css was injected successfully. -function testCSSWasInjected() { - assert(document.defaultView.getComputedStyle( - document.body, null)["background-color"] == "rgb(255, 0, 0)"); -} - -runAllTests(); diff --git a/chrome/test/data/extensions/content_script_inject/script2.js b/chrome/test/data/extensions/content_script_inject/script2.js deleted file mode 100644 index 9133afa2..0000000 --- a/chrome/test/data/extensions/content_script_inject/script2.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2009 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. - -// Tests that we cannot see global variables defined in other content scripts. -// This var was defined in script1a.js. We run each content script in a separate -// context, so we shouldn't see globals across them. -function testCannotSeeOtherContentScriptGlobals() {
- assert(typeof script1_var == "undefined");
-}
-
-runAllTests();
diff --git a/chrome/test/data/extensions/content_script_inject/script3.js b/chrome/test/data/extensions/content_script_inject/script3.js deleted file mode 100644 index 15bc225..0000000 --- a/chrome/test/data/extensions/content_script_inject/script3.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2009 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 gotDOMContentLoadedEvent = false; - -// Test that at parse time, we have the document element. -// This basically tests that we don't get injected too early (before there is -// a document element). -var hasDocumentElement = (document.documentElement.tagName == "HTML"); - -// TODO(aa): We would like to add more tests here verifying that we aren't -// injected too late. For example, we could test that there are zero child -// nodes to the documentElement, but unfortunately run_at:document_start is -// currently buggy and doesn't guarantee that. - -window.addEventListener("DOMContentLoaded", function() { - gotDOMContentLoadedEvent = true; -}, false); - -// Don't run tests until onload so that we can test that DOMContentLoaded and -// onload happen after this script runs. -window.addEventListener("load", runAllTests, false); - -function testRunAtDocumentStart() { - assert(hasDocumentElement); -} - -function testGotLoadEvents() { - assert(gotDOMContentLoadedEvent); -} diff --git a/chrome/test/data/extensions/content_script_inject_page.html b/chrome/test/data/extensions/content_script_inject_page.html deleted file mode 100644 index 4412e19..0000000 --- a/chrome/test/data/extensions/content_script_inject_page.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title></title> -<script> -var content_var = "hello"; -</script> -</head> -<body> -</body> -</html> diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json index 544b6b6..c2255cc 100644 --- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json +++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json @@ -10,7 +10,7 @@ "permissions": ["http://*.google.com/*", "https://*.google.com/*"], "content_scripts": [ { - "matches": ["http://*.google.com/*", "https://*.google.com/*"], + "matches": ["file://*", "http://*.google.com/*", "https://*.google.com/*"], "js": ["script1.js", "script2.js"], "css": ["style1.css", "style2.css", "style2.css"] }, diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/script2.js b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/script2.js index 4ffd7b9..b6dc38e 100644 --- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/script2.js +++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/script2.js @@ -1 +1,2 @@ // script2 +document.title = "Modified"; diff --git a/chrome/test/data/extensions/test_file.html b/chrome/test/data/extensions/test_file.html new file mode 100755 index 0000000..9718b43 --- /dev/null +++ b/chrome/test/data/extensions/test_file.html @@ -0,0 +1 @@ +<title>Unmodified</title>
diff --git a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json index 0f0e048..6c50242 100644 --- a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json +++ b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json @@ -6,7 +6,7 @@ "permissions": ["http://*.google.com/*", "https://*.google.com/*"], "content_scripts": [ { - "matches": ["http://*.google.com/*", "https://*.google.com/*"], + "matches": ["file://*", "http://*.google.com/*", "https://*.google.com/*"], "js": ["script1.js", "script2.js"], "css": ["style1.css", "style2.css", "style2.css"] }, |