summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 12:41:15 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 12:41:15 +0000
commit4c028ff10f9a8a025d1490909ea257056bae0ad9 (patch)
treea405defb2b9edb5051ff5dc20c4cce89ad6fb961 /chrome/test
parent36b70104846c6bd306dae660c3b3266a4acf2c1c (diff)
downloadchromium_src-4c028ff10f9a8a025d1490909ea257056bae0ad9.zip
chromium_src-4c028ff10f9a8a025d1490909ea257056bae0ad9.tar.gz
chromium_src-4c028ff10f9a8a025d1490909ea257056bae0ad9.tar.bz2
Add the onBeforeNavigate and onErrorOccured events to the webNavigation API.
Also, rewrite the onCommitted event such that AUTO_SUBFRAME events are also registered. The frameId and the requestId fields are still unimplemented. Also, there occur navigation events after an error is reported. BUG=50943 TEST=WebNavigationEvents Review URL: http://codereview.chromium.org/3436002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59641 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/test.html279
1 files changed, 201 insertions, 78 deletions
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
index 4ac358d1..431b4e7 100644
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
@@ -16,98 +16,221 @@ function checkExpectations() {
chrome.test.succeed();
}
+chrome.experimental.webNavigation.onBeforeNavigate.addListener(
+ function(details) {
+ console.log('---onBeforeNavigate: ' + details.url);
+ // normalize details.
+ details.timeStamp = 0;
+ if (details.frameId != 0) {
+ details.frameId = 1;
+ }
+ capturedEventData.push(["onBeforeNavigate", details]);
+ checkExpectations();
+});
+
chrome.experimental.webNavigation.onCommitted.addListener(function(details) {
- console.log('---onCommitted: ' + details.url);
+ console.log('---onCommitted: ' + details.url);
+ // normalize details.
+ details.timeStamp = 0;
+ if (details.frameId != 0) {
+ details.frameId = 1;
+ }
+ capturedEventData.push(["onCommitted", details]);
+ checkExpectations();
+});
+
+chrome.experimental.webNavigation.onErrorOccurred.addListener(
+ function(details) {
+ console.log('---onErrorOccurred: ' + details.url);
// normalize details.
details.timeStamp = 0;
if (details.frameId != 0) {
details.frameId = 1;
}
- capturedEventData.push(details);
+ capturedEventData.push(["onErrorOccurred", details]);
checkExpectations();
});
var getURL = chrome.extension.getURL;
chrome.tabs.getSelected(null, function(tab) {
- var tabId = tab.id;
+ var tabId = tab.id;
+
+ chrome.test.runTests([
+ /* Navigates to an URL */
+ function simpleLoad() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('simpleLoad/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('simpleLoad/a.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') });
+ },
- chrome.test.runTests([
- /* Navigates to an URL */
- function simpleLoad() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('simpleLoad/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') });
- },
+ /* Navigates to a.html that redirects to b.html (using javascript)
+ after a delay of 500ms, so the initial navigation is completed and
+ the redirection is marked as client_redirect */
+ function clientRedirect() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('clientRedirect/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('clientRedirect/a.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('clientRedirect/b.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "client_redirect",
+ transitionType: "link",
+ url: getURL('clientRedirect/b.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') });
+ },
- /* Navigates to a.html that redirects to b.html (using javascript)
- after a delay of 500ms, so the initial navigation is completed and
- the redirection is marked as client_redirect */
- function clientRedirect() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('clientRedirect/a.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "client_redirect",
- transitionType: "link",
- url: getURL('clientRedirect/b.html') }]);
- chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') });
- },
+ /* First navigates to a.html which redirects to to b.html which uses
+ history.back() to navigate back to a.html */
+ function forwardBack() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('forwardBack/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('forwardBack/a.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('forwardBack/b.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "client_redirect",
+ transitionType: "link",
+ url: getURL('forwardBack/b.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('forwardBack/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "forward_back",
+ transitionType: "link",
+ url: getURL('forwardBack/a.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') });
+ },
- /* First navigates to a.html which redirects to to b.html which uses
- history.back() to navigate back to a.html */
- function forwardBack() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('forwardBack/a.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "client_redirect",
- transitionType: "link",
- url: getURL('forwardBack/b.html') },
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "forward_back",
- transitionType: "link",
- url: getURL('forwardBack/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') });
- },
+ /* Navigates to a.html which includes b.html as an iframe. b.html
+ redirects to c.html. */
+ function iframe() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('iframe/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('iframe/a.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('iframe/b.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "auto_subframe",
+ url: getURL('iframe/b.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('iframe/c.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "manual_subframe",
+ url: getURL('iframe/c.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('iframe/a.html') });
+ },
- /* Navigates to a.html which includes b.html as an iframe. b.html
- redirects to c.html. Note that all navigation entries are for
- a.html. Also, b.html does not generate a navigation entry. */
- function iframe() {
- expect([
- { frameId: 0,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('iframe/a.html') },
- { frameId: 1,
- tabId: tabId,
- timeStamp: 0,
- transitionQualifiers: "",
- transitionType: "link",
- url: getURL('iframe/a.html') }]);
- chrome.tabs.update(tabId, { url: getURL('iframe/a.html') });
- },
- ]);
+ /* Navigates to a non-existant page. */
+ function nonExistant() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('nonexistant.html') }],
+ [ "onErrorOccurred",
+ { error: "net::ERR_FILE_NOT_FOUND",
+ frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: getURL('nonexistant.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ url: "chrome://chromewebdata/"}],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: tabId,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('nonexistant.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('nonexistant.html') });
+ },
+ ]);
});
</script>