mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1199934 - page shouldn't be able to trap/revert the location bar by hash/replacestate changes, r=jaws
MozReview-Commit-ID: HsmmHsUtU0h --HG-- extra : rebase_source : 85dee8cf0ebcf67fd7c0fb6e6936217d8b3fc0ae
This commit is contained in:
parent
3bc93889a9
commit
32bc4f6864
@ -758,11 +758,11 @@
|
||||
// if the error page's URI is about:blank, because that causes complete
|
||||
// loss of urlbar contents for invalid URI errors (see bug 867957).
|
||||
// Another reason to clear the userTypedValue is if this was an anchor
|
||||
// navigation.
|
||||
// navigation initiated by the user.
|
||||
if (this.mBrowser.userTypedClear > 0 ||
|
||||
((aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) &&
|
||||
aLocation.spec != "about:blank") ||
|
||||
isSameDocument) {
|
||||
(isSameDocument && this.mBrowser.inLoadURI)) {
|
||||
this.mBrowser.userTypedValue = null;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
[browser_urlbar_blanking.js]
|
||||
support-files =
|
||||
file_blank_but_not_blank.html
|
||||
[browser_urlbar_locationchange_urlbar_edit_dos.js]
|
||||
support-files =
|
||||
file_urlbar_edit_dos.html
|
||||
[browser_urlbar_stop_pending.js]
|
||||
support-files =
|
||||
slow-page.sjs
|
||||
|
@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
function* checkURLBarValueStays(browser) {
|
||||
gURLBar.select();
|
||||
EventUtils.synthesizeKey("a", {});
|
||||
is(gURLBar.value, "a", "URL bar value should match after sending a key");
|
||||
yield new Promise(resolve => {
|
||||
let listener = {
|
||||
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
|
||||
ok(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT,
|
||||
"Should only get a same document location change");
|
||||
gBrowser.selectedBrowser.removeProgressListener(filter);
|
||||
filter = null;
|
||||
resolve();
|
||||
},
|
||||
};
|
||||
let filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
|
||||
.createInstance(Ci.nsIWebProgress);
|
||||
filter.addProgressListener(listener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
gBrowser.selectedBrowser.addProgressListener(filter);
|
||||
});
|
||||
is(gURLBar.value, "a", "URL bar should not have been changed by location changes.");
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: "http://example.com/browser/browser/base/content/test/urlbar/file_urlbar_edit_dos.html"
|
||||
}, function*(browser) {
|
||||
yield ContentTask.spawn(browser, "", function() {
|
||||
content.wrappedJSObject.dos_hash();
|
||||
});
|
||||
yield checkURLBarValueStays(browser);
|
||||
yield ContentTask.spawn(browser, "", function() {
|
||||
content.clearTimeout(content.wrappedJSObject.dos_timeout);
|
||||
content.wrappedJSObject.dos_pushState();
|
||||
});
|
||||
yield checkURLBarValueStays(browser);
|
||||
});
|
||||
});
|
||||
|
23
browser/base/content/test/urlbar/file_urlbar_edit_dos.html
Normal file
23
browser/base/content/test/urlbar/file_urlbar_edit_dos.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Try editing the URL bar</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var dos_timeout = null;
|
||||
function dos_hash() {
|
||||
dos_timeout = setTimeout(function() {
|
||||
location.hash = "#";
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function dos_pushState() {
|
||||
dos_timeout = setTimeout(function() {
|
||||
history.pushState({}, "Some title", "");
|
||||
}, 50);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -130,9 +130,9 @@ var WebProgressListener = {
|
||||
json.documentURI = content.document.documentURIObject.spec;
|
||||
json.charset = content.document.characterSet;
|
||||
json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
|
||||
json.inLoadURI = WebNavigation.inLoadURI;
|
||||
}
|
||||
|
||||
json.inLoadURI = WebNavigation.inLoadURI;
|
||||
this._send("Content:StateChange", json, objects);
|
||||
},
|
||||
|
||||
@ -171,6 +171,7 @@ var WebProgressListener = {
|
||||
json.mayEnableCharacterEncodingMenu = docShell.mayEnableCharacterEncodingMenu;
|
||||
json.principal = content.document.nodePrincipal;
|
||||
json.synthetic = content.document.mozSyntheticDocument;
|
||||
json.inLoadURI = WebNavigation.inLoadURI;
|
||||
|
||||
if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled) {
|
||||
let uri = aLocationURI.clone();
|
||||
|
@ -220,7 +220,9 @@ RemoteWebProgressManager.prototype = {
|
||||
if (isTopLevel) {
|
||||
this._browser._contentWindow = objects.contentWindow;
|
||||
this._browser._documentContentType = json.documentContentType;
|
||||
this._browser.inLoadURI = json.inLoadURI;
|
||||
if (typeof json.inLoadURI != "undefined") {
|
||||
this._browser.inLoadURI = json.inLoadURI;
|
||||
}
|
||||
if (json.charset) {
|
||||
this._browser._characterSet = json.charset;
|
||||
this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
|
||||
|
Loading…
Reference in New Issue
Block a user