Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js |
| diff --git a/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5faa82cd1d90ff961d42c7cdd6c7fe555d963f16 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/webnavigation/test_crossProcess.js |
| @@ -0,0 +1,406 @@ |
| +// Copyright (c) 2012 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. |
| + |
| +function runTests() { |
| + var getURL = chrome.extension.getURL; |
| + var URL_REGULAR = |
| + "http://127.0.0.1:PORT/files/extensions/api_test/webnavigation/crossProcess/b.html"; |
| + var URL_REDIRECT = "http://www.a.com:PORT/server-redirect"; |
| + var URL_SLOW = "http://127.0.0.1:PORT/slow"; |
| + chrome.tabs.create({"url": "about:blank"}, function(tab) { |
| + var tabId = tab.id; |
| + chrome.test.getConfig(function(config) { |
| + var fixPort = function(url) { |
| + return url.replace(/PORT/g, config.testServer.port); |
| + }; |
| + URL_REGULAR = fixPort(URL_REGULAR); |
| + URL_REDIRECT = fixPort(URL_REDIRECT); |
| + URL_SLOW = fixPort(URL_SLOW); |
| + |
| + chrome.test.runTests([ |
| + // Navigates from an extension page to a HTTP page which causes a |
| + // process switch. |
| + function crossProcess() { |
| + expect([ |
| + { label: "a-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/a.html') }}, |
| + { label: "a-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/a.html') }}, |
| + { label: "a-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/a.html') }}, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/a.html') }}, |
| + { label: "b-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}, |
| + { label: "b-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: URL_REGULAR }}, |
| + { label: "b-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}, |
| + { label: "b-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}], |
| + [ navigationOrder("a-"), navigationOrder("b-") ]); |
| + |
| + chrome.tabs.update( |
| + tabId, |
| + { url: getURL('crossProcess/a.html?' + config.testServer.port) }); |
| + }, |
| + |
| + // Redirects through an app extend, should cause two process switches. |
|
Charlie Reis
2012/08/06 20:04:13
nit: extend -> extent
jochen (gone - plz use gerrit)
2012/08/06 21:08:39
Done.
|
| + function crossProcessRedirect() { |
| + expect([ |
| + { label: "a-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/c.html') }}, |
| + { label: "a-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/c.html') }}, |
| + { label: "a-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/c.html') }}, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/c.html') }}, |
| + { label: "b-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REDIRECT }}, |
| + { label: "b-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { error: "net::ERR_ABORTED", |
| + frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REDIRECT }}, |
| + { label: "c-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 2, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}, |
| + { label: "c-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 2, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: URL_REGULAR }}, |
| + { label: "c-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 2, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}, |
| + { label: "c-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 2, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_REGULAR }}], |
| + [ navigationOrder("a-"), |
| + navigationOrder("c-"), |
| + [ "a-onCompleted", "b-onBeforeNavigate", "b-onErrorOccurred", |
| + "c-onBeforeNavigate"] ]); |
| + |
| + chrome.tabs.update( |
| + tabId, |
| + { url: getURL('crossProcess/c.html?' + config.testServer.port) }); |
| + }, |
| + |
| + // Navigates to a different site, but then aborts the navigation by |
| + // starting a new one. |
| + function crossProcessAbort() { |
| + expect([ |
| + { label: "a-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/d.html') }}, |
| + { label: "a-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/d.html') }}, |
| + { label: "a-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/d.html') }}, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/d.html') }}, |
| + { label: "b-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}, |
| + { label: "b-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { error: "net::ERR_ABORTED", |
| + frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}, |
| + { label: "c-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/b.html') }}, |
| + { label: "c-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: ["client_redirect"], |
| + transitionType: "link", |
| + url: getURL('crossProcess/b.html') }}, |
| + { label: "c-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/b.html') }}, |
| + { label: "c-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/b.html') }}], |
| + [ navigationOrder("a-"), |
| + navigationOrder("c-"), |
| + [ "a-onCompleted", "b-onBeforeNavigate", "b-onErrorOccurred", |
| + "c-onCommitted"] ]); |
| + |
| + chrome.tabs.update( |
| + tabId, |
| + { url: getURL('crossProcess/d.html?' + config.testServer.port) }); |
| + }, |
| + |
| + // Navigates to a different site, but then modifies the history using |
| + // history.pushState(). |
| + function crossProcessHistory() { |
| + expect([ |
| + { label: "a-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/e.html') }}, |
| + { label: "a-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/e.html') }}, |
| + { label: "a-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/e.html') }}, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/e.html') }}, |
| + { label: "a-onHistoryStateUpdated", |
| + event: "onHistoryStateUpdated", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: ["client_redirect"], |
| + transitionType: "link", |
| + url: getURL('crossProcess/b.html') }}, |
| + { label: "b-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}, |
| + { label: "b-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { error: "net::ERR_ABORTED", |
| + frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}], |
| + [ navigationOrder("a-"), |
| + [ "a-onCompleted", "b-onBeforeNavigate", |
| + "a-onHistoryStateUpdated"] ]); |
| + |
| + chrome.tabs.update( |
| + tabId, |
| + { url: getURL('crossProcess/e.html?' + config.testServer.port) }); |
| + }, |
| + |
| + // Navigates to a different site, but then modifies the reference |
| + // framgent. |
| + function crossProcessFragment() { |
| + expect([ |
| + { label: "a-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/f.html') }}, |
| + { label: "a-onCommitted", |
| + event: "onCommitted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/f.html') }}, |
| + { label: "a-onDOMContentLoaded", |
| + event: "onDOMContentLoaded", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/f.html') }}, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: getURL('crossProcess/f.html') }}, |
| + { label: "a-onReferenceFragmentUpdated", |
| + event: "onReferenceFragmentUpdated", |
| + details: { frameId: 0, |
| + processId: 0, |
| + tabId: 0, |
| + timeStamp: 0, |
| + transitionQualifiers: [], |
| + transitionType: "link", |
| + url: getURL('crossProcess/f.html#foo') }}, |
| + { label: "b-onBeforeNavigate", |
| + event: "onBeforeNavigate", |
| + details: { frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}, |
| + { label: "b-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { error: "net::ERR_ABORTED", |
| + frameId: 0, |
| + processId: 1, |
| + tabId: 0, |
| + timeStamp: 0, |
| + url: URL_SLOW }}], |
| + [ navigationOrder("a-"), |
| + [ "a-onCompleted", "b-onBeforeNavigate", |
| + "a-onReferenceFragmentUpdated"] ]); |
| + |
| + chrome.tabs.update( |
| + tabId, |
| + { url: getURL('crossProcess/f.html?' + config.testServer.port) }); |
| + }, |
| + ]); |
| + }); |
| + }); |
| +} |