mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1256652 - [webext] Add webNavigation client_redirect transitions implementation and test case. r=krizsa
MozReview-Commit-ID: DoDzXCuk4FQ --HG-- extra : transplant_source : 9gb%BC9I%B7%B2%2C%3E%17%22%D6%84%04%13%22%1C%15P
This commit is contained in:
parent
dc5fd2506d
commit
32c8c2f2b7
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE HTML>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="1;dummy_page.html">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE HTML>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
Refresh: 1;url=dummy_page.html
|
@ -5,6 +5,9 @@ support-files =
|
||||
file_WebRequest_page1.html
|
||||
file_WebRequest_page2.html
|
||||
file_WebRequest_page3.html
|
||||
file_webNavigation_clientRedirect.html
|
||||
file_webNavigation_clientRedirect_httpHeaders.html
|
||||
file_webNavigation_clientRedirect_httpHeaders.html^headers^
|
||||
file_WebNavigation_page1.html
|
||||
file_WebNavigation_page2.html
|
||||
file_WebNavigation_page3.html
|
||||
|
@ -72,6 +72,8 @@ const FRAME2 = BASE + "/file_WebNavigation_page3.html";
|
||||
const FRAME_PUSHSTATE = BASE + "/file_WebNavigation_page3_pushState.html";
|
||||
const REDIRECT = BASE + "/redirection.sjs";
|
||||
const REDIRECTED = BASE + "/dummy_page.html";
|
||||
const CLIENT_REDIRECT = BASE + "/file_webNavigation_clientRedirect.html";
|
||||
const CLIENT_REDIRECT_HTTPHEADER = BASE + "/file_webNavigation_clientRedirect_httpHeaders.html";
|
||||
|
||||
const REQUIRED = [
|
||||
"onBeforeNavigate",
|
||||
@ -217,6 +219,45 @@ add_task(function* webnav_transitions_props() {
|
||||
"Got the expected 'forward_back' transitionQualifiers in the OnCommitted events");
|
||||
}
|
||||
|
||||
// transitionQualifier: client_redirect
|
||||
// (from meta http-equiv tag)
|
||||
received = [];
|
||||
yield loadAndWait(win, "onCompleted", REDIRECTED, () => {
|
||||
win.location = CLIENT_REDIRECT;
|
||||
});
|
||||
|
||||
found = received.find((data) => (data.event == "onCommitted" && data.url == REDIRECTED));
|
||||
|
||||
ok(found, "Got the onCommitted event");
|
||||
|
||||
if (found) {
|
||||
is(found.details.transitionType, "link",
|
||||
"Got the expected 'link' transitionType in the OnCommitted event");
|
||||
ok(Array.isArray(found.details.transitionQualifiers) &&
|
||||
found.details.transitionQualifiers.find((q) => q == "client_redirect"),
|
||||
"Got the expected 'client_redirect' transitionQualifiers in the OnCommitted events");
|
||||
}
|
||||
|
||||
// transitionQualifier: client_redirect
|
||||
// (from meta http-equiv tag)
|
||||
received = [];
|
||||
yield loadAndWait(win, "onCompleted", REDIRECTED, () => {
|
||||
win.location = CLIENT_REDIRECT_HTTPHEADER;
|
||||
});
|
||||
|
||||
found = received.find((data) => (data.event == "onCommitted" &&
|
||||
data.url == CLIENT_REDIRECT_HTTPHEADER));
|
||||
|
||||
ok(found, "Got the onCommitted event");
|
||||
|
||||
if (found) {
|
||||
is(found.details.transitionType, "link",
|
||||
"Got the expected 'link' transitionType in the OnCommitted event");
|
||||
ok(Array.isArray(found.details.transitionQualifiers) &&
|
||||
found.details.transitionQualifiers.find((q) => q == "client_redirect"),
|
||||
"Got the expected 'client_redirect' transitionQualifiers in the OnCommitted events");
|
||||
}
|
||||
|
||||
// cleanup phase
|
||||
win.close();
|
||||
|
||||
|
@ -67,9 +67,13 @@ var WebProgressListener = {
|
||||
this.previousURIMap.set(win, currentURI);
|
||||
}
|
||||
|
||||
// This WeakSet of DOMWindows keeps track of the attempted refresh.
|
||||
this.refreshAttemptedDOMWindows = new WeakSet();
|
||||
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW |
|
||||
Ci.nsIWebProgress.NOTIFY_REFRESH |
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION);
|
||||
},
|
||||
|
||||
@ -82,6 +86,13 @@ var WebProgressListener = {
|
||||
webProgress.removeProgressListener(this);
|
||||
},
|
||||
|
||||
onRefreshAttempted: function onRefreshAttempted(webProgress, URI, delay, sameURI) {
|
||||
this.refreshAttemptedDOMWindows.add(webProgress.DOMWindow);
|
||||
|
||||
// If this function doesn't return true, the attempted refresh will be blocked.
|
||||
return true;
|
||||
},
|
||||
|
||||
onStateChange: function onStateChange(webProgress, request, stateFlags, status) {
|
||||
let {originalURI, URI: locationURI} = request.QueryInterface(Ci.nsIChannel);
|
||||
|
||||
@ -227,11 +238,19 @@ var WebProgressListener = {
|
||||
frameTransitionData.form_submit = true;
|
||||
}
|
||||
|
||||
if (this.refreshAttemptedDOMWindows.has(DOMWindow)) {
|
||||
this.refreshAttemptedDOMWindows.delete(DOMWindow);
|
||||
frameTransitionData.client_redirect = true;
|
||||
}
|
||||
|
||||
return frameTransitionData;
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]),
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIWebProgressListener,
|
||||
Ci.nsIWebProgressListener2,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
};
|
||||
|
||||
var disabled = false;
|
||||
|
Loading…
Reference in New Issue
Block a user