diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 01d1bc02db8a..7097e95bbc1c 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1291,9 +1291,6 @@ var gBrowserInit = { gBrowserThumbnails.init(); - // Add Devtools menuitems and listeners - gDevToolsBrowser.registerBrowserWindow(window); - gMenuButtonBadgeManager.init(); gMenuButtonUpdateBadge.init(); @@ -1407,8 +1404,6 @@ var gBrowserInit = { if (!this._loadHandled) return; - gDevToolsBrowser.forgetBrowserWindow(window); - let desc = Object.getOwnPropertyDescriptor(window, "DeveloperToolbar"); if (desc && !desc.get) { DeveloperToolbar.destroy(); @@ -2702,8 +2697,7 @@ var BrowserOnClick = { break; case "Browser:SendSSLErrorReport": this.onSSLErrorReport(msg.target, - msg.data.documentURI, - msg.data.location, + msg.data.uri, msg.data.securityInfo); break; case "Browser:SetSSLErrorReportAuto": @@ -2723,7 +2717,7 @@ var BrowserOnClick = { let weakCryptoOverride = Cc["@mozilla.org/security/weakcryptooverride;1"] .getService(Ci.nsIWeakCryptoOverride); weakCryptoOverride.addWeakCryptoOverride( - msg.data.location.hostname, + msg.data.uri.host, PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)); break; case "Browser:SSLErrorGoBack": @@ -2732,7 +2726,7 @@ var BrowserOnClick = { } }, - onSSLErrorReport: function(browser, documentURI, location, securityInfo) { + onSSLErrorReport: function(browser, uri, securityInfo) { if (!Services.prefs.getBoolPref("security.ssl.errorReporting.enabled")) { Cu.reportError("User requested certificate error report sending, but certificate error reporting is disabled"); return; @@ -2745,11 +2739,8 @@ var BrowserOnClick = { let errorReporter = Cc["@mozilla.org/securityreporter;1"] .getService(Ci.nsISecurityReporter); - // if location.port is the empty string, set to -1 (for consistency with - // port values from nsIURI) - let port = location.port === "" ? -1 : location.port; errorReporter.reportTLSError(transportSecurityInfo, - location.hostname, port); + uri.host, uri.port); }, onAboutCertError: function (browser, elementId, isTopFrame, location, securityInfoAsString) { @@ -6543,6 +6534,10 @@ var gIdentityHandler = { return this._state & Ci.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT; }, + get _isCertUserOverridden() { + return this._state & Ci.nsIWebProgressListener.STATE_CERT_USER_OVERRIDDEN; + }, + get _hasInsecureLoginForms() { // checks if the page has been flagged for an insecure login. Also checks // if the pref to degrade the UI is set to true @@ -6832,23 +6827,14 @@ var gIdentityHandler = { if (this._isMixedActiveContentBlocked) { this._identityBox.classList.add("mixedActiveBlocked"); } - - let iData = this.getIdentityData(); - - // Verifier is either the CA Org, for a normal cert, or a special string - // for certs that are trusted because of a security exception. - tooltip = gNavigatorBundle.getFormattedString("identity.identified.verifier", - [iData.caOrg]); - - let host = this._uri.host; - let port = 443; - try { - if (this._uri.port > 0) - port = this._uri.port; - } catch (e) {} - - if (this._overrideService.hasMatchingOverride(host, port, iData.cert, {}, {})) { + if (this._isCertUserOverridden) { + this._identityBox.classList.add("certUserOverridden"); + // Cert is trusted because of a security exception, verifier is a special string. tooltip = gNavigatorBundle.getString("identity.identified.verified_by_you"); + } else { + // It's a normal cert, verifier is the CA Org. + tooltip = gNavigatorBundle.getFormattedString("identity.identified.verifier", + [this.getIdentityData().caOrg]); } } else { this._identityBox.className = "unknownIdentity"; @@ -6952,6 +6938,8 @@ var gIdentityHandler = { connection = "file"; } else if (this._isEV) { connection = "secure-ev"; + } else if (this._isCertUserOverridden) { + connection = "secure-cert-user-overridden"; } else if (this._isSecure) { connection = "secure"; } diff --git a/browser/base/content/content.js b/browser/base/content/content.js index a96032737587..30ef38b48039 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -99,7 +99,8 @@ var handleContentContextMenu = function (event) { Services.obs.notifyObservers(subject, "content-contextmenu", null); let doc = event.target.ownerDocument; - let docLocation = doc.location ? doc.location.href : undefined; + let docLocation = doc.mozDocumentURIIfNotForErrorPages; + docLocation = docLocation && docLocation.spec; let charSet = doc.characterSet; let baseURI = doc.baseURI; let referrer = doc.referrer; @@ -276,9 +277,6 @@ var AboutCertErrorListener = { // if we're enabling reports, send a report for this failure if (event.detail) { - let doc = content.document; - let location = doc.location.href; - let serhelper = Cc["@mozilla.org/network/serialization-helper;1"] .getService(Ci.nsISerializationHelper); @@ -288,9 +286,9 @@ var AboutCertErrorListener = { let serializedSecurityInfo = serhelper.serializeToString(serializable); + let {host, port} = content.document.mozDocumentURIIfNotForErrorPages; sendAsyncMessage("Browser:SendSSLErrorReport", { - documentURI: doc.documentURI, - location: {hostname: doc.location.hostname, port: doc.location.port}, + uri: { host, port }, securityInfo: serializedSecurityInfo }); } @@ -349,10 +347,6 @@ var AboutNetErrorListener = { // if we're enabling reports, send a report for this failure if (evt.detail) { - let contentDoc = content.document; - - let location = contentDoc.location.href; - let serhelper = Cc["@mozilla.org/network/serialization-helper;1"] .getService(Ci.nsISerializationHelper); @@ -362,12 +356,9 @@ var AboutNetErrorListener = { let serializedSecurityInfo = serhelper.serializeToString(serializable); + let {host, port} = content.document.mozDocumentURIIfNotForErrorPages; sendAsyncMessage("Browser:SendSSLErrorReport", { - documentURI: contentDoc.documentURI, - location: { - hostname: contentDoc.location.hostname, - port: contentDoc.location.port - }, + uri: { host, port }, securityInfo: serializedSecurityInfo }); @@ -375,13 +366,8 @@ var AboutNetErrorListener = { }, onOverride: function(evt) { - let contentDoc = content.document; - let location = contentDoc.location; - - sendAsyncMessage("Browser:OverrideWeakCrypto", { - documentURI: contentDoc.documentURI, - location: {hostname: location.hostname, port: location.port} - }); + let {host, port} = content.document.mozDocumentURIIfNotForErrorPages; + sendAsyncMessage("Browser:OverrideWeakCrypto", { uri: {host, port} }); } } diff --git a/browser/base/content/sanitize.js b/browser/base/content/sanitize.js index 943ff31f4d9f..58e6e615efdb 100644 --- a/browser/base/content/sanitize.js +++ b/browser/base/content/sanitize.js @@ -688,8 +688,9 @@ Sanitizer.PREF_SANITIZE_ON_SHUTDOWN = "privacy.sanitize.sanitizeOnShutdown"; // by a crash. Sanitizer.PREF_SANITIZE_IN_PROGRESS = "privacy.sanitize.sanitizeInProgress"; // Whether the previous shutdown sanitization completed successfully. -// Note that PREF_SANITIZE_IN_PROGRESS would be enough to detect an interrupted -// sanitization, but this is still supported for backwards compatibility. +// This is used to detect cases where we were supposed to sanitize on shutdown +// but due to a crash we were unable to. In such cases there may not be any +// sanitization in progress, cause we didn't have a chance to start it yet. Sanitizer.PREF_SANITIZE_DID_SHUTDOWN = "privacy.sanitize.didShutdownSanitize"; // Time span constants corresponding to values of the privacy.sanitize.timeSpan @@ -779,10 +780,14 @@ Sanitizer.onStartup = Task.async(function*() { let shutownSanitizationWasInterrupted = Preferences.get(Sanitizer.PREF_SANITIZE_ON_SHUTDOWN, false) && !Preferences.has(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN); - // Regardless, reset the pref, since we want to check it at the next startup - // even if the browser exits abruptly. - Preferences.reset(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN); - Services.prefs.savePrefFile(null); + + if (Preferences.has(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN)) { + // Reset the pref, so that if we crash before having a chance to + // sanitize on shutdown, we will do at the next startup. + // Flushing prefs has a cost, so do this only if necessary. + Preferences.reset(Sanitizer.PREF_SANITIZE_DID_SHUTDOWN); + Services.prefs.savePrefFile(null); + } // Make sure that we are triggered during shutdown, at the right time, // and only once. @@ -804,7 +809,7 @@ Sanitizer.onStartup = Task.async(function*() { } placesClient.addBlocker("sanitize.js: Sanitize on shutdown", doSanitize); - // Check if Firefox crashed before completing a sanitization. + // Check if Firefox crashed during a sanitization. let lastInterruptedSanitization = Preferences.get(Sanitizer.PREF_SANITIZE_IN_PROGRESS, ""); if (lastInterruptedSanitization) { let s = new Sanitizer(); @@ -812,11 +817,9 @@ Sanitizer.onStartup = Task.async(function*() { let itemsToClear = JSON.parse(lastInterruptedSanitization); yield s.sanitize(itemsToClear); } else if (shutownSanitizationWasInterrupted) { - // Ideally lastInterruptedSanitization should always be set when a - // sanitization is interrupted, but some add-ons or Firefox previous - // versions may not set the pref. - // In such a case, we can still detect an interrupted shutdown sanitization, - // and just redo it. + // Otherwise, could be we were supposed to sanitize on shutdown but we + // didn't have a chance, due to an earlier crash. + // In such a case, just redo a shutdown sanitize now, during startup. yield Sanitizer.onShutdown(); } }); diff --git a/browser/base/content/social-content.js b/browser/base/content/social-content.js index bea71cb7c43e..fc8fd88b4bb6 100644 --- a/browser/base/content/social-content.js +++ b/browser/base/content/social-content.js @@ -64,6 +64,11 @@ SocialErrorListener = { }, receiveMessage(message) { + if (!content) { + Cu.reportError("Message received whilst `content` is null: " + message.name); + return; + } + let document = content.document; switch (message.name) { diff --git a/browser/base/content/test/chat/browser_chatwindow.js b/browser/base/content/test/chat/browser_chatwindow.js index 9cb3c9ce6e17..94f4bc5749d8 100644 --- a/browser/base/content/test/chat/browser_chatwindow.js +++ b/browser/base/content/test/chat/browser_chatwindow.js @@ -4,6 +4,8 @@ Components.utils.import("resource://gre/modules/Promise.jsm", this); +requestLongerTimeout(2); + var chatbar = document.getElementById("pinnedchats"); add_chat_task(function* testOpenCloseChat() { diff --git a/browser/base/content/test/chat/browser_focus.js b/browser/base/content/test/chat/browser_focus.js index 2fd80cae0ae1..2f7fae78f836 100644 --- a/browser/base/content/test/chat/browser_focus.js +++ b/browser/base/content/test/chat/browser_focus.js @@ -7,6 +7,8 @@ Components.utils.import("resource://gre/modules/Promise.jsm", this); const CHAT_URL = "https://example.com/browser/browser/base/content/test/chat/chat.html"; +requestLongerTimeout(2); + // Is the currently opened tab focused? function isTabFocused() { let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab); diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 6e81e3d8bda7..21233191bdf8 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -155,6 +155,7 @@ skip-if = os == "mac" # The Fitt's Law back button is not supported on OS X [browser_beforeunload_duplicate_dialogs.js] [browser_blob-channelname.js] [browser_bookmark_popup.js] +skip-if = (os == "linux" && debug) # mouseover not reliable on linux debug builds [browser_bookmark_titles.js] skip-if = buildapp == 'mulet' || toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341) [browser_bug304198.js] diff --git a/browser/base/content/test/general/browser_addCertException.js b/browser/base/content/test/general/browser_addCertException.js index dcf6f10241be..df9ea5c8ae73 100644 --- a/browser/base/content/test/general/browser_addCertException.js +++ b/browser/base/content/test/general/browser_addCertException.js @@ -8,7 +8,7 @@ // a bad certificate, being redirected to the internal about:certerror page, // using the button contained therein to load the certificate exception // dialog, using that to add an exception, and finally successfully visiting -// the site. +// the site, including showing the right identity box and control center icons. function test() { waitForExplicitFinish(); whenNewTabLoaded(window, loadBadCertPage); @@ -67,6 +67,7 @@ var certExceptionDialogObserver = { var successfulLoadListener = { handleEvent: function() { gBrowser.selectedBrowser.removeEventListener("load", this, true); + checkControlPanelIcons(); let certOverrideService = Cc["@mozilla.org/security/certoverride;1"] .getService(Ci.nsICertOverrideService); certOverrideService.clearValidityOverride("expired.example.com", -1); @@ -75,6 +76,35 @@ var successfulLoadListener = { } }; +// Check for the correct icons in the identity box and control center. +function checkControlPanelIcons() { + let { gIdentityHandler } = gBrowser.ownerGlobal; + gIdentityHandler._identityBox.click(); + document.getElementById("identity-popup-security-expander").click(); + + is_element_visible(document.getElementById("connection-icon")); + let connectionIconImage = gBrowser.ownerGlobal + .getComputedStyle(document.getElementById("connection-icon"), "") + .getPropertyValue("list-style-image"); + let securityViewBG = gBrowser.ownerGlobal + .getComputedStyle(document.getElementById("identity-popup-securityView"), "") + .getPropertyValue("background-image"); + let securityContentBG = gBrowser.ownerGlobal + .getComputedStyle(document.getElementById("identity-popup-security-content"), "") + .getPropertyValue("background-image"); + is(connectionIconImage, + "url(\"chrome://browser/skin/identity-mixed-passive-loaded.svg\")", + "Using expected icon image in the identity block"); + is(securityViewBG, + "url(\"chrome://browser/skin/identity-mixed-passive-loaded.svg\")", + "Using expected icon image in the Control Center main view"); + is(securityContentBG, + "url(\"chrome://browser/skin/identity-mixed-passive-loaded.svg\")", + "Using expected icon image in the Control Center subview"); + + gIdentityHandler._identityPopup.hidden = true; +} + // Utility function to get a handle on the certificate exception dialog. // Modified from toolkit/components/passwordmgr/test/prompt_common.js function getDialog(aLocation) { diff --git a/browser/components/controlcenter/content/panel.inc.xul b/browser/components/controlcenter/content/panel.inc.xul index 6623c71f0c84..841bed398ef9 100644 --- a/browser/components/controlcenter/content/panel.inc.xul +++ b/browser/components/controlcenter/content/panel.inc.xul @@ -25,7 +25,7 @@