diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:40:32 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 18:40:32 +0000 |
commit | bc535ee5bb4eece29f5d88bcc688613b3b208b27 (patch) | |
tree | 37b90c6bbbe98732c81515b35f02f8b835ac5df7 /chrome/test | |
parent | 7566dbf757617f9e77f4a7f9f031402eb7818b04 (diff) | |
download | chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.zip chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.tar.gz chromium_src-bc535ee5bb4eece29f5d88bcc688613b3b208b27.tar.bz2 |
Add support for a "split" incognito behavior for extensions.
- On by default for apps, off by default for extensions.
- Split mode means "run incognito extensions in a separate process if the user
says OK, and the two processes can only see their own profile."
- Spanning mode is what we have now, and means "run a single extension process,
but allow it to access both profiles if the user says OK."
BUG=49232
BUG=49114
TEST=extensions still work in incognito when you check "Allow in Incognito".
Review URL: http://codereview.chromium.org/3210007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
5 files changed, 108 insertions, 8 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 606f6b5..34d2f25 100644 --- a/chrome/test/data/extensions/api_test/incognito/apis/background.html +++ b/chrome/test/data/extensions/api_test/incognito/apis/background.html @@ -76,8 +76,7 @@ chrome.test.runTests([ // 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); + assertTrue(!chrome.extension.inIncognitoContext); var testUrl = "http://localhost:1337/files/extensions/test_file.html"; @@ -85,7 +84,7 @@ chrome.test.runTests([ chrome.tabs.create({windowId: incognitoWindow.id, url: testUrl}, pass(function(tab) { chrome.tabs.executeScript(tab.id, - {code: 'document.title = chrome.extension.inIncognitoTab'}, + {code: 'document.title = chrome.extension.inIncognitoContext'}, pass(function() { assertEq(undefined, chrome.extension.lastError); chrome.tabs.get(tab.id, pass(function(tab) { @@ -98,7 +97,7 @@ chrome.test.runTests([ chrome.tabs.create({windowId: normalWindow.id, url: testUrl}, pass(function(tab) { chrome.tabs.executeScript(tab.id, - {code: 'document.title = chrome.extension.inIncognitoTab'}, + {code: 'document.title = chrome.extension.inIncognitoContext'}, pass(function() { assertEq(undefined, chrome.extension.lastError); chrome.tabs.get(tab.id, pass(function(tab) { diff --git a/chrome/test/data/extensions/api_test/incognito/split/background.html b/chrome/test/data/extensions/api_test/incognito/split/background.html new file mode 100644 index 0000000..32fec55 --- /dev/null +++ b/chrome/test/data/extensions/api_test/incognito/split/background.html @@ -0,0 +1,89 @@ +<script> +var pass = chrome.test.callbackPass; +var assertEq = chrome.test.assertEq; +var assertTrue = chrome.test.assertTrue; + +var win, tab; +var inIncognitoContext = chrome.extension.inIncognitoContext; + +// Listen to some events to make sure we don't get events from the other +// profile. + +chrome.tabs.onUpdated.addListener(function(id, info, tab) { + if (inIncognitoContext != tab.incognito) { + chrome.test.notifyFail( + "[FAIL] Split-mode incognito test received an event for " + + (tab.incognito ? "an incognito" : "a normal") + + " tab in the wrong profile."); + } +}); + +chrome.extension.onRequest.addListener( + function(request, sender, sendResponse) { + if (inIncognitoContext != sender.tab.incognito) { + chrome.test.notifyFail( + "[FAIL] Split-mode incognito test received a message from " + + (sender.tab.incognito ? "an incognito" : "a normal") + + " tab in the wrong profile."); + } +}); + +chrome.test.runTests([ + function setupWindows() { + // The test harness should have set us up with 2 windows: 1 incognito + // and 1 regular. Since we are in split mode, we should only see the + // window for our profile. + chrome.windows.getAll({populate: true}, pass(function(windows) { + assertEq(1, windows.length); + + win = windows[0]; + tab = win.tabs[0]; + assertEq(inIncognitoContext, win.incognito); + })); + }, + + // Tests that we can update an incognito tab and get the event for it. + function tabUpdate() { + var newUrl = "about:blank"; + + // Prepare the event listeners first. + var done = chrome.test.listenForever(chrome.tabs.onUpdated, + function(id, info, tab) { + assertEq(tab.id, id); + assertEq(inIncognitoContext, tab.incognito); + assertEq(newUrl, tab.url); + if (info.status == "complete") + done(); + }); + + // Update our tab. + chrome.tabs.update(tab.id, {"url": newUrl}, pass()); + }, + + // Tests content script injection to verify that the script can tell its + // in incongnito. + function contentScriptTestIncognito() { + var testUrl = "http://localhost:1337/files/extensions/test_file.html"; + + // Test that chrome.extension.inIncognitoContext is true for incognito + // tabs. + chrome.tabs.create({windowId: win.id, url: testUrl}, + pass(function(tab) { + chrome.tabs.executeScript(tab.id, + {code: 'chrome.extension.sendRequest({' + + ' inIncognitoContext: chrome.extension.inIncognitoContext' + + '});'}, + pass(function() { + assertEq(undefined, chrome.extension.lastError); + })); + })); + + var done = chrome.test.listenForever(chrome.extension.onRequest, + function(request, sender, sendResponse) { + assertEq(inIncognitoContext, request.inIncognitoContext); + sendResponse(); + done(); + }); + } +]); +</script> diff --git a/chrome/test/data/extensions/api_test/incognito/split/manifest.json b/chrome/test/data/extensions/api_test/incognito/split/manifest.json new file mode 100644 index 0000000..b3a9206 --- /dev/null +++ b/chrome/test/data/extensions/api_test/incognito/split/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "incognito split-mode apitest", + "version": "0.1", + "description": "test that an incognito extension in split mode behaves properly", + "background_page": "background.html", + "incognito": "split", + "permissions": ["tabs", "http://*/*"] +} 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 3232930..f9d97ff 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 @@ -25,12 +25,14 @@ { "path": "bar.html", "renderProcessId": 42, - "renderViewId": 88 + "renderViewId": 88, + "incognito": false }, { "path": "dog.html", "renderProcessId": 0, - "renderViewId": 0 + "renderViewId": 0, + "incognito": false } ], "hasPopupAction": false, diff --git a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension2.json b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension2.json index 7c3c36f..8751022 100644 --- a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension2.json +++ b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension2.json @@ -15,12 +15,14 @@ { "path": "bar.html", "renderProcessId": 42, - "renderViewId": 88 + "renderViewId": 88, + "incognito": false }, { "path": "bar.html", "renderProcessId": 0, - "renderViewId": 0 + "renderViewId": 0, + "incognito": false } ], "hasPopupAction": false, |