mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
18efcca64b
- Bug 1134800 - Properly cache file matching patterns; r=glandium (0c65935e9) - Bug 1136177 - Amount by mouse wheel scrolling is wrong. r=jimm (6cd8824a3) - Bug 1055369 - Assertion failure: !handle || !handle->IsDoomed(). r=honzab (696f6d801) - Bug 1132728 - Don't draw focus rings on b2g. r=fabrice,bz (0bf2719a2) - Bug 1133201 - part 1 - treat null links in BrowserUtils.linkHasNoReferrer as specifying rel="noreferrer"; r=Gijs,mconley (97031e93c) - Bug 906190 - Persist 'disable protection' option for Mixed Content Blocker in child tabs - tabbrowser part. r=gavin (7467fee83) - Bug 947895 - [e10s] Null check browser.docShell in context-menu Open in new tab. r=gavin (5236b883e) - Bug 1038604 - Rename disableMCB to allowMixedContent. r=dao (2df2b924b) - Bug 1151349 - Make lldb ns(Int)Region summary handle the numRects==0 case. r=jrmuizel (19be5e2c0) - Bug 1146585 - Add a test for Cache.delete; r=bkelly (db28bcc13) - Bug 899222 - Make about:home work via message passing (r=felipe) Bug 900865: Make about:home call nsISearchEngine.getSubmission for all searches. r=gavin (15f8ae2f8) - Bug 910523 - about:home now takes into account async startup of SessionRestore;r=felipe (ceaa0687c) - Bug 927132 - Fix about:home in e10s (r=mdeboer) (53c586ee2) - Bug 897062 - Handle special clicks in e10s. r=felipe,smaug (7ec4573c8) - Bug 899348 - Implement about:tabcrashed page. r=jaws (547bb3e7c) - Bug 899348 - Dispatch an event when an out-of-process browser crashes and display an error page when that occurs (missing parts) (88c87ce75) - Bug 897066 - In e10s builds, some pages should be loaded in the chrome process (r=gavin) (4cc0f8ed5) - Bug 1038811 - Push Notifications - WebIDL changes. r=nsm. sr=jst (2ed030bf3) - Bug 1038811 - Push Notifications - ServiceWorker changes, push event implementation. r=nsm (6313c8c10) - reinstantiate file as of 2015-02-05 (7f12724c8) - Bug 1038811 - Push Notifications - Tests. r=nsm (cbac31308) - Bug 1038811 - Push Notifications - Allow MOZ_DISABLE_NONLOCAL_CONNECTIONS for push subsuite. r=ahalberstadt/jgriffin (859e182ce) - Bug 1038811 - Push Notifications - Push implementation changes. r=nsm (161a739f4) - Bug 898170 - Avoid swapping docshells in e10s mode (r=felipe) (55e96d59a) - Bug 862078 - Use an about:config preference to control multiprocess browsing, part 2 (r=felipe) [missing bits] (9fac04b17) - Bug 666809 - Support SecurityUI in e10s mode. r=felipe f=gavin [missing bits] (0e7aa1368) - Bug 691610 - e10s support for useDefaultIcon. r=felipe sr=smaug (cbf7e5341) - Bug 897066 - Underline tab titles if the tab is remote (r=gavin) [+ followup fix] (2eda1d81e) - Bug 899348 - Make reload of the about:tabcrashed work as expected. r=jaws (72843ef8f) - Bug 1133846 - Add missing arguments to logging call in ActivateTimeoutTick. r=mcmanus (a784a7ce8) - Bug 1135682 - Do not update the all MediaStreamGraph if it's not dirty, r=padenot (49eeeeef5) - Bug 1135255 - Fix mozdevice tempfile handling on Windows. r=gbrown (53a2353bd) - Bug 1134735 - Don't use tee->InitAsync in nsHttpChannel::InstallCacheListener when using cache2, r=michal (3fa833982) - Bug 1132081 - Speed up ConvertHostARGBRow() in the PNG encoder. r=jmuizelaar (6b7890586) - pointer style before patch (3336fab8f) - Bug 1135100 - Don't update GC thing pointers that haven't changed after marking r=terrence (0df3ea820)
236 lines
7.8 KiB
JavaScript
236 lines
7.8 KiB
JavaScript
/* -*- mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
this.EXPORTED_SYMBOLS = [ "BrowserUtils" ];
|
|
|
|
const {interfaces: Ci, utils: Cu, classes: Cc} = Components;
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
this.BrowserUtils = {
|
|
|
|
/**
|
|
* Prints arguments separated by a space and appends a new line.
|
|
*/
|
|
dumpLn: function (...args) {
|
|
for (let a of args)
|
|
dump(a + " ");
|
|
dump("\n");
|
|
},
|
|
|
|
/**
|
|
* urlSecurityCheck: JavaScript wrapper for checkLoadURIWithPrincipal
|
|
* and checkLoadURIStrWithPrincipal.
|
|
* If |aPrincipal| is not allowed to link to |aURL|, this function throws with
|
|
* an error message.
|
|
*
|
|
* @param aURL
|
|
* The URL a page has linked to. This could be passed either as a string
|
|
* or as a nsIURI object.
|
|
* @param aPrincipal
|
|
* The principal of the document from which aURL came.
|
|
* @param aFlags
|
|
* Flags to be passed to checkLoadURIStr. If undefined,
|
|
* nsIScriptSecurityManager.STANDARD will be passed.
|
|
*/
|
|
urlSecurityCheck: function(aURL, aPrincipal, aFlags) {
|
|
var secMan = Services.scriptSecurityManager;
|
|
if (aFlags === undefined) {
|
|
aFlags = secMan.STANDARD;
|
|
}
|
|
|
|
try {
|
|
if (aURL instanceof Ci.nsIURI)
|
|
secMan.checkLoadURIWithPrincipal(aPrincipal, aURL, aFlags);
|
|
else
|
|
secMan.checkLoadURIStrWithPrincipal(aPrincipal, aURL, aFlags);
|
|
} catch (e) {
|
|
let principalStr = "";
|
|
try {
|
|
principalStr = " from " + aPrincipal.URI.spec;
|
|
}
|
|
catch(e2) { }
|
|
|
|
throw "Load of " + aURL + principalStr + " denied.";
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Constructs a new URI, using nsIIOService.
|
|
* @param aURL The URI spec.
|
|
* @param aOriginCharset The charset of the URI.
|
|
* @param aBaseURI Base URI to resolve aURL, or null.
|
|
* @return an nsIURI object based on aURL.
|
|
*/
|
|
makeURI: function(aURL, aOriginCharset, aBaseURI) {
|
|
return Services.io.newURI(aURL, aOriginCharset, aBaseURI);
|
|
},
|
|
|
|
makeFileURI: function(aFile) {
|
|
return Services.io.newFileURI(aFile);
|
|
},
|
|
|
|
makeURIFromCPOW: function(aCPOWURI) {
|
|
return Services.io.newURI(aCPOWURI.spec, aCPOWURI.originCharset, null);
|
|
},
|
|
|
|
/**
|
|
* Return the current focus element and window. If the current focus
|
|
* is in a content process, then this function returns CPOWs
|
|
* (cross-process object wrappers) that refer to the focused
|
|
* items. Note that calling this function synchronously contacts the
|
|
* content process, which may block for a long time.
|
|
*
|
|
* @param document The document in question.
|
|
* @return [focusedElement, focusedWindow]
|
|
*/
|
|
getFocusSync: function(document) {
|
|
let elt = document.commandDispatcher.focusedElement;
|
|
var window = document.commandDispatcher.focusedWindow;
|
|
|
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
if (elt instanceof window.XULElement &&
|
|
elt.localName == "browser" &&
|
|
elt.namespaceURI == XUL_NS &&
|
|
elt.getAttribute("remote")) {
|
|
[elt, window] = elt.syncHandler.getFocusedElementAndWindow();
|
|
}
|
|
|
|
return [elt, window];
|
|
},
|
|
|
|
/**
|
|
* For a given DOM element, returns its position in "screen"
|
|
* coordinates. In a content process, the coordinates returned will
|
|
* be relative to the left/top of the tab. In the chrome process,
|
|
* the coordinates are relative to the user's screen.
|
|
*/
|
|
getElementBoundingScreenRect: function(aElement) {
|
|
let rect = aElement.getBoundingClientRect();
|
|
let window = aElement.ownerDocument.defaultView;
|
|
|
|
// We need to compensate for any iframes that might shift things
|
|
// over. We also need to compensate for zooming.
|
|
let fullZoom = window.getInterface(Ci.nsIDOMWindowUtils).fullZoom;
|
|
rect = {
|
|
left: (rect.left + window.mozInnerScreenX) * fullZoom,
|
|
top: (rect.top + window.mozInnerScreenY) * fullZoom,
|
|
width: rect.width * fullZoom,
|
|
height: rect.height * fullZoom
|
|
};
|
|
|
|
return rect;
|
|
},
|
|
|
|
/**
|
|
* Given an element potentially within a subframe, calculate the offsets
|
|
* up to the top level browser.
|
|
*
|
|
* @param aTopLevelWindow content window to calculate offsets to.
|
|
* @param aElement The element in question.
|
|
* @return [targetWindow, offsetX, offsetY]
|
|
*/
|
|
offsetToTopLevelWindow: function (aTopLevelWindow, aElement) {
|
|
let offsetX = 0;
|
|
let offsetY = 0;
|
|
let element = aElement;
|
|
while (element &&
|
|
element.ownerDocument &&
|
|
element.ownerDocument.defaultView != aTopLevelWindow) {
|
|
element = element.ownerDocument.defaultView.frameElement;
|
|
let rect = element.getBoundingClientRect();
|
|
offsetX += rect.left;
|
|
offsetY += rect.top;
|
|
}
|
|
let win = null;
|
|
if (element == aElement)
|
|
win = aTopLevelWindow;
|
|
else
|
|
win = element.contentDocument.defaultView;
|
|
return { targetWindow: win, offsetX: offsetX, offsetY: offsetY };
|
|
},
|
|
|
|
onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) {
|
|
// Don't modify non-default targets or targets that aren't in top-level app
|
|
// tab docshells (isAppTab will be false for app tab subframes).
|
|
if (originalTarget != "" || !isAppTab)
|
|
return originalTarget;
|
|
|
|
// External links from within app tabs should always open in new tabs
|
|
// instead of replacing the app tab's page (Bug 575561)
|
|
let linkHost;
|
|
let docHost;
|
|
try {
|
|
linkHost = linkURI.host;
|
|
docHost = linkNode.ownerDocument.documentURIObject.host;
|
|
} catch(e) {
|
|
// nsIURI.host can throw for non-nsStandardURL nsIURIs.
|
|
// If we fail to get either host, just return originalTarget.
|
|
return originalTarget;
|
|
}
|
|
|
|
if (docHost == linkHost)
|
|
return originalTarget;
|
|
|
|
// Special case: ignore "www" prefix if it is part of host string
|
|
let [longHost, shortHost] =
|
|
linkHost.length > docHost.length ? [linkHost, docHost] : [docHost, linkHost];
|
|
if (longHost == "www." + shortHost)
|
|
return originalTarget;
|
|
|
|
return "_blank";
|
|
},
|
|
|
|
/**
|
|
* Map the plugin's name to a filtered version more suitable for UI.
|
|
*
|
|
* @param aName The full-length name string of the plugin.
|
|
* @return the simplified name string.
|
|
*/
|
|
makeNicePluginName: function (aName) {
|
|
if (aName == "Shockwave Flash")
|
|
return "Adobe Flash";
|
|
// Regex checks if aName begins with "Java" + non-letter char
|
|
if (/^Java\W/.exec(aName))
|
|
return "Java";
|
|
|
|
// Clean up the plugin name by stripping off parenthetical clauses,
|
|
// trailing version numbers or "plugin".
|
|
// EG, "Foo Bar (Linux) Plugin 1.23_02" --> "Foo Bar"
|
|
// Do this by first stripping the numbers, etc. off the end, and then
|
|
// removing "Plugin" (and then trimming to get rid of any whitespace).
|
|
// (Otherwise, something like "Java(TM) Plug-in 1.7.0_07" gets mangled)
|
|
let newName = aName.replace(/\(.*?\)/g, "").
|
|
replace(/[\s\d\.\-\_\(\)]+$/, "").
|
|
replace(/\bplug-?in\b/i, "").trim();
|
|
return newName;
|
|
},
|
|
|
|
/**
|
|
* Return true if linkNode has a rel="noreferrer" attribute.
|
|
*
|
|
* @param linkNode The <a> element, or null.
|
|
* @return a boolean indicating if linkNode has a rel="noreferrer" attribute.
|
|
*/
|
|
linkHasNoReferrer: function (linkNode) {
|
|
// A null linkNode typically means that we're checking a link that wasn't
|
|
// provided via an <a> link, like a text-selected URL. Don't leak
|
|
// referrer information in this case.
|
|
if (!linkNode)
|
|
return true;
|
|
|
|
let rel = linkNode.getAttribute("rel");
|
|
if (!rel)
|
|
return false;
|
|
|
|
// The HTML spec says that rel should be split on spaces before looking
|
|
// for particular rel values.
|
|
let values = rel.split(/[ \t\r\n\f]/);
|
|
return values.indexOf('noreferrer') != -1;
|
|
},
|
|
};
|