summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 07:06:52 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 07:06:52 +0000
commit784688a65f687f05e9cb8ab25fc7bf1a9d14fb00 (patch)
treeb8f88dba229d93569d03d41ea5e7e8712bffd5dc /chrome/test
parent5808d6e578817a36eeecc93e5cb32d5aa8807d96 (diff)
downloadchromium_src-784688a65f687f05e9cb8ab25fc7bf1a9d14fb00.zip
chromium_src-784688a65f687f05e9cb8ab25fc7bf1a9d14fb00.tar.gz
chromium_src-784688a65f687f05e9cb8ab25fc7bf1a9d14fb00.tar.bz2
Reland r54723. Implement the webNavigation.onCommitted event.
BUG=50943 TEST=ExtensionApiTest.WebNavigationEvents Review URL: http://codereview.chromium.org/3310025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html6
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html3
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json7
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html1
-rw-r--r--chrome/test/data/extensions/api_test/webnavigation/navigation/test.html113
10 files changed, 139 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html
new file mode 100644
index 0000000..3e3e11a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/a.html
@@ -0,0 +1,3 @@
+<script>
+ window.setTimeout('document.location = "b.html";', 500);
+</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html
new file mode 100644
index 0000000..18ecdcb
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/clientRedirect/b.html
@@ -0,0 +1 @@
+<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html
new file mode 100644
index 0000000..7b3462c
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/a.html
@@ -0,0 +1,6 @@
+<script>
+ if (window.sessionStorage['redirected'] != 1) {
+ window.sessionStorage['redirected'] = 1;
+ window.setTimeout('document.location = "b.html";', 500);
+ }
+</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html
new file mode 100644
index 0000000..a4270ed
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/forwardBack/b.html
@@ -0,0 +1,3 @@
+<script>
+ window.setTimeout('history.back();', 500);
+</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html
new file mode 100644
index 0000000..c5c157d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/a.html
@@ -0,0 +1 @@
+<html><body><iframe src="b.html"></iframe></body></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html
new file mode 100644
index 0000000..d6e86d8
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/b.html
@@ -0,0 +1,3 @@
+<script>
+ window.setTimeout('document.location = "c.html";', 500);
+</script>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html
new file mode 100644
index 0000000..18ecdcb
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/iframe/c.html
@@ -0,0 +1 @@
+<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json b/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json
new file mode 100644
index 0000000..c5538ce
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/manifest.json
@@ -0,0 +1,7 @@
+{
+ "name": "navigation",
+ "version": "1.0",
+ "description": "Tests the webNavigation API events.",
+ "permissions": ["experimental", "tabs"],
+ "background_page": "test.html"
+}
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html
new file mode 100644
index 0000000..18ecdcb
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/simpleLoad/a.html
@@ -0,0 +1 @@
+<html></html>
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html b/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
new file mode 100644
index 0000000..4ac358d1
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation/test.html
@@ -0,0 +1,113 @@
+<script>
+var expectedEventData;
+var capturedEventData;
+
+function expect(data) {
+ expectedEventData = data;
+ capturedEventData = [];
+}
+
+function checkExpectations() {
+ if (capturedEventData.length < expectedEventData.length) {
+ return;
+ }
+ chrome.test.assertEq(JSON.stringify(expectedEventData),
+ JSON.stringify(capturedEventData));
+ chrome.test.succeed();
+}
+
+chrome.experimental.webNavigation.onCommitted.addListener(function(details) {
+ console.log('---onCommitted: ' + details.url);
+ // normalize details.
+ details.timeStamp = 0;
+ if (details.frameId != 0) {
+ details.frameId = 1;
+ }
+ capturedEventData.push(details);
+ checkExpectations();
+});
+
+var getURL = chrome.extension.getURL;
+chrome.tabs.getSelected(null, function(tab) {
+ var tabId = tab.id;
+
+ 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([
+ { 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([
+ { 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. 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') });
+ },
+ ]);
+});
+</script>