Bug 1332595 - remove obsolete click handling hacks from browser.js, r?Mossop
MozReview-Commit-ID: 1BeeU0zJnXF
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2843,34 +2843,16 @@ var BrowserOnClick = {
case "captive-portal-login-success":
// Broadcast when a captive portal is freed so that error pages
// can refresh themselves.
window.messageManager.broadcastAsyncMessage("Browser:CaptivePortalFreed");
break;
}
},
- handleEvent(event) {
- if (!event.isTrusted || // Don't trust synthetic events
- event.button == 2) {
- return;
- }
-
- let originalTarget = event.originalTarget;
- let ownerDoc = originalTarget.ownerDocument;
- if (!ownerDoc) {
- return;
- }
-
- if (gMultiProcessBrowser &&
- ownerDoc.documentURI.toLowerCase() == "about:newtab") {
- this.onE10sAboutNewTab(event, ownerDoc);
- }
- },
-
receiveMessage(msg) {
switch (msg.name) {
case "Browser:CertExceptionError":
this.onCertError(msg.target, msg.data.elementId,
msg.data.isTopFrame, msg.data.location,
msg.data.securityInfoAsString);
break;
case "Browser:OpenCaptivePortalPage":
@@ -3054,38 +3036,16 @@ var BrowserOnClick = {
secHistogram.add(nsISecTel[bucketName + "IGNORE_WARNING"]);
}
this.ignoreWarningButton(reason);
}
break;
}
},
- /**
- * This functions prevents navigation from happening directly through the <a>
- * link in about:newtab (which is loaded in the parent and therefore would load
- * the next page also in the parent) and instructs the browser to open the url
- * in the current tab which will make it update the remoteness of the tab.
- */
- onE10sAboutNewTab(event, ownerDoc) {
- let isTopFrame = (ownerDoc.defaultView.parent === ownerDoc.defaultView);
- if (!isTopFrame) {
- return;
- }
-
- let anchorTarget = event.originalTarget.parentNode;
-
- if (anchorTarget instanceof HTMLAnchorElement &&
- anchorTarget.classList.contains("newtab-link")) {
- event.preventDefault();
- let where = whereToOpenLink(event, false, false);
- openLinkIn(anchorTarget.href, where, { charset: ownerDoc.characterSet, referrerURI: ownerDoc.documentURIObject });
- }
- },
-
ignoreWarningButton(reason) {
// Allow users to override and continue through to the site,
// but add a notify bar as a reminder, so that they don't lose
// track after, e.g., tab switching.
gBrowser.loadURIWithFlags(gBrowser.currentURI.spec,
nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
null, null, null);
@@ -4880,48 +4840,16 @@ var TabsProgressListener = {
}
} else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
aStatus == Cr.NS_BINDING_ABORTED &&
this._startedLoadTimer.has(aBrowser)) {
this._startedLoadTimer.delete(aBrowser);
TelemetryStopwatch.cancel("FX_PAGE_LOAD_MS", aBrowser);
}
}
-
- // Attach a listener to watch for "click" events bubbling up from error
- // pages and other similar pages (like about:newtab). This lets us fix bugs
- // like 401575 which require error page UI to do privileged things, without
- // letting error pages have any privilege themselves.
- // We can't look for this during onLocationChange since at that point the
- // document URI is not yet the about:-uri of the error page.
-
- let isRemoteBrowser = aBrowser.isRemoteBrowser;
- // We check isRemoteBrowser here to avoid requesting the doc CPOW
- let doc = isRemoteBrowser ? null : aWebProgress.DOMWindow.document;
-
- if (!isRemoteBrowser &&
- aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
- Components.isSuccessCode(aStatus) &&
- doc.documentURI.startsWith("about:") &&
- !doc.documentURI.toLowerCase().startsWith("about:blank") &&
- !doc.documentURI.toLowerCase().startsWith("about:home") &&
- !doc.documentElement.hasAttribute("hasBrowserHandlers")) {
- // STATE_STOP may be received twice for documents, thus store an
- // attribute to ensure handling it just once.
- doc.documentElement.setAttribute("hasBrowserHandlers", "true");
- aBrowser.addEventListener("click", BrowserOnClick, true);
- aBrowser.addEventListener("pagehide", function onPageHide(event) {
- if (event.target.defaultView.frameElement)
- return;
- aBrowser.removeEventListener("click", BrowserOnClick, true);
- aBrowser.removeEventListener("pagehide", onPageHide, true);
- if (event.target.documentElement)
- event.target.documentElement.removeAttribute("hasBrowserHandlers");
- }, true);
- }
},
onLocationChange(aBrowser, aWebProgress, aRequest, aLocationURI,
aFlags) {
// Filter out location changes caused by anchor navigation
// or history.push/pop/replaceState.
if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
// Reader mode actually cares about these:
--- a/layout/base/tests/test_reftests_with_caret.html
+++ b/layout/base/tests/test_reftests_with_caret.html
@@ -61,16 +61,17 @@ const MAX_ITERATIONS = 1000;
function createIframe(url,next) {
var iframe = document.createElement("iframe");
iframe.src = url;
iframe.remotePageLoaded = remotePageLoaded;
var me = this;
var currentIteration = 0;
function iframeLoadCompleted() {
+ iframe.focus();
var docEl = iframe.contentDocument.documentElement;
if (docEl.className.indexOf("reftest-wait") >= 0) {
if (currentIteration++ > MAX_ITERATIONS) {
ok(false, "iframe load for " + url + " timed out");
endTest();
} else {
setTimeout(iframeLoadCompleted, 0);
}
@@ -79,17 +80,16 @@ function createIframe(url,next) {
iframe.remotePageLoaded(function() {
if (next) {
setTimeout(function(){createIframe(next,null);}, 0)
}
});
}
iframe.addEventListener("load", iframeLoadCompleted);
window.document.body.appendChild(iframe);
- iframe.focus();
};
function refTest(test,ref) {
createIframe(test,ref);
};
var caretBlinkTime = null;
function endTest() {
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul
@@ -32,52 +32,58 @@
// Load the given file into the frame, then copy+paste the entire frame and
// check that the cut text matches what we expect.
function test(aFilename, aExpected, aNext) {
let frame = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe")
frame.height = 300;
frame.src = "about:memory?file=" + makePathname(aFilename);
document.documentElement.appendChild(frame);
- frame.focus();
+ frame.addEventListener("load", function onFrameLoad(e) {
+ if (frame.location && frame.location.href != "about:blank") {
+ return;
+ }
+ frame.removeEventListener("load", onFrameLoad);
+ frame.focus();
- // Initialize the clipboard contents.
- SpecialPowers.clipboardCopyString("initial clipboard value");
+ // Initialize the clipboard contents.
+ SpecialPowers.clipboardCopyString("initial clipboard value");
- let numFailures = 0, maxFailures = 30;
+ let numFailures = 0, maxFailures = 30;
- // Because the file load is async, we don't know when it will finish and
- // the output will show up. So we poll.
- function copyPasteAndCheck() {
- // Copy and paste frame contents, and filter out non-deterministic
- // differences.
- synthesizeKey("A", {accelKey: true});
- synthesizeKey("C", {accelKey: true});
- let actual = SpecialPowers.getClipboardData("text/unicode");
- actual = actual.replace(/\(pid \d+\)/, "(pid NNN)");
+ // Because the file load is async, we don't know when it will finish and
+ // the output will show up. So we poll.
+ function copyPasteAndCheck() {
+ // Copy and paste frame contents, and filter out non-deterministic
+ // differences.
+ synthesizeKey("A", {accelKey: true});
+ synthesizeKey("C", {accelKey: true});
+ let actual = SpecialPowers.getClipboardData("text/unicode");
+ actual = actual.replace(/\(pid \d+\)/, "(pid NNN)");
- if (actual.trim() === aExpected.trim()) {
- SimpleTest.ok(true, "Clipboard has the expected contents");
- aNext();
- } else {
- numFailures++;
- if (numFailures === maxFailures) {
- ok(false, "pasted text doesn't match");
- dump("******EXPECTED******\n");
- dump(aExpected);
- dump("*******ACTUAL*******\n");
- dump(actual);
- dump("********************\n");
- SimpleTest.finish();
+ if (actual.trim() === aExpected.trim()) {
+ SimpleTest.ok(true, "Clipboard has the expected contents");
+ aNext();
} else {
- setTimeout(copyPasteAndCheck, 100);
+ numFailures++;
+ if (numFailures === maxFailures) {
+ ok(false, "pasted text doesn't match");
+ dump("******EXPECTED******\n");
+ dump(aExpected);
+ dump("*******ACTUAL*******\n");
+ dump(actual);
+ dump("********************\n");
+ SimpleTest.finish();
+ } else {
+ setTimeout(copyPasteAndCheck, 100);
+ }
}
}
- }
- copyPasteAndCheck();
+ copyPasteAndCheck();
+ });
}
// Returns a function that chains together multiple test() calls.
function chain(aFrameIds) {
let x = aFrameIds.shift();
if (x) {
return function() { test(x.filename, x.expected, chain(aFrameIds)); }
} else {