diff options
author | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 17:29:35 +0000 |
---|---|---|
committer | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 17:29:35 +0000 |
commit | 381162b2224c18d592e077aae94343cb73296bb9 (patch) | |
tree | 4fe4fa6efe4a65f66c824d2298d538ffd9d98011 /chrome/test | |
parent | 9ad59068b7c34cae14bd70e01cef2adb1d617409 (diff) | |
download | chromium_src-381162b2224c18d592e077aae94343cb73296bb9.zip chromium_src-381162b2224c18d592e077aae94343cb73296bb9.tar.gz chromium_src-381162b2224c18d592e077aae94343cb73296bb9.tar.bz2 |
Adds an experimental processes module to the extensions API.
This first step adds only a Process object with an id, along with a
getProcessForTab function.
BUG=32303
TEST=browser_test.exe --gtest_filter=ExtensionAPITest.Processes
Review URL: http://codereview.chromium.org/551090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
5 files changed, 109 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/processes/a.html b/chrome/test/data/extensions/api_test/processes/a.html new file mode 100644 index 0000000..dcd442e --- /dev/null +++ b/chrome/test/data/extensions/api_test/processes/a.html @@ -0,0 +1,5 @@ +<html> + <body> + <h1>A</h1> + </body> +</html>
\ No newline at end of file diff --git a/chrome/test/data/extensions/api_test/processes/b.html b/chrome/test/data/extensions/api_test/processes/b.html new file mode 100644 index 0000000..7bff50a --- /dev/null +++ b/chrome/test/data/extensions/api_test/processes/b.html @@ -0,0 +1,5 @@ +<html> + <body> + <h1>B</h1> + </body> +</html>
\ No newline at end of file diff --git a/chrome/test/data/extensions/api_test/processes/manifest.json b/chrome/test/data/extensions/api_test/processes/manifest.json new file mode 100644 index 0000000..44fcdfb --- /dev/null +++ b/chrome/test/data/extensions/api_test/processes/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "chrome.experimental.processes", + "version": "0.1", + "description": "end-to-end browser test for chrome.experimental.processes API", + "background_page": "test.html", + "permissions": ["experimental", "tabs"] +} diff --git a/chrome/test/data/extensions/api_test/processes/test.html b/chrome/test/data/extensions/api_test/processes/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/processes/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/processes/test.js b/chrome/test/data/extensions/api_test/processes/test.js new file mode 100644 index 0000000..ecdcaf8 --- /dev/null +++ b/chrome/test/data/extensions/api_test/processes/test.js @@ -0,0 +1,91 @@ +// Processes API test for Chrome. +// browser_tests.exe --gtest_filter=ExtensionApiTest.Processes + +var pass = chrome.test.callbackPass; +var fail = chrome.test.callbackFail; +var assertEq = chrome.test.assertEq; +var assertTrue = chrome.test.assertTrue; + +var tabs = []; + +function createTab(index, url) { + chrome.tabs.create({"url": url}, pass(function(tab) { + tabs[index] = tab; + })); +} + +var getProcess = chrome.experimental.processes.getProcessForTab; + +function pageUrl(letter) { + return chrome.extension.getURL(letter + ".html"); +} + +chrome.test.runTests([ + function setupProcessTests() { + // Open 4 tabs for test, then wait and create a 5th + createTab(0, "about:blank"); + createTab(1, pageUrl("a")); + createTab(2, pageUrl("b")); + createTab(3, "chrome://newtab/"); + + // Wait for all loads to complete. + var completedCount = 0; + var onUpdatedCompleted = chrome.test.listenForever( + chrome.tabs.onUpdated, + function(changedTabId, changeInfo, changedTab) { + if (changedTab.status == "complete") { + completedCount++; + + // Once the NTP finishes loading, create another one. This ensures + // both NTPs end up in the same process. + if (changedTabId == tabs[3].id) { + createTab(4, "chrome://newtab/"); + } + } + + // Once all tabs are done loading, continue with the next test. + if (completedCount == 4) { + onUpdatedCompleted(); + } + } + ); + + }, + + function extensionPageInOwnProcess() { + getProcess(tabs[0].id, pass(function(process0) { + getProcess(tabs[1].id, pass(function(process1) { + // about:blank and extension page should not share a process + assertTrue(process0.id != process1.id); + })); + })); + }, + + function extensionPagesShareProcess() { + getProcess(tabs[1].id, pass(function(process1) { + getProcess(tabs[2].id, pass(function(process2) { + // Pages from same extension should share a process + assertEq(process1.id, process2.id); + })); + })); + }, + + function newTabPageInOwnProcess() { + getProcess(tabs[0].id, pass(function(process0) { + getProcess(tabs[3].id, pass(function(process3) { + // NTP should not share a process with current tabs + assertTrue(process0.id != process3.id); + })); + })); + }, + + function newTabPagesShareProcess() { + getProcess(tabs[3].id, pass(function(process3) { + getProcess(tabs[4].id, pass(function(process4) { + // Multiple NTPs should share a process + assertEq(process3.id, process4.id); + })); + })); + }, + +]); |