diff --git a/accessible/jsat/AccessFu.css b/accessible/jsat/AccessFu.css
index 89514de60a1e..10b91a3472c3 100644
--- a/accessible/jsat/AccessFu.css
+++ b/accessible/jsat/AccessFu.css
@@ -9,9 +9,14 @@
display: none;
border-radius: 2px;
box-shadow: 1px 1px 1px #444;
+ display: none;
}
-#virtual-cursor-inset {
+#virtual-cursor-box.show {
+ display: block;
+}
+
+#virtual-cursor-box > div {
border-radius: 1px;
box-shadow: inset 1px 1px 1px #444;
display: block;
diff --git a/accessible/jsat/AccessFu.jsm b/accessible/jsat/AccessFu.jsm
index 8fa83f35df79..3e738863dbba 100644
--- a/accessible/jsat/AccessFu.jsm
+++ b/accessible/jsat/AccessFu.jsm
@@ -394,23 +394,19 @@ this.AccessFu = { // jshint ignore:line
_processedMessageManagers: [],
/**
- * Adjusts the given bounds relative to the given browser. Converts from
- * screen or device pixels to either device or CSS pixels.
+ * Adjusts the given bounds relative to the given browser.
* @param {Rect} aJsonBounds the bounds to adjust
* @param {browser} aBrowser the browser we want the bounds relative to
* @param {bool} aToCSSPixels whether to convert to CSS pixels (as opposed to
* device pixels)
- * @param {bool} aFromDevicePixels whether to convert from device pixels (as
- * opposed to screen pixels)
*/
adjustContentBounds:
- function(aJsonBounds, aBrowser, aToCSSPixels, aFromDevicePixels) {
+ function(aJsonBounds, aBrowser, aToCSSPixels) {
let bounds = new Rect(aJsonBounds.left, aJsonBounds.top,
aJsonBounds.right - aJsonBounds.left,
aJsonBounds.bottom - aJsonBounds.top);
let win = Utils.win;
let dpr = win.devicePixelRatio;
- let vp = Utils.getViewport(win);
let offset = { left: -win.mozInnerScreenX, top: -win.mozInnerScreenY };
if (!aBrowser.contentWindow) {
@@ -421,16 +417,6 @@ this.AccessFu = { // jshint ignore:line
offset.left += clientRect.left + win.mozInnerScreenX;
offset.top += clientRect.top + win.mozInnerScreenY;
}
-
- // Here we scale from screen pixels to layout device pixels by dividing by
- // the resolution (caused by pinch-zooming). The resolution is the
- // viewport zoom divided by the devicePixelRatio. If there's no viewport,
- // then we're on a platform without pinch-zooming and we can just ignore
- // this.
- if (!aFromDevicePixels && vp) {
- bounds = bounds.scale(vp.zoom / dpr, vp.zoom / dpr);
- }
-
// Add the offset; the offset is in CSS pixels, so multiply the
// devicePixelRatio back in before adding to preserve unit consistency.
bounds = bounds.translate(offset.left * dpr, offset.top * dpr);
@@ -545,11 +531,10 @@ var Output = {
highlightBox.id = 'virtual-cursor-box';
// Add highlight inset for inner shadow
- let inset = Utils.win.document.
- createElementNS('http://www.w3.org/1999/xhtml', 'div');
- inset.id = 'virtual-cursor-inset';
+ highlightBox.appendChild(
+ Utils.win.document.createElementNS(
+ 'http://www.w3.org/1999/xhtml', 'div'));
- highlightBox.appendChild(inset);
this.highlightBox = Cu.getWeakReference(highlightBox);
} else {
highlightBox = this.highlightBox.get();
@@ -559,12 +544,12 @@ var Output = {
let r = AccessFu.adjustContentBounds(aDetail.bounds, aBrowser, true);
// First hide it to avoid flickering when changing the style.
- highlightBox.style.display = 'none';
+ highlightBox.classList.remove('show');
highlightBox.style.top = (r.top - padding) + 'px';
highlightBox.style.left = (r.left - padding) + 'px';
highlightBox.style.width = (r.width + padding*2) + 'px';
highlightBox.style.height = (r.height + padding*2) + 'px';
- highlightBox.style.display = 'block';
+ highlightBox.classList.add('show');
break;
}
@@ -572,7 +557,7 @@ var Output = {
{
let highlightBox = this.highlightBox ? this.highlightBox.get() : null;
if (highlightBox) {
- highlightBox.style.display = 'none';
+ highlightBox.classList.remove('show');
}
break;
}
@@ -889,8 +874,7 @@ var Input = {
activateContextMenu: function activateContextMenu(aDetails) {
if (Utils.MozBuildApp === 'mobile/android') {
let p = AccessFu.adjustContentBounds(aDetails.bounds,
- Utils.CurrentBrowser,
- true, true).center();
+ Utils.CurrentBrowser, true).center();
Services.obs.notifyObservers(null, 'Gesture:LongPress',
JSON.stringify({x: p.x, y: p.y}));
}
@@ -915,8 +899,8 @@ var Input = {
doScroll: function doScroll(aDetails) {
let horizontal = aDetails.horizontal;
let page = aDetails.page;
- let p = AccessFu.adjustContentBounds(aDetails.bounds, Utils.CurrentBrowser,
- true, true).center();
+ let p = AccessFu.adjustContentBounds(
+ aDetails.bounds, Utils.CurrentBrowser, true).center();
Utils.winUtils.sendWheelEvent(p.x, p.y,
horizontal ? page : 0, horizontal ? 0 : page, 0,
Utils.win.WheelEvent.DOM_DELTA_PAGE, 0, 0, 0, 0);
diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm
index 57ab6c5176d3..2ef4a2dfe83a 100644
--- a/accessible/jsat/Utils.jsm
+++ b/accessible/jsat/Utils.jsm
@@ -255,15 +255,6 @@ this.Utils = { // jshint ignore:line
}
},
- getViewport: function getViewport(aWindow) {
- switch (this.MozBuildApp) {
- case 'mobile/android':
- return aWindow.BrowserApp.selectedTab.getViewport();
- default:
- return null;
- }
- },
-
getState: function getState(aAccessibleOrEvent) {
if (aAccessibleOrEvent instanceof Ci.nsIAccessibleStateChangeEvent) {
return new State(
@@ -302,18 +293,37 @@ this.Utils = { // jshint ignore:line
return doc.QueryInterface(Ci.nsIAccessibleDocument).virtualCursor;
},
- getBounds: function getBounds(aAccessible) {
- let objX = {}, objY = {}, objW = {}, objH = {};
- aAccessible.getBounds(objX, objY, objW, objH);
- return new Rect(objX.value, objY.value, objW.value, objH.value);
+ getContentResolution: function _getContentResolution(aAccessible) {
+ let resX = { value: 1 }, resY = { value: 1 };
+ aAccessible.document.window.QueryInterface(
+ Ci.nsIInterfaceRequestor).getInterface(
+ Ci.nsIDOMWindowUtils).getResolution(resX, resY);
+ return [resX.value, resY.value];
},
- getTextBounds: function getTextBounds(aAccessible, aStart, aEnd) {
- let accText = aAccessible.QueryInterface(Ci.nsIAccessibleText);
- let objX = {}, objY = {}, objW = {}, objH = {};
- accText.getRangeExtents(aStart, aEnd, objX, objY, objW, objH,
- Ci.nsIAccessibleCoordinateType.COORDTYPE_SCREEN_RELATIVE);
- return new Rect(objX.value, objY.value, objW.value, objH.value);
+ getBounds: function getBounds(aAccessible, aPreserveContentScale) {
+ let objX = {}, objY = {}, objW = {}, objH = {};
+ aAccessible.getBounds(objX, objY, objW, objH);
+
+ let [scaleX, scaleY] = aPreserveContentScale ? [1, 1] :
+ this.getContentResolution(aAccessible);
+
+ return new Rect(objX.value, objY.value, objW.value, objH.value).scale(
+ scaleX, scaleY);
+ },
+
+ getTextBounds: function getTextBounds(aAccessible, aStart, aEnd,
+ aPreserveContentScale) {
+ let accText = aAccessible.QueryInterface(Ci.nsIAccessibleText);
+ let objX = {}, objY = {}, objW = {}, objH = {};
+ accText.getRangeExtents(aStart, aEnd, objX, objY, objW, objH,
+ Ci.nsIAccessibleCoordinateType.COORDTYPE_SCREEN_RELATIVE);
+
+ let [scaleX, scaleY] = aPreserveContentScale ? [1, 1] :
+ this.getContentResolution(aAccessible);
+
+ return new Rect(objX.value, objY.value, objW.value, objH.value).scale(
+ scaleX, scaleY);
},
/**
diff --git a/accessible/jsat/content-script.js b/accessible/jsat/content-script.js
index 1dd0d4cd2b9b..c9a991aa5fd4 100644
--- a/accessible/jsat/content-script.js
+++ b/accessible/jsat/content-script.js
@@ -65,14 +65,10 @@ function forwardToChild(aMessage, aListener, aVCPosition) {
}
function activateContextMenu(aMessage) {
- function sendContextMenuCoordinates(aAccessible) {
- let bounds = Utils.getBounds(aAccessible);
- sendAsyncMessage('AccessFu:ActivateContextMenu', {bounds: bounds});
- }
-
let position = Utils.getVirtualCursor(content.document).position;
if (!forwardToChild(aMessage, activateContextMenu, position)) {
- sendContextMenuCoordinates(position);
+ sendAsyncMessage('AccessFu:ActivateContextMenu',
+ { bounds: Utils.getBounds(position, true) });
}
}
@@ -85,16 +81,12 @@ function presentCaretChange(aText, aOldOffset, aNewOffset) {
}
function scroll(aMessage) {
- function sendScrollCoordinates(aAccessible) {
- let bounds = Utils.getBounds(aAccessible);
- sendAsyncMessage('AccessFu:DoScroll',
- { bounds: bounds,
- page: aMessage.json.page,
- horizontal: aMessage.json.horizontal });
- }
-
let position = Utils.getVirtualCursor(content.document).position;
if (!forwardToChild(aMessage, scroll, position)) {
+ sendAsyncMessage('AccessFu:DoScroll',
+ { bounds: Utils.getBounds(position, true),
+ page: aMessage.json.page,
+ horizontal: aMessage.json.horizontal });
sendScrollCoordinates(position);
}
}
diff --git a/addon-sdk/source/lib/toolkit/loader.js b/addon-sdk/source/lib/toolkit/loader.js
index d2b17a1ab038..02370f8bdce7 100644
--- a/addon-sdk/source/lib/toolkit/loader.js
+++ b/addon-sdk/source/lib/toolkit/loader.js
@@ -407,18 +407,18 @@ const nodeResolve = iced(function nodeResolve(id, requirer, { rootURI }) {
let fullId = join(rootURI, id);
let resolvedPath;
- if (resolvedPath = loadAsFile(fullId))
+ if ((resolvedPath = loadAsFile(fullId)))
return stripBase(rootURI, resolvedPath);
- else if (resolvedPath = loadAsDirectory(fullId))
+ else if ((resolvedPath = loadAsDirectory(fullId)))
return stripBase(rootURI, resolvedPath);
// If manifest has dependencies, attempt to look up node modules
// in the `dependencies` list
else {
let dirs = getNodeModulePaths(dirname(join(rootURI, requirer))).map(dir => join(dir, id));
for (let i = 0; i < dirs.length; i++) {
- if (resolvedPath = loadAsFile(dirs[i]))
+ if ((resolvedPath = loadAsFile(dirs[i])))
return stripBase(rootURI, resolvedPath);
- if (resolvedPath = loadAsDirectory(dirs[i]))
+ if ((resolvedPath = loadAsDirectory(dirs[i])))
return stripBase(rootURI, resolvedPath);
}
}
@@ -459,7 +459,7 @@ function loadAsDirectory (path) {
let main = getManifestMain(JSON.parse(readURI(path + '/package.json')));
if (main != null) {
let tmpPath = join(path, main);
- if (found = loadAsFile(tmpPath))
+ if ((found = loadAsFile(tmpPath)))
return found
}
try {
diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js
index 9eb3444fddce..147326a5034b 100644
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -1201,8 +1201,7 @@ const kTransferContractId = "@mozilla.org/transfer;1";
// Override Toolkit's nsITransfer implementation with the one from the
// JavaScript API for downloads. This will eventually be removed when
-// nsIDownloadManager will not be available anymore (bug 851471). The
-// old code in this module will be removed in bug 899110.
+// nsIDownloadManager will not be available anymore (bug 851471).
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(kTransferCid, "",
kTransferContractId, null);
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index a15e38aeaa59..24d083f129ca 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -980,7 +980,11 @@ pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mo
pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
+
+// Turn off remote lookups in beta and stable channel.
+#ifndef RELEASE_BUILD
pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
+#endif
#ifdef MOZILLA_OFFICIAL
// Normally the "client ID" sent in updates is appinfo.name, but for
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index de7685e242d5..1f5fecc12faf 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -438,6 +438,13 @@ var gPopupBlockerObserver = {
// Hide the icon in the location bar (if the location bar exists)
if (gURLBar)
this._reportButton.hidden = true;
+
+ // Hide the notification box (if it's visible).
+ var notificationBox = gBrowser.getNotificationBox();
+ var notification = notificationBox.getNotificationWithValue("popup-blocked");
+ if (notification) {
+ notificationBox.removeNotification(notification, false);
+ }
return;
}
diff --git a/browser/devtools/shared/AppCacheUtils.jsm b/browser/devtools/shared/AppCacheUtils.jsm
index 894be888bd6c..49c9630d1f2d 100644
--- a/browser/devtools/shared/AppCacheUtils.jsm
+++ b/browser/devtools/shared/AppCacheUtils.jsm
@@ -293,7 +293,14 @@ AppCacheUtils.prototype = {
},
clearAll: function ACU_clearAll() {
- Services.cache.evictEntries(Ci.nsICache.STORE_OFFLINE);
+ if (!Services.prefs.getBoolPref("browser.cache.disk.enable")) {
+ throw new Error(l10n.GetStringFromName("cacheDisabled"));
+ }
+
+ let appCacheStorage = Services.cache2.appCacheStorage(LoadContextInfo.default, null);
+ appCacheStorage.asyncEvictStorage({
+ onCacheEntryDoomed: function(result) {}
+ });
},
_getManifestURI: function ACU__getManifestURI() {
diff --git a/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js b/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js
index 294ee97287d4..b7e030d94314 100644
--- a/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js
+++ b/browser/devtools/styleinspector/test/browser_computedview_select-and-copy-styles.js
@@ -15,7 +15,7 @@ let test = asyncTest(function*() {
info("Creating the test document");
content.document.body.innerHTML = '
\n' +
'
Some header text
\n' +
@@ -58,7 +58,7 @@ function checkCopySelection(view) {
let expectedPattern = "font-family: helvetica,sans-serif;[\\r\\n]+" +
"font-size: 16px;[\\r\\n]+" +
- "font-variant: small-caps;[\\r\\n]*";
+ "font-variant-caps: small-caps;[\\r\\n]*";
return waitForClipboard(() => {
fireCopyEvent(props[0]);
@@ -80,7 +80,7 @@ function checkSelectAll(view) {
let expectedPattern = "color: #FF0;[\\r\\n]+" +
"font-family: helvetica,sans-serif;[\\r\\n]+" +
"font-size: 16px;[\\r\\n]+" +
- "font-variant: small-caps;[\\r\\n]*";
+ "font-variant-caps: small-caps;[\\r\\n]*";
return waitForClipboard(() => {
fireCopyEvent(prop);
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index 3eef152bc430..2ec4f3481f73 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -816,6 +816,7 @@ bin/libfreebl_32int64_3.so
@BINPATH@/webapprt/components/PaymentUIGlue.js
@BINPATH@/webapprt/components/components.manifest
@BINPATH@/webapprt/defaults/preferences/prefs.js
+@BINPATH@/webapprt/modules/DownloadView.jsm
@BINPATH@/webapprt/modules/Startup.jsm
@BINPATH@/webapprt/modules/WebappRT.jsm
@BINPATH@/webapprt/modules/WebappManager.jsm
diff --git a/build/sanitizers/lsan_suppressions.txt b/build/sanitizers/lsan_suppressions.txt
index e5e1e381861f..c075a2bfa52c 100644
--- a/build/sanitizers/lsan_suppressions.txt
+++ b/build/sanitizers/lsan_suppressions.txt
@@ -28,12 +28,43 @@ leak:GI___strdup
###
-### Many leaks only affect some test suites. The suite annotations are not checked.
+### Bug 979928 - WebRTC leaks. m2, m3.
###
-# Bug 979928 - WebRTC is leaky. m2, m3
-leak:/media/mtransport/
-leak:/media/webrtc/signaling/
+# WebRTC leaks added for Mochitest 2.
+leak:NR_reg_init
+leak:fsmdef_init
+leak:r_log_register
+leak:nr_reg_set
+leak:ccsnap_device_init
+leak:ccsnap_line_init
+leak:media/webrtc/signaling/src/sipcc/core/common/init.c
+leak:cprPostMessage
+leak:mozilla::NrIceStunServer::Create
+
+# Additional WebRTC leak suppressions added for Mochitest 3.
+leak:mozilla::TransportLayerDtls::Setup
+leak:mozilla::NrIceTurnServer::Create
+# There are about 228KB of leaks from the call to |pmsg->sdp = cpr_malloc(sdp_size);|
+# in send_message_helper.
+leak:send_message_helper
+leak:fsmdef_ev_createoffer
+leak:fsmdef_ev_setremotedesc
+leak:fsmdef_ev_setlocaldesc
+leak:fsmdef_ev_createanswer
+# About 70KB of leaks under this stack.
+leak:vcmRxAllocICE_s
+leak:vcmRxStartICE_m
+# About 50KB of leaks under this stack.
+leak:ccsnap_EscapeStrToLocaleStr
+leak:gsmsdp_add_default_audio_formats_to_local_sdp
+leak:gsmsdp_add_default_video_formats_to_local_sdp
+leak:CCAPI_CallInfo_getMediaStreams
+
+
+###
+### Many leaks only affect some test suites. The suite annotations are not checked.
+###
# Bug 981195 - Small leak in the parser. m4
leak:TypeCompartment::fixObjectType
diff --git a/content/base/public/Element.h b/content/base/public/Element.h
index 881ec04ce43d..3944913c5d3e 100644
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -728,7 +728,7 @@ public:
int32_t ScrollTop()
{
nsIScrollableFrame* sf = GetScrollFrame();
- return sf ? sf->GetScrollPositionCSSPixels().y : 0;
+ return sf ? sf->GetScrollPositionCSSPixels().y.value : 0;
}
void SetScrollTop(int32_t aScrollTop)
{
@@ -741,7 +741,7 @@ public:
int32_t ScrollLeft()
{
nsIScrollableFrame* sf = GetScrollFrame();
- return sf ? sf->GetScrollPositionCSSPixels().x : 0;
+ return sf ? sf->GetScrollPositionCSSPixels().x.value : 0;
}
void SetScrollLeft(int32_t aScrollLeft)
{
diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h
index be418e725b86..8297817083ac 100644
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -405,15 +405,6 @@ public:
static bool CanCallerAccess(nsPIDOMWindow* aWindow);
/**
- * Get the window through the JS context that's currently on the stack.
- * If there's no JS context currently on the stack, returns null.
- */
- static nsPIDOMWindow *GetWindowFromCaller();
-
- /**
- * The two GetDocumentFrom* functions below allow a caller to get at a
- * document that is relevant to the currently executing script.
- *
* GetDocumentFromCaller gets its document by looking at the last called
* function and finding the document that the function itself relates to.
* For example, consider two windows A and B in the same origin. B has a
@@ -421,28 +412,10 @@ public:
* If a script in window A were to call B's function, GetDocumentFromCaller
* would find that function (in B) and return B's document.
*
- * GetDocumentFromContext gets its document by looking at the currently
- * executing context's global object and returning its document. Thus,
- * given the example above, GetDocumentFromCaller would see that the
- * currently executing script was in window A, and return A's document.
- */
- /**
- * Get the document from the currently executing function. This will return
- * the document that the currently executing function is in/from.
- *
* @return The document or null if no JS Context.
*/
static nsIDocument* GetDocumentFromCaller();
- /**
- * Get the document through the JS context that's currently on the stack.
- * If there's no JS context currently on the stack it will return null.
- * This will return the document of the calling script.
- *
- * @return The document or null if no JS context
- */
- static nsIDocument* GetDocumentFromContext();
-
// Check if a node is in the document prolog, i.e. before the document
// element.
static bool InProlog(nsINode *aNode);
@@ -2279,9 +2252,7 @@ private:
static bool sInitialized;
static uint32_t sScriptBlockerCount;
-#ifdef DEBUG
static uint32_t sDOMNodeRemovedSuppressCount;
-#endif
static uint32_t sMicroTaskLevel;
// Not an nsCOMArray because removing elements from those is slower
static nsTArray< nsCOMPtr >* sBlockedScriptRunners;
@@ -2338,14 +2309,10 @@ class MOZ_STACK_CLASS nsAutoScriptBlockerSuppressNodeRemoved :
public nsAutoScriptBlocker {
public:
nsAutoScriptBlockerSuppressNodeRemoved() {
-#ifdef DEBUG
++nsContentUtils::sDOMNodeRemovedSuppressCount;
-#endif
}
~nsAutoScriptBlockerSuppressNodeRemoved() {
-#ifdef DEBUG
--nsContentUtils::sDOMNodeRemovedSuppressCount;
-#endif
}
};
diff --git a/content/base/src/WebSocket.cpp b/content/base/src/WebSocket.cpp
index 060d51580632..93b2ec62a275 100644
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -686,7 +686,7 @@ WebSocket::Init(JSContext* aCx,
// Confirmed we are opening plain ws:// and want to prevent this from a
// secure context (e.g. https). Check the principal's uri to determine if
// we were loaded from https.
- nsCOMPtr globalObject(BrokenGetEntryGlobal());
+ nsCOMPtr globalObject(GetEntryGlobal());
if (globalObject) {
nsCOMPtr principal(globalObject->PrincipalOrNull());
if (principal) {
diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp
index 1029a0925826..b1e96b3d1f52 100644
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -214,9 +214,7 @@ nsILineBreaker *nsContentUtils::sLineBreaker;
nsIWordBreaker *nsContentUtils::sWordBreaker;
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
uint32_t nsContentUtils::sScriptBlockerCount = 0;
-#ifdef DEBUG
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
-#endif
uint32_t nsContentUtils::sMicroTaskLevel = 0;
nsTArray< nsCOMPtr >* nsContentUtils::sBlockedScriptRunners = nullptr;
uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0;
@@ -1953,19 +1951,6 @@ nsContentUtils::TraceSafeJSContext(JSTracer* aTrc)
}
}
-nsPIDOMWindow *
-nsContentUtils::GetWindowFromCaller()
-{
- JSContext *cx = GetCurrentJSContext();
- if (cx) {
- nsCOMPtr win =
- do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
- return win;
- }
-
- return nullptr;
-}
-
nsIDocument*
nsContentUtils::GetDocumentFromCaller()
{
@@ -1980,24 +1965,6 @@ nsContentUtils::GetDocumentFromCaller()
return win->GetExtantDoc();
}
-nsIDocument*
-nsContentUtils::GetDocumentFromContext()
-{
- JSContext *cx = GetCurrentJSContext();
- if (cx) {
- nsIScriptGlobalObject *sgo = nsJSUtils::GetDynamicScriptGlobal(cx);
-
- if (sgo) {
- nsCOMPtr pwin = do_QueryInterface(sgo);
- if (pwin) {
- return pwin->GetExtantDoc();
- }
- }
- }
-
- return nullptr;
-}
-
bool
nsContentUtils::IsCallerChrome()
{
@@ -3920,30 +3887,27 @@ nsContentUtils::MaybeFireNodeRemoved(nsINode* aChild, nsINode* aParent,
NS_PRECONDITION(aChild->GetParentNode() == aParent, "Wrong parent");
NS_PRECONDITION(aChild->OwnerDoc() == aOwnerDoc, "Wrong owner-doc");
- // This checks that IsSafeToRunScript is true since we don't want to fire
- // events when that is false. We can't rely on EventDispatcher to assert
- // this in this situation since most of the time there are no mutation
- // event listeners, in which case we won't even attempt to dispatch events.
- // However this also allows for two exceptions. First off, we don't assert
- // if the mutation happens to native anonymous content since we never fire
- // mutation events on such content anyway.
- // Second, we don't assert if sDOMNodeRemovedSuppressCount is true since
- // that is a know case when we'd normally fire a mutation event, but can't
- // make that safe and so we suppress it at this time. Ideally this should
- // go away eventually.
- NS_ASSERTION((aChild->IsNodeOfType(nsINode::eCONTENT) &&
- static_cast(aChild)->
- IsInNativeAnonymousSubtree()) ||
- IsSafeToRunScript() ||
- sDOMNodeRemovedSuppressCount,
- "Want to fire DOMNodeRemoved event, but it's not safe");
-
// Having an explicit check here since it's an easy mistake to fall into,
// and there might be existing code with problems. We'd rather be safe
// than fire DOMNodeRemoved in all corner cases. We also rely on it for
// nsAutoScriptBlockerSuppressNodeRemoved.
if (!IsSafeToRunScript()) {
- WarnScriptWasIgnored(aOwnerDoc);
+ // This checks that IsSafeToRunScript is true since we don't want to fire
+ // events when that is false. We can't rely on EventDispatcher to assert
+ // this in this situation since most of the time there are no mutation
+ // event listeners, in which case we won't even attempt to dispatch events.
+ // However this also allows for two exceptions. First off, we don't assert
+ // if the mutation happens to native anonymous content since we never fire
+ // mutation events on such content anyway.
+ // Second, we don't assert if sDOMNodeRemovedSuppressCount is true since
+ // that is a know case when we'd normally fire a mutation event, but can't
+ // make that safe and so we suppress it at this time. Ideally this should
+ // go away eventually.
+ if (!(aChild->IsContent() && aChild->AsContent()->IsInNativeAnonymousSubtree()) &&
+ !sDOMNodeRemovedSuppressCount) {
+ NS_ERROR("Want to fire DOMNodeRemoved event, but it's not safe");
+ WarnScriptWasIgnored(aOwnerDoc);
+ }
return;
}
diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
index 629d55e40252..d49047480262 100644
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1429,10 +1429,10 @@ nsHTMLDocument::Open(JSContext* cx,
return ret.forget();
}
- // Note: We want to use GetDocumentFromContext here because this document
+ // Note: We want to use GetEntryDocument here because this document
// should inherit the security information of the document that's opening us,
// (since if it's secure, then it's presumably trusted).
- nsCOMPtr callerDoc = nsContentUtils::GetDocumentFromContext();
+ nsCOMPtr callerDoc = GetEntryDocument();
if (!callerDoc) {
// If we're called from C++ or in some other way without an originating
// document we can't do a document.open w/o changing the principal of the
diff --git a/content/media/gmp/GMPChild.cpp b/content/media/gmp/GMPChild.cpp
index f93ef31bdaf9..344b4b70d63e 100644
--- a/content/media/gmp/GMPChild.cpp
+++ b/content/media/gmp/GMPChild.cpp
@@ -128,14 +128,15 @@ GMPChild::Init(const std::string& aPluginPath,
return false;
}
+#ifdef MOZ_CRASHREPORTER
+ SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
+#endif
+
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
mPluginPath = aPluginPath;
return true;
#endif
-#ifdef MOZ_CRASHREPORTER
- SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
-#endif
#if defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif
diff --git a/content/media/mediasource/SourceBufferResource.h b/content/media/mediasource/SourceBufferResource.h
index f7007e4447a5..5ef220dc5a52 100644
--- a/content/media/mediasource/SourceBufferResource.h
+++ b/content/media/mediasource/SourceBufferResource.h
@@ -75,6 +75,7 @@ private:
public:
ResourceQueue() :
nsDeque(new ResourceQueueDeallocator()),
+ mLogicalLength(0),
mOffset(0)
{
}
@@ -87,12 +88,7 @@ private:
// Returns the length of all items in the queue plus the offset.
// This is the logical length of the resource.
inline uint64_t GetLength() {
- uint64_t s = mOffset;
- for (uint32_t i = 0; i < GetSize(); ++i) {
- ResourceItem* item = ResourceAt(i);
- s += item->mData.Length();
- }
- return s;
+ return mLogicalLength;
}
// Copies aCount bytes from aOffset in the queue into aDest.
@@ -113,6 +109,7 @@ private:
}
inline void PushBack(ResourceItem* aItem) {
+ mLogicalLength += aItem->mData.Length();
nsDeque::Push(aItem);
}
@@ -184,8 +181,10 @@ private:
return static_cast(nsDeque::PopFront());
}
- // Logical offset into the resource of the first element
- // in the queue.
+ // Logical length of the resource.
+ uint64_t mLogicalLength;
+
+ // Logical offset into the resource of the first element in the queue.
uint64_t mOffset;
};
diff --git a/content/media/moz.build b/content/media/moz.build
index 36cda1091ebf..83f40041131e 100644
--- a/content/media/moz.build
+++ b/content/media/moz.build
@@ -67,9 +67,6 @@ EXPORTS += [
'AudioCompactor.h',
'AudioEventTimeline.h',
'AudioMixer.h',
- 'AudioNodeEngine.h',
- 'AudioNodeExternalInputStream.h',
- 'AudioNodeStream.h',
'AudioSampleFormat.h',
'AudioSegment.h',
'AudioStream.h',
@@ -130,9 +127,6 @@ EXPORTS.mozilla.dom += [
UNIFIED_SOURCES += [
'AudioChannelFormat.cpp',
'AudioCompactor.cpp',
- 'AudioNodeEngine.cpp',
- 'AudioNodeExternalInputStream.cpp',
- 'AudioNodeStream.cpp',
'AudioSegment.cpp',
'AudioSink.cpp',
'AudioStream.cpp',
@@ -185,10 +179,6 @@ SOURCES += [
FAIL_ON_WARNINGS = True
-if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
- SOURCES += ['AudioNodeEngineNEON.cpp']
- SOURCES['AudioNodeEngineNEON.cpp'].flags += ['-mfpu=neon']
-
MSVC_ENABLE_PGO = True
include('/ipc/chromium/chromium-config.mozbuild')
diff --git a/content/media/AudioNodeEngine.cpp b/content/media/webaudio/AudioNodeEngine.cpp
similarity index 100%
rename from content/media/AudioNodeEngine.cpp
rename to content/media/webaudio/AudioNodeEngine.cpp
diff --git a/content/media/AudioNodeEngine.h b/content/media/webaudio/AudioNodeEngine.h
similarity index 100%
rename from content/media/AudioNodeEngine.h
rename to content/media/webaudio/AudioNodeEngine.h
diff --git a/content/media/AudioNodeEngineNEON.cpp b/content/media/webaudio/AudioNodeEngineNEON.cpp
similarity index 100%
rename from content/media/AudioNodeEngineNEON.cpp
rename to content/media/webaudio/AudioNodeEngineNEON.cpp
diff --git a/content/media/AudioNodeEngineNEON.h b/content/media/webaudio/AudioNodeEngineNEON.h
similarity index 100%
rename from content/media/AudioNodeEngineNEON.h
rename to content/media/webaudio/AudioNodeEngineNEON.h
diff --git a/content/media/AudioNodeExternalInputStream.cpp b/content/media/webaudio/AudioNodeExternalInputStream.cpp
similarity index 100%
rename from content/media/AudioNodeExternalInputStream.cpp
rename to content/media/webaudio/AudioNodeExternalInputStream.cpp
diff --git a/content/media/AudioNodeExternalInputStream.h b/content/media/webaudio/AudioNodeExternalInputStream.h
similarity index 100%
rename from content/media/AudioNodeExternalInputStream.h
rename to content/media/webaudio/AudioNodeExternalInputStream.h
diff --git a/content/media/AudioNodeStream.cpp b/content/media/webaudio/AudioNodeStream.cpp
similarity index 100%
rename from content/media/AudioNodeStream.cpp
rename to content/media/webaudio/AudioNodeStream.cpp
diff --git a/content/media/AudioNodeStream.h b/content/media/webaudio/AudioNodeStream.h
similarity index 100%
rename from content/media/AudioNodeStream.h
rename to content/media/webaudio/AudioNodeStream.h
diff --git a/content/media/webaudio/moz.build b/content/media/webaudio/moz.build
index 42371e593697..6751e377c797 100644
--- a/content/media/webaudio/moz.build
+++ b/content/media/webaudio/moz.build
@@ -19,6 +19,9 @@ BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
EXPORTS += [
'AudioContext.h',
+ 'AudioNodeEngine.h',
+ 'AudioNodeExternalInputStream.h',
+ 'AudioNodeStream.h',
'AudioParamTimeline.h',
'MediaBufferDecoder.h',
'ThreeDPoint.h',
@@ -65,6 +68,9 @@ UNIFIED_SOURCES += [
'AudioDestinationNode.cpp',
'AudioListener.cpp',
'AudioNode.cpp',
+ 'AudioNodeEngine.cpp',
+ 'AudioNodeExternalInputStream.cpp',
+ 'AudioNodeStream.cpp',
'AudioParam.cpp',
'AudioProcessingEvent.cpp',
'BiquadFilterNode.cpp',
@@ -90,8 +96,15 @@ UNIFIED_SOURCES += [
'WebAudioUtils.cpp',
]
+if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
+ SOURCES += ['AudioNodeEngineNEON.cpp']
+ SOURCES['AudioNodeEngineNEON.cpp'].flags += ['-mfpu=neon']
+
FAIL_ON_WARNINGS = True
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
+LOCAL_INCLUDES += [
+ '..'
+]
diff --git a/content/media/webaudio/test/mochitest.ini b/content/media/webaudio/test/mochitest.ini
index 22783d98d60c..e66d5661f83c 100644
--- a/content/media/webaudio/test/mochitest.ini
+++ b/content/media/webaudio/test/mochitest.ini
@@ -128,6 +128,7 @@ skip-if = (toolkit == 'gonk' && !debug)
[test_periodicWave.html]
[test_scriptProcessorNode.html]
[test_scriptProcessorNodeChannelCount.html]
+[test_scriptProcessorNodePassThrough.html]
[test_scriptProcessorNode_playbackTime1.html]
[test_scriptProcessorNodeZeroInputOutput.html]
[test_scriptProcessorNodeNotConnected.html]
diff --git a/content/media/webaudio/test/test_scriptProcessorNode.html b/content/media/webaudio/test/test_scriptProcessorNode.html
index 4a5ebeb793dd..7cfb3d96e5a1 100644
--- a/content/media/webaudio/test/test_scriptProcessorNode.html
+++ b/content/media/webaudio/test/test_scriptProcessorNode.html
@@ -26,7 +26,7 @@ addLoadEvent(function() {
for (var i = 0; i < 2048; ++i) {
// Make sure our first sample won't be zero
e.outputBuffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * (i + 1) / context.sampleRate);
- e.outputBuffer.getChannelData(0)[i] = Math.sin(880 * 2 * Math.PI * (i + 1) / context.sampleRate);
+ e.outputBuffer.getChannelData(1)[i] = Math.sin(880 * 2 * Math.PI * (i + 1) / context.sampleRate);
}
// Remember our generated audio
buffer = e.outputBuffer;
diff --git a/content/media/webaudio/test/test_scriptProcessorNodePassThrough.html b/content/media/webaudio/test/test_scriptProcessorNodePassThrough.html
new file mode 100644
index 000000000000..8352a331da71
--- /dev/null
+++ b/content/media/webaudio/test/test_scriptProcessorNodePassThrough.html
@@ -0,0 +1,103 @@
+
+
+
+ Test ScriptProcessorNode with passthrough
+
+
+
+
+
+
+
+
+
+
diff --git a/content/media/webm/WebMBufferedParser.cpp b/content/media/webm/WebMBufferedParser.cpp
index 9a2a4aa9d631..d2ce8b80af4e 100644
--- a/content/media/webm/WebMBufferedParser.cpp
+++ b/content/media/webm/WebMBufferedParser.cpp
@@ -60,7 +60,7 @@ void WebMBufferedParser::Append(const unsigned char* aBuffer, uint32_t aLength,
// and return to CLUSTER_SYNC.
if (mClusterIDPos == sizeof(CLUSTER_ID)) {
mClusterIDPos = 0;
- mClusterOffset = mCurrentOffset + (p - aBuffer) - 1;
+ mClusterOffset = mCurrentOffset + (p - aBuffer) - sizeof(CLUSTER_ID);
mState = READ_VINT;
mNextState = TIMECODE_SYNC;
}
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index c39aafc1808d..b8aa1166903c 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1965,16 +1965,16 @@ Navigator::GetMozCameras(ErrorResult& aRv)
return mCameraManager;
}
-already_AddRefed
+already_AddRefed
Navigator::ServiceWorker()
{
MOZ_ASSERT(mWindow);
if (!mServiceWorkerContainer) {
- mServiceWorkerContainer = new workers::ServiceWorkerContainer(mWindow);
+ mServiceWorkerContainer = new ServiceWorkerContainer(mWindow);
}
- nsRefPtr ref = mServiceWorkerContainer;
+ nsRefPtr ref = mServiceWorkerContainer;
return ref.forget();
}
diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h
index c676673e095b..b97259cc9d40 100644
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -36,6 +36,7 @@ struct MediaStreamConstraints;
class WakeLock;
class ArrayBufferViewOrBlobOrStringOrFormData;
struct MobileIdOptions;
+class ServiceWorkerContainer;
}
}
@@ -104,10 +105,6 @@ class AudioChannelManager;
#endif
} // namespace system
-namespace workers {
-class ServiceWorkerContainer;
-} // namespace workers
-
class Navigator : public nsIDOMNavigator
, public nsIMozNavigatorNetwork
, public nsWrapperCache
@@ -262,7 +259,7 @@ public:
ErrorResult& aRv);
#endif // MOZ_MEDIA_NAVIGATOR
- already_AddRefed ServiceWorker();
+ already_AddRefed ServiceWorker();
bool DoNewResolve(JSContext* aCx, JS::Handle aObject,
JS::Handle aId,
@@ -340,7 +337,7 @@ private:
nsCOMPtr mMessagesManager;
nsTArray > mDeviceStorageStores;
nsRefPtr mTimeManager;
- nsRefPtr mServiceWorkerContainer;
+ nsRefPtr mServiceWorkerContainer;
nsCOMPtr mWindow;
// Hashtable for saving cached objects newresolve created, so we don't create
diff --git a/dom/base/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp
index 5f7657149103..5c0daafb7203 100644
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -122,27 +122,18 @@ ScriptSettingsStackEntry::~ScriptSettingsStackEntry()
ScriptSettingsStack::Pop(this);
}
-// This mostly gets the entry global, but doesn't entirely match the spec in
-// certain edge cases. It's good enough for some purposes, but not others. If
-// you want to call this function, ping bholley and describe your use-case.
nsIGlobalObject*
-BrokenGetEntryGlobal()
+GetEntryGlobal()
{
- // We need the current JSContext in order to check the JS for
- // scripted frames that may have appeared since anyone last
- // manipulated the stack. If it's null, that means that there
- // must be no entry global on the stack.
- JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
- if (!cx) {
- MOZ_ASSERT(ScriptSettingsStack::EntryGlobal() == nullptr);
- return nullptr;
- }
-
- return nsJSUtils::GetDynamicScriptGlobal(cx);
+ return ScriptSettingsStack::EntryGlobal();
}
-// Note: When we're ready to expose it, GetEntryGlobal will look similar to
-// GetIncumbentGlobal below.
+nsIDocument*
+GetEntryDocument()
+{
+ nsCOMPtr entryWin = do_QueryInterface(GetEntryGlobal());
+ return entryWin ? entryWin->GetExtantDoc() : nullptr;
+}
nsIGlobalObject*
GetIncumbentGlobal()
@@ -171,6 +162,22 @@ GetIncumbentGlobal()
return ScriptSettingsStack::IncumbentGlobal();
}
+nsIGlobalObject*
+GetCurrentGlobal()
+{
+ JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
+ if (!cx) {
+ return nullptr;
+ }
+
+ JSObject *global = JS::CurrentGlobalOrNull(cx);
+ if (!global) {
+ return nullptr;
+ }
+
+ return xpc::GetNativeForGlobal(global);
+}
+
nsIPrincipal*
GetWebIDLCallerPrincipal()
{
diff --git a/dom/base/ScriptSettings.h b/dom/base/ScriptSettings.h
index 8e5dc63630d4..637aa7436ea4 100644
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -20,6 +20,7 @@
class nsPIDOMWindow;
class nsGlobalWindow;
class nsIScriptContext;
+class nsIDocument;
namespace mozilla {
namespace dom {
@@ -63,17 +64,57 @@ private:
void InitScriptSettings();
void DestroyScriptSettings();
-// This mostly gets the entry global, but doesn't entirely match the spec in
-// certain edge cases. It's good enough for some purposes, but not others. If
-// you want to call this function, ping bholley and describe your use-case.
-nsIGlobalObject* BrokenGetEntryGlobal();
+// To implement a web-compatible browser, it is often necessary to obtain the
+// global object that is "associated" with the currently-running code. This
+// process is made more complicated by the fact that, historically, different
+// algorithms have operated with different definitions of the "associated"
+// global.
+//
+// HTML5 formalizes this into two concepts: the "incumbent global" and the
+// "entry global". The incumbent global corresponds to the global of the
+// current script being executed, whereas the entry global corresponds to the
+// global of the script where the current JS execution began.
+//
+// There is also a potentially-distinct third global that is determined by the
+// current compartment. This roughly corresponds with the notion of Realms in
+// ECMAScript.
+//
+// Suppose some event triggers an event listener in window |A|, which invokes a
+// scripted function in window |B|, which invokes the |window.location.href|
+// setter in window |C|. The entry global would be |A|, the incumbent global
+// would be |B|, and the current compartment would be that of |C|.
+//
+// In general, it's best to use to use the most-closely-associated global
+// unless the spec says to do otherwise. In 95% of the cases, the global of
+// the current compartment (GetCurrentGlobal()) is the right thing. For
+// example, WebIDL constructors (new C.XMLHttpRequest()) are initialized with
+// the global of the current compartment (i.e. |C|).
+//
+// The incumbent global is very similar, but differs in a few edge cases. For
+// example, if window |B| does |C.location.href = "..."|, the incumbent global
+// used for the navigation algorithm is B, because no script from |C| was ever run.
+//
+// The entry global is used for various things like computing base URIs, mostly
+// for historical reasons.
+//
+// Note that all of these functions return bonafide global objects. This means
+// that, for Windows, they always return the inner.
-// Note: We don't yet expose GetEntryGlobal, because in order for it to be
-// correct, we first need to replace a bunch of explicit cx pushing in the
-// browser with AutoEntryScript. But GetIncumbentGlobal is simpler, because it
-// can mostly be inferred from the JS stack.
+// Returns the global associated with the top-most Candidate Entry Point on
+// the Script Settings Stack. See the HTML spec. This may be null.
+nsIGlobalObject* GetEntryGlobal();
+
+// If the entry global is a window, returns its extant document. Otherwise,
+// returns null.
+nsIDocument* GetEntryDocument();
+
+// Returns the global associated with the top-most entry of the the Script
+// Settings Stack. See the HTML spec. This may be null.
nsIGlobalObject* GetIncumbentGlobal();
+// Returns the global associated with the current compartment. This may be null.
+nsIGlobalObject* GetCurrentGlobal();
+
// JS-implemented WebIDL presents an interesting situation with respect to the
// subject principal. A regular C++-implemented API can simply examine the
// compartment of the most-recently-executed script, and use that to infer the
diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp
index cc3ae9045729..bc21c8409b23 100644
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -2501,11 +2501,6 @@ OldBindingConstructorEnabled(const nsGlobalNameStruct *aStruct,
}
}
- // Don't expose CSSFontFeatureValuesRule unless the pref is enabled
- if (aStruct->mDOMClassInfoID == eDOMClassInfo_CSSFontFeatureValuesRule_id) {
- return nsCSSFontFeatureValuesRule::PrefEnabled();
- }
-
return true;
}
diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
index 720114996a5f..3307075ef93f 100644
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -420,7 +420,7 @@ nsFocusManager::GetLastFocusMethod(nsIDOMWindow* aWindow, uint32_t* aLastFocusMe
{
// the focus method is stored on the inner window
nsCOMPtr window(do_QueryInterface(aWindow));
- if (window)
+ if (window && window->IsOuterWindow())
window = window->GetCurrentInnerWindow();
if (!window)
window = mFocusedWindow;
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 302deea54bb3..4a6cb7b858fc 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1482,10 +1482,11 @@ nsGlobalWindow::CleanUp()
mChromeEventHandler = nullptr; // Forces Release
mParentTarget = nullptr;
- nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
-
- if (inner) {
- inner->CleanUp();
+ if (IsOuterWindow()) {
+ nsGlobalWindow* inner = GetCurrentInnerWindowInternal();
+ if (inner) {
+ inner->CleanUp();
+ }
}
if (IsInnerWindow()) {
@@ -5915,15 +5916,8 @@ nsGlobalWindow::RefreshCompartmentPrincipal()
static already_AddRefed
GetCallerDocShellTreeItem()
{
- JSContext *cx = nsContentUtils::GetCurrentJSContext();
- nsCOMPtr callerItem;
-
- if (cx) {
- nsCOMPtr callerWebNav =
- do_GetInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
-
- callerItem = do_QueryInterface(callerWebNav);
- }
+ nsCOMPtr callerWebNav = do_GetInterface(GetEntryGlobal());
+ nsCOMPtr callerItem = do_QueryInterface(callerWebNav);
return callerItem.forget();
}
@@ -6557,7 +6551,7 @@ nsGlobalWindow::Focus(ErrorResult& aError)
return;
}
- nsIDOMWindow *caller = nsContentUtils::GetWindowFromCaller();
+ nsCOMPtr caller = do_QueryInterface(GetEntryGlobal());
nsCOMPtr opener;
GetOpener(getter_AddRefs(opener));
@@ -7535,20 +7529,7 @@ nsGlobalWindow::FireAbuseEvents(bool aBlocked, bool aWindow,
nsIURI *baseURL = nullptr;
- JSContext *cx = nsContentUtils::GetCurrentJSContext();
- nsCOMPtr contextWindow;
-
- if (cx) {
- nsIScriptContext *currentCX = nsJSUtils::GetDynamicScriptContext(cx);
- if (currentCX) {
- contextWindow = do_QueryInterface(currentCX->GetGlobalObject());
- }
- }
- if (!contextWindow) {
- contextWindow = this;
- }
-
- nsCOMPtr doc = contextWindow->GetDoc();
+ nsCOMPtr doc = GetEntryDocument();
if (doc)
baseURL = doc->GetDocBaseURI();
@@ -8253,7 +8234,7 @@ nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle aMessage,
nsCOMPtr providedPrincipal;
if (aTargetOrigin.EqualsASCII("/")) {
- providedPrincipal = BrokenGetEntryGlobal()->PrincipalOrNull();
+ providedPrincipal = GetEntryGlobal()->PrincipalOrNull();
if (NS_WARN_IF(!providedPrincipal))
return;
}
@@ -12803,11 +12784,7 @@ nsGlobalWindow::GetScrollFrame()
nsresult
nsGlobalWindow::SecurityCheckURL(const char *aURL)
{
- nsCOMPtr sourceWindow;
- JSContext* topCx = nsContentUtils::GetCurrentJSContext();
- if (topCx) {
- sourceWindow = do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(topCx));
- }
+ nsCOMPtr sourceWindow = do_QueryInterface(GetEntryGlobal());
if (!sourceWindow) {
sourceWindow = this;
}
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index 850564da70de..a47dd8b8a0c0 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -599,6 +599,7 @@ public:
nsGlobalWindow *GetCurrentInnerWindowInternal() const
{
+ MOZ_ASSERT(IsOuterWindow());
return static_cast(mInnerWindow);
}
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index 7ae1c32bb6dc..7f4c0fd37b02 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -557,46 +557,38 @@ NS_ScriptErrorReporter(JSContext *cx,
}
}
- // XXX this means we are not going to get error reports on non DOM contexts
- nsIScriptContext *context = nsJSUtils::GetDynamicScriptContext(cx);
-
JS::Rooted exception(cx);
::JS_GetPendingException(cx, &exception);
- // Note: we must do this before running any more code on cx (if cx is the
- // dynamic script context).
+ // Note: we must do this before running any more code on cx.
::JS_ClearPendingException(cx);
- if (context) {
- nsIScriptGlobalObject *globalObject = context->GetGlobalObject();
+ MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
+ nsCOMPtr globalObject = GetEntryGlobal();
+ if (globalObject) {
- if (globalObject) {
-
- nsCOMPtr win = do_QueryInterface(globalObject);
- if (win) {
- win = win->GetCurrentInnerWindow();
- }
- nsCOMPtr scriptPrincipal =
- do_QueryInterface(globalObject);
- NS_ASSERTION(scriptPrincipal, "Global objects must implement "
- "nsIScriptObjectPrincipal");
- nsContentUtils::AddScriptRunner(
- new ScriptErrorEvent(JS_GetRuntime(cx),
- report,
- message,
- nsJSPrincipals::get(report->originPrincipals),
- scriptPrincipal->GetPrincipal(),
- win,
- exception,
- /* We do not try to report Out Of Memory via a dom
- * event because the dom event handler would
- * encounter an OOM exception trying to process the
- * event, and then we'd need to generate a new OOM
- * event for that new OOM instance -- this isn't
- * pretty.
- */
- report->errorNumber != JSMSG_OUT_OF_MEMORY));
- }
+ nsCOMPtr win = do_QueryInterface(globalObject);
+ MOZ_ASSERT_IF(win, win->IsInnerWindow());
+ nsCOMPtr scriptPrincipal =
+ do_QueryInterface(globalObject);
+ NS_ASSERTION(scriptPrincipal, "Global objects must implement "
+ "nsIScriptObjectPrincipal");
+ nsContentUtils::AddScriptRunner(
+ new ScriptErrorEvent(JS_GetRuntime(cx),
+ report,
+ message,
+ nsJSPrincipals::get(report->originPrincipals),
+ scriptPrincipal->GetPrincipal(),
+ win,
+ exception,
+ /* We do not try to report Out Of Memory via a dom
+ * event because the dom event handler would
+ * encounter an OOM exception trying to process the
+ * event, and then we'd need to generate a new OOM
+ * event for that new OOM instance -- this isn't
+ * pretty.
+ */
+ report->errorNumber != JSMSG_OUT_OF_MEMORY));
}
if (nsContentUtils::DOMWindowDumpEnabled()) {
diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
index d5c47f687a40..acbfa3994548 100644
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -63,21 +63,6 @@ nsJSUtils::GetStaticScriptContext(JSObject* aObj)
return nativeGlobal->GetScriptContext();
}
-nsIScriptGlobalObject *
-nsJSUtils::GetDynamicScriptGlobal(JSContext* aContext)
-{
- nsIScriptContext *scriptCX = GetDynamicScriptContext(aContext);
- if (!scriptCX)
- return nullptr;
- return scriptCX->GetGlobalObject();
-}
-
-nsIScriptContext *
-nsJSUtils::GetDynamicScriptContext(JSContext *aContext)
-{
- return GetScriptContextFromJSContext(aContext);
-}
-
uint64_t
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
{
diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h
index d781609446ea..18f7864fa842 100644
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -32,10 +32,6 @@ public:
static nsIScriptContext *GetStaticScriptContext(JSObject* aObj);
- static nsIScriptGlobalObject *GetDynamicScriptGlobal(JSContext *aContext);
-
- static nsIScriptContext *GetDynamicScriptContext(JSContext *aContext);
-
/**
* Retrieve the inner window ID based on the given JSContext.
*
diff --git a/dom/base/nsLocation.cpp b/dom/base/nsLocation.cpp
index d16e6c720804..2c9a92d4f339 100644
--- a/dom/base/nsLocation.cpp
+++ b/dom/base/nsLocation.cpp
@@ -28,6 +28,7 @@
#include "nsITextToSubURI.h"
#include "nsJSUtils.h"
#include "nsContentUtils.h"
+#include "nsGlobalWindow.h"
#include "mozilla/Likely.h"
#include "nsCycleCollectionParticipant.h"
#include "nsNullPrincipal.h"
@@ -42,15 +43,8 @@ GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
{
aCharset.Truncate();
- JSContext *cx = nsContentUtils::GetCurrentJSContext();
- if (cx) {
- nsCOMPtr window =
- do_QueryInterface(nsJSUtils::GetDynamicScriptGlobal(cx));
- NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
-
- if (nsIDocument* doc = window->GetDoc()) {
- aCharset = doc->GetDocumentCharacterSet();
- }
+ if (nsIDocument* doc = GetEntryDocument()) {
+ aCharset = doc->GetDocumentCharacterSet();
}
return NS_OK;
@@ -545,23 +539,23 @@ nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
* anywhere else. This is part of solution for bug # 39938, 72197
*
*/
- bool inScriptTag=false;
- JSContext *cx = nsContentUtils::GetCurrentJSContext();
- if (cx) {
- nsIScriptContext *scriptContext =
- nsJSUtils::GetDynamicScriptContext(cx);
+ bool inScriptTag = false;
+ nsIScriptContext* scriptContext = nullptr;
+ nsCOMPtr win = do_QueryInterface(GetEntryGlobal());
+ if (win) {
+ scriptContext = static_cast(win.get())->GetContextInternal();
+ }
- if (scriptContext) {
- if (scriptContext->GetProcessingScriptTag()) {
- // Now check to make sure that the script is running in our window,
- // since we only want to replace if the location is set by a
- //
+
+
+
+
+Mozilla Bug 1036214
+
+