diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 17:57:09 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 17:57:09 +0000 |
commit | b2a74caaf15e234b5e6c03151d12c28a319a06cb (patch) | |
tree | 4b0f606a6ee117a66e66e4b7fb6546d9943bd425 /chrome/test | |
parent | 293caa54c215807abcef6a31aa34ca0e49e51581 (diff) | |
download | chromium_src-b2a74caaf15e234b5e6c03151d12c28a319a06cb.zip chromium_src-b2a74caaf15e234b5e6c03151d12c28a319a06cb.tar.gz chromium_src-b2a74caaf15e234b5e6c03151d12c28a319a06cb.tar.bz2 |
Add chrome.extension.inIncognitoTab for content scripts.
Review URL: http://codereview.chromium.org/822008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/extensions/api_test/incognito/apis/background.html | 35 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/incognito/apis/manifest.json | 2 |
2 files changed, 36 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/api_test/incognito/apis/background.html b/chrome/test/data/extensions/api_test/incognito/apis/background.html index ff13197..606f6b5 100644 --- a/chrome/test/data/extensions/api_test/incognito/apis/background.html +++ b/chrome/test/data/extensions/api_test/incognito/apis/background.html @@ -71,6 +71,41 @@ chrome.test.runTests([ chrome.tabs.remove(tab.id, pass()); })); })); + }, + + // Tests content script injection to verify that the script can tell its + // in incongnito. + function contentScriptTestIncognito() { + // The property is undefined outside of content scripts. + assertEq(undefined, chrome.extension.inIncognitoTab); + + var testUrl = "http://localhost:1337/files/extensions/test_file.html"; + + // Test that chrome.extension.inIncognitoTab is true for incognito tabs. + chrome.tabs.create({windowId: incognitoWindow.id, url: testUrl}, + pass(function(tab) { + chrome.tabs.executeScript(tab.id, + {code: 'document.title = chrome.extension.inIncognitoTab'}, + pass(function() { + assertEq(undefined, chrome.extension.lastError); + chrome.tabs.get(tab.id, pass(function(tab) { + assertEq("true", tab.title); + })); + })); + })); + + // ... and false for normal tabs. + chrome.tabs.create({windowId: normalWindow.id, url: testUrl}, + pass(function(tab) { + chrome.tabs.executeScript(tab.id, + {code: 'document.title = chrome.extension.inIncognitoTab'}, + pass(function() { + assertEq(undefined, chrome.extension.lastError); + chrome.tabs.get(tab.id, pass(function(tab) { + assertEq("false", tab.title); + })); + })); + })); } ]); </script> diff --git a/chrome/test/data/extensions/api_test/incognito/apis/manifest.json b/chrome/test/data/extensions/api_test/incognito/apis/manifest.json index 4781276..5bb9a63 100644 --- a/chrome/test/data/extensions/api_test/incognito/apis/manifest.json +++ b/chrome/test/data/extensions/api_test/incognito/apis/manifest.json @@ -3,5 +3,5 @@ "version": "0.1", "description": "test that an incognito extension behaves properly", "background_page": "background.html", - "permissions": ["tabs"] + "permissions": ["tabs", "http://*/*"] } |