Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(613)

Unified Diff: chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html

Issue 6363002: Implement the onBeforeRetarget event of the webNavigation API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html
diff --git a/chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html b/chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html
index cbbfd99b1ffaca2dac8660d887f72b2024e0c50a..54080a734cd6f1d92e4e32c1a0ae813858c3fe18 100644
--- a/chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html
+++ b/chrome/test/data/extensions/api_test/webnavigation/navigation1/test.html
@@ -3,12 +3,16 @@ var expectedEventData;
var capturedEventData;
var nextFrameId;
var frameIds;
+var nextTabId;
+var tabIds;
function expect(data) {
expectedEventData = data;
capturedEventData = [];
nextFrameId = 1;
frameIds = {};
+ nextTabId = 0;
+ tabIds = {};
}
function checkExpectations() {
@@ -22,13 +26,27 @@ function checkExpectations() {
function captureEvent(name, details) {
// normalize details.
- details.timeStamp = 0;
- if (details.frameId != 0) {
+ if ('timeStamp' in details) {
+ details.timeStamp = 0;
+ }
+ if (('frameId' in details) && (details.frameId != 0)) {
if (frameIds[details.frameId] === undefined) {
frameIds[details.frameId] = nextFrameId++;
}
details.frameId = frameIds[details.frameId];
}
+ if ('tabId' in details) {
+ if (tabIds[details.tabId] === undefined) {
+ tabIds[details.tabId] = nextTabId++;
+ }
+ details.tabId = tabIds[details.tabId];
+ }
+ if ('sourceTabId' in details) {
+ if (tabIds[details.sourceTabId] === undefined) {
+ tabIds[details.sourceTabId] = nextTabId++;
+ }
+ details.sourceTabId = tabIds[details.sourceTabId];
+ }
capturedEventData.push([name, details]);
checkExpectations();
}
@@ -52,6 +70,11 @@ chrome.experimental.webNavigation.onCompleted.addListener(
captureEvent("onCompleted", details);
});
+chrome.experimental.webNavigation.onBeforeRetarget.addListener(
+ function(details) {
+ captureEvent("onBeforeRetarget", details);
+});
+
chrome.experimental.webNavigation.onErrorOccurred.addListener(
function(details) {
captureEvent("onErrorOccurred", details);
@@ -68,24 +91,24 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('simpleLoad/a.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "link",
url: getURL('simpleLoad/a.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('simpleLoad/a.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('simpleLoad/a.html') }]]);
chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') });
@@ -99,47 +122,47 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/a.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "link",
url: getURL('clientRedirect/a.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/a.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/a.html') }],
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/b.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "client_redirect",
transitionType: "link",
url: getURL('clientRedirect/b.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/b.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('clientRedirect/b.html') }]]);
chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') });
@@ -152,70 +175,70 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "link",
url: getURL('forwardBack/a.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }],
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/b.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "client_redirect",
transitionType: "link",
url: getURL('forwardBack/b.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/b.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/b.html') }],
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "forward_back",
transitionType: "link",
url: getURL('forwardBack/a.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('forwardBack/a.html') }]]);
chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') });
@@ -228,12 +251,12 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/a.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "link",
@@ -241,57 +264,57 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 1,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/b.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/a.html') }],
[ "onCommitted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "auto_subframe",
url: getURL('iframe/b.html') }],
[ "onDOMContentLoaded",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/b.html') }],
[ "onCompleted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/b.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/a.html') }],
[ "onBeforeNavigate",
{ frameId: 1,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/c.html') }],
[ "onCommitted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "manual_subframe",
url: getURL('iframe/c.html') }],
[ "onDOMContentLoaded",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/c.html') }],
[ "onCompleted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/c.html') }]]);
chrome.tabs.update(tabId, { url: getURL('iframe/a.html') });
@@ -305,12 +328,12 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 0,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/d.html') }],
[ "onCommitted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "link",
@@ -318,84 +341,221 @@ chrome.tabs.getSelected(null, function(tab) {
[ "onBeforeNavigate",
{ frameId: 1,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/e.html') }],
[ "onDOMContentLoaded",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/d.html') }],
[ "onCommitted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "auto_subframe",
url: getURL('iframe/e.html') }],
[ "onDOMContentLoaded",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/e.html') }],
[ "onBeforeNavigate",
{ frameId: 2,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/f.html') }],
[ "onCompleted",
{ frameId: 1,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/e.html') }],
[ "onCommitted",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "auto_subframe",
url: getURL('iframe/f.html') }],
[ "onDOMContentLoaded",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/f.html') }],
[ "onCompleted",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/f.html') }],
[ "onCompleted",
{ frameId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/d.html') }],
[ "onBeforeNavigate",
{ frameId: 2,
requestId: 0,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/g.html') }],
[ "onCommitted",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
transitionQualifiers: "",
transitionType: "manual_subframe",
url: getURL('iframe/g.html') }],
[ "onDOMContentLoaded",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/g.html') }],
[ "onCompleted",
{ frameId: 2,
- tabId: tabId,
+ tabId: 0,
timeStamp: 0,
url: getURL('iframe/g.html') }]]);
chrome.tabs.update(tabId, { url: getURL('iframe/d.html') });
},
+
+ /* Opens a new tab from javascript. */
+ function openTab() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('openTab/a.html') }],
+ [ "onDOMContentLoaded",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onCompleted",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onBeforeRetarget",
+ { sourceTabId: 0,
+ sourceUrl: getURL('openTab/a.html'),
+ targetUrl: getURL('openTab/b.html'),
+ timeStamp: 0 }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('openTab/b.html') }],
+ [ "onDOMContentLoaded",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }],
+ [ "onCompleted",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('openTab/a.html') });
+ },
+
+ /* Opens a new tab from javascript within an iframe. */
+ function openTabFrame() {
+ expect([
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/c.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('openTab/c.html') }],
+ [ "onBeforeNavigate",
+ { frameId: 1,
+ requestId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onDOMContentLoaded",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/c.html') }],
+ [ "onCommitted",
+ { frameId: 1,
+ tabId: 0,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "auto_subframe",
+ url: getURL('openTab/a.html') }],
+ [ "onDOMContentLoaded",
+ { frameId: 1,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onCompleted",
+ { frameId: 1,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/a.html') }],
+ [ "onCompleted",
+ { frameId: 0,
+ tabId: 0,
+ timeStamp: 0,
+ url: getURL('openTab/c.html') }],
+ [ "onBeforeRetarget",
+ { sourceTabId: 0,
+ sourceUrl: getURL('openTab/a.html'),
+ targetUrl: getURL('openTab/b.html'),
+ timeStamp: 0 }],
+ [ "onBeforeNavigate",
+ { frameId: 0,
+ requestId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }],
+ [ "onCommitted",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ transitionQualifiers: "",
+ transitionType: "link",
+ url: getURL('openTab/b.html') }],
+ [ "onDOMContentLoaded",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }],
+ [ "onCompleted",
+ { frameId: 0,
+ tabId: 1,
+ timeStamp: 0,
+ url: getURL('openTab/b.html') }]]);
+ chrome.tabs.update(tabId, { url: getURL('openTab/c.html') });
+ },
]);
});
</script>

Powered by Google App Engine
This is Rietveld 408576698