diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 02:05:39 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 02:05:39 +0000 |
commit | 719663e4f49853e2a9ff84bc0ac29cca484105d1 (patch) | |
tree | 175f6f17d37984d9fcea0698f28efece6d2195ef /chrome/test | |
parent | 6776c72f56c29972bfd47efc1a1cf1629e3c7da2 (diff) | |
download | chromium_src-719663e4f49853e2a9ff84bc0ac29cca484105d1.zip chromium_src-719663e4f49853e2a9ff84bc0ac29cca484105d1.tar.gz chromium_src-719663e4f49853e2a9ff84bc0ac29cca484105d1.tar.bz2 |
Introduce a new 'all_frames' property to content scripts and
default it to false. This should improve performance in
sites that use frames and elimiate confusion, since in most
cases developers *don't* expect content scripts to match
frames.
Review URL: http://codereview.chromium.org/412008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
6 files changed, 60 insertions, 4 deletions
diff --git a/chrome/test/data/extensions/api_test/content_script_all_frames/all_frames.js b/chrome/test/data/extensions/api_test/content_script_all_frames/all_frames.js new file mode 100644 index 0000000..71d22fd --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_script_all_frames/all_frames.js @@ -0,0 +1 @@ +chrome.extension.sendRequest("all_frames"); diff --git a/chrome/test/data/extensions/api_test/content_script_all_frames/manifest.json b/chrome/test/data/extensions/api_test/content_script_all_frames/manifest.json new file mode 100644 index 0000000..0f73a8f --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_script_all_frames/manifest.json @@ -0,0 +1,18 @@ +{ + "name": "content_script_all_frames", + "version": "1.0", + "description": "Tests the all_frames property of content script declarations.", + "background_page": "test.html", + "permissions": ["tabs"], + "content_scripts": [ + { + "matches": ["http://*/*"], + "js": ["top_frame_only.js"] + }, + { + "matches": ["http://*/*"], + "js": ["all_frames.js"], + "all_frames": true + } + ] +} diff --git a/chrome/test/data/extensions/api_test/content_script_all_frames/test.html b/chrome/test/data/extensions/api_test/content_script_all_frames/test.html new file mode 100644 index 0000000..e8f8088 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_script_all_frames/test.html @@ -0,0 +1,34 @@ +<script> +// We load a page that has one iframe +// So we should receive two "all_frames" messages, and one "top_frame_only" +// messages. + +var num_all_frames_messages = 0; +var num_top_frame_only_messages = 0; + +chrome.test.runTests([ + // Tests receiving a request from a content script and responding. + function onRequest() { + chrome.extension.onRequest.addListener( + function(request, sender, sendResponse) { + if (request == "all_frames") { + num_all_frames_messages++; + } else if (request == "top_frame_only") { + num_top_frame_only_messages++; + } else { + chrome.test.fail("Unexpected request: " + JSON.stringify(request)); + } + + if (num_all_frames_messages == 2 && num_top_frame_only_messages == 1) { + chrome.test.succeed(); + } + } + ); + } +]); + +chrome.test.log("Creating tab..."); +chrome.tabs.create({ + url: "http://localhost:1337/files/extensions/test_file_with_iframe.html" +}); +</script> diff --git a/chrome/test/data/extensions/api_test/content_script_all_frames/top_frame_only.js b/chrome/test/data/extensions/api_test/content_script_all_frames/top_frame_only.js new file mode 100644 index 0000000..76ad923 --- /dev/null +++ b/chrome/test/data/extensions/api_test/content_script_all_frames/top_frame_only.js @@ -0,0 +1 @@ +chrome.extension.sendRequest("top_frame_only"); diff --git a/chrome/test/data/extensions/subscribe_page_action/feed_finder.js b/chrome/test/data/extensions/subscribe_page_action/feed_finder.js index d5c4f2a..5261264 100644 --- a/chrome/test/data/extensions/subscribe_page_action/feed_finder.js +++ b/chrome/test/data/extensions/subscribe_page_action/feed_finder.js @@ -2,10 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -if (window == top) { - findFeeds(); - window.addEventListener("focus", findFeeds); -} +findFeeds(); +window.addEventListener("focus", findFeeds); function findFeeds() { // Find all the RSS link elements. diff --git a/chrome/test/data/extensions/test_file_with_iframe.html b/chrome/test/data/extensions/test_file_with_iframe.html new file mode 100644 index 0000000..8a310c7 --- /dev/null +++ b/chrome/test/data/extensions/test_file_with_iframe.html @@ -0,0 +1,4 @@ +<html>
+Test file!
+<iframe src="test_file.html"></iframe>
+</html>
|