merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2015-03-31 14:43:50 +02:00
commit 889e5d30e1
978 changed files with 7498 additions and 7546 deletions

View File

@ -478,7 +478,7 @@ static nsRoleMapEntry sWAIRoleMaps[] =
},
{ // radiogroup
&nsGkAtoms::radiogroup,
roles::GROUPING,
roles::RADIO_GROUP,
kUseMapRole,
eNoValue,
eNoAction,

View File

@ -976,7 +976,12 @@ enum Role {
*/
MATHML_STACK_LINE = 167,
LAST_ROLE = MATHML_STACK_LINE
/**
* A group containing radio buttons
*/
RADIO_GROUP = 168,
LAST_ROLE = RADIO_GROUP
};
} // namespace role

View File

@ -1359,3 +1359,11 @@ ROLE(MATHML_STACK_LINE,
0,
IA2_ROLE_UNKNOWN,
eNoNameRule)
ROLE(RADIO_GROUP,
"grouping",
ATK_ROLE_PANEL,
NSAccessibilityRadioGroupRole,
ROLE_SYSTEM_GROUPING,
ROLE_SYSTEM_GROUPING,
eNoNameRule)

View File

@ -8,7 +8,7 @@
/**
* Defines cross platform (Gecko) roles.
*/
[scriptable, uuid(55581ec3-ba6e-4805-8108-260ed34cdcbb)]
[scriptable, uuid(00f9e831-3198-40b7-9186-5251474d4d7a)]
interface nsIAccessibleRole : nsISupports
{
/**
@ -969,4 +969,9 @@ interface nsIAccessibleRole : nsISupports
* A MathML line in a stack (msline in MathML).
*/
const unsigned long ROLE_MATHML_STACK_LINE = 167;
/**
* A group containing radio buttons
*/
const unsigned long ROLE_RADIO_GROUP = 168;
};

View File

@ -96,6 +96,7 @@ const ROLE_PROGRESSBAR = nsIAccessibleRole.ROLE_PROGRESSBAR;
const ROLE_PROPERTYPAGE = nsIAccessibleRole.ROLE_PROPERTYPAGE;
const ROLE_PUSHBUTTON = nsIAccessibleRole.ROLE_PUSHBUTTON;
const ROLE_RADIOBUTTON = nsIAccessibleRole.ROLE_RADIOBUTTON;
const ROLE_RADIO_GROUP = nsIAccessibleRole.ROLE_RADIO_GROUP;
const ROLE_RADIO_MENU_ITEM = nsIAccessibleRole.ROLE_RADIO_MENU_ITEM;
const ROLE_RICH_OPTION = nsIAccessibleRole.ROLE_RICH_OPTION;
const ROLE_ROW = nsIAccessibleRole.ROLE_ROW;

View File

@ -51,7 +51,7 @@
testRole("aria_presentation", ROLE_TEXT_CONTAINER); // weak role
testRole("aria_progressbar", ROLE_PROGRESSBAR);
testRole("aria_radio", ROLE_RADIOBUTTON);
testRole("aria_radiogroup", ROLE_GROUPING);
testRole("aria_radiogroup", ROLE_RADIO_GROUP);
testRole("aria_region", ROLE_PANE);
testRole("aria_row", ROLE_ROW);
testRole("aria_rowheader", ROLE_ROWHEADER);

View File

@ -39,7 +39,7 @@
// radiogroup
accTree = {
role: ROLE_GROUPING,
role: ROLE_RADIO_GROUP,
children: [
{
role: ROLE_RADIOBUTTON,

View File

@ -472,7 +472,7 @@ XULRadioGroupAccessible::
role
XULRadioGroupAccessible::NativeRole()
{
return roles::GROUPING;
return roles::RADIO_GROUP;
}
uint64_t

View File

@ -952,3 +952,9 @@ bin/libfreebl_32int64_3.so
#ifdef PACKAGE_MOZTT
@RESPATH@/fonts/*
#endif
; media
#ifdef MOZ_EME
@RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@
@RESPATH@/gmp-clearkey/0.1/clearkey.info
#endif

View File

@ -274,25 +274,18 @@ var PlacesCommandHook = {
var uri = aBrowser.currentURI;
var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
if (itemId == -1) {
// Copied over from addBookmarkForBrowser:
// Bug 52536: We obtain the URL and title from the nsIWebNavigation
// associated with a <browser/> rather than from a DOMWindow.
// This is because when a full page plugin is loaded, there is
// no DOMWindow (?) but information about the loaded document
// may still be obtained from the webNavigation.
var webNav = aBrowser.webNavigation;
var url = webNav.currentURI;
// Bug 1148838 - Make this code work for full page plugins.
var title;
var description;
var charset;
try {
let isErrorPage = /^about:(neterror|certerror|blocked)/
.test(webNav.document.documentURI);
title = isErrorPage ? PlacesUtils.history.getPageTitle(url)
: webNav.document.title;
title = title || url.spec;
description = PlacesUIUtils.getDescriptionFromDocument(webNav.document);
charset = webNav.document.characterSet;
.test(aBrowser.contentDocumentAsCPOW.documentURI);
title = isErrorPage ? PlacesUtils.history.getPageTitle(uri)
: aBrowser.contentTitle;
title = title || uri.spec;
description = PlacesUIUtils.getDescriptionFromDocument(aBrowser.contentDocumentAsCPOW);
charset = aBrowser.characterSet;
}
catch (e) { }

View File

@ -3769,7 +3769,8 @@
};
let popup = browser.ownerDocument.getElementById("contentAreaContextMenu");
let event = gContextMenuContentData.event;
popup.openPopupAtScreen(event.screenX, event.screenY, true);
let pos = browser.mapScreenCoordinatesFromContent(event.screenX, event.screenY);
popup.openPopupAtScreen(pos.x, pos.y, true);
break;
}
case "DOMWebNotificationClicked": {

View File

@ -848,7 +848,7 @@ function waitForEvents(event)
if (painted && loaded) {
subwindow.removeEventListener("MozAfterPaint", waitForEvents, false);
subwindow.onload = null;
startTest();
SimpleTest.waitForFocus(startTest, subwindow);
}
}

View File

@ -15,6 +15,8 @@ Cu.import("resource://gre/modules/Services.jsm", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", this);
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "console",
"resource://gre/modules/devtools/Console.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivacyFilter",
@ -205,23 +207,23 @@ let SessionSaverInternal = {
delete state.deferredInitialState;
}
#ifndef XP_MACOSX
// We want to restore closed windows that are marked with _shouldRestore.
// We're doing this here because we want to control this only when saving
// the file.
while (state._closedWindows.length) {
let i = state._closedWindows.length - 1;
if (AppConstants.platform != "macosx") {
// We want to restore closed windows that are marked with _shouldRestore.
// We're doing this here because we want to control this only when saving
// the file.
while (state._closedWindows.length) {
let i = state._closedWindows.length - 1;
if (!state._closedWindows[i]._shouldRestore) {
// We only need to go until _shouldRestore
// is falsy since we're going in reverse.
break;
if (!state._closedWindows[i]._shouldRestore) {
// We only need to go until _shouldRestore
// is falsy since we're going in reverse.
break;
}
delete state._closedWindows[i]._shouldRestore;
state.windows.unshift(state._closedWindows.pop());
}
delete state._closedWindows[i]._shouldRestore;
state.windows.unshift(state._closedWindows.pop());
}
#endif
stopWatchFinish("COLLECT_DATA_MS", "COLLECT_DATA_LONGEST_OP_MS");
return this._writeState(state);

View File

@ -126,6 +126,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "console",
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "GlobalState",
"resource:///modules/sessionstore/GlobalState.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivacyFilter",
@ -883,9 +885,7 @@ let SessionStoreInternal = {
if (closedWindowState) {
let newWindowState;
#ifndef XP_MACOSX
if (!this._doResumeSession()) {
#endif
if (AppConstants.platform == "macosx" || !this._doResumeSession()) {
// We want to split the window up into pinned tabs and unpinned tabs.
// Pinned tabs should be restored. If there are any remaining tabs,
// they should be added back to _closedWindows.
@ -909,7 +909,6 @@ let SessionStoreInternal = {
delete normalTabsState.windows[0].__lastSessionWindowID;
this._closedWindows[closedWindowIndex] = normalTabsState.windows[0];
}
#ifndef XP_MACOSX
}
else {
// If we're just restoring the window, make sure it gets removed from
@ -918,7 +917,7 @@ let SessionStoreInternal = {
newWindowState = closedWindowState;
delete newWindowState.hidden;
}
#endif
if (newWindowState) {
// Ensure that the window state isn't hidden
this._restoreCount = 1;
@ -1067,11 +1066,11 @@ let SessionStoreInternal = {
SessionCookies.update([winData]);
}
#ifndef XP_MACOSX
// Until we decide otherwise elsewhere, this window is part of a series
// of closing windows to quit.
winData._shouldRestore = true;
#endif
if (AppConstants.platform != "macosx") {
// Until we decide otherwise elsewhere, this window is part of a series
// of closing windows to quit.
winData._shouldRestore = true;
}
// Store the window's close date to figure out when each individual tab
// was closed. This timestamp should allow re-arranging data based on how
@ -2175,21 +2174,21 @@ let SessionStoreInternal = {
// shallow copy this._closedWindows to preserve current state
let lastClosedWindowsCopy = this._closedWindows.slice();
#ifndef XP_MACOSX
// If no non-popup browser window remains open, return the state of the last
// closed window(s). We only want to do this when we're actually "ending"
// the session.
//XXXzpao We should do this for _restoreLastWindow == true, but that has
// its own check for popups. c.f. bug 597619
if (nonPopupCount == 0 && lastClosedWindowsCopy.length > 0 &&
RunState.isQuitting) {
// prepend the last non-popup browser window, so that if the user loads more tabs
// at startup we don't accidentally add them to a popup window
do {
total.unshift(lastClosedWindowsCopy.shift())
} while (total[0].isPopup && lastClosedWindowsCopy.length > 0)
if (AppConstants.platform != "macosx") {
// If no non-popup browser window remains open, return the state of the last
// closed window(s). We only want to do this when we're actually "ending"
// the session.
//XXXzpao We should do this for _restoreLastWindow == true, but that has
// its own check for popups. c.f. bug 597619
if (nonPopupCount == 0 && lastClosedWindowsCopy.length > 0 &&
RunState.isQuitting) {
// prepend the last non-popup browser window, so that if the user loads more tabs
// at startup we don't accidentally add them to a popup window
do {
total.unshift(lastClosedWindowsCopy.shift())
} while (total[0].isPopup && lastClosedWindowsCopy.length > 0)
}
}
#endif
if (activeWindow) {
this.activeWindowSSiCache = activeWindow.__SSi || "";
@ -3422,15 +3421,15 @@ let SessionStoreInternal = {
if (this._closedWindows.length <= this._max_windows_undo)
return;
let spliceTo = this._max_windows_undo;
#ifndef XP_MACOSX
let normalWindowIndex = 0;
// try to find a non-popup window in this._closedWindows
while (normalWindowIndex < this._closedWindows.length &&
!!this._closedWindows[normalWindowIndex].isPopup)
normalWindowIndex++;
if (normalWindowIndex >= this._max_windows_undo)
spliceTo = normalWindowIndex + 1;
#endif
if (AppConstants.platform != "macosx") {
let normalWindowIndex = 0;
// try to find a non-popup window in this._closedWindows
while (normalWindowIndex < this._closedWindows.length &&
!!this._closedWindows[normalWindowIndex].isPopup)
normalWindowIndex++;
if (normalWindowIndex >= this._max_windows_undo)
spliceTo = normalWindowIndex + 1;
}
this._closedWindows.splice(spliceTo, this._closedWindows.length);
},

View File

@ -7,6 +7,9 @@
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
var gStateObject;
var gTreeData;
@ -179,11 +182,9 @@ function onListClick(aEvent) {
if (cell.col) {
// Restore this specific tab in the same window for middle/double/accel clicking
// on a tab's title.
#ifdef XP_MACOSX
let accelKey = aEvent.metaKey;
#else
let accelKey = aEvent.ctrlKey;
#endif
let accelKey = AppConstants.platform == "macosx" ?
aEvent.metaKey :
aEvent.ctrlKey;
if ((aEvent.button == 1 || aEvent.button == 0 && aEvent.detail == 2 || accelKey) &&
cell.col.id == "title" &&
!treeView.isContainer(cell.row)) {

View File

@ -4,5 +4,5 @@
browser.jar:
* content/browser/aboutSessionRestore.xhtml (content/aboutSessionRestore.xhtml)
* content/browser/aboutSessionRestore.js (content/aboutSessionRestore.js)
content/browser/aboutSessionRestore.js (content/aboutSessionRestore.js)
content/browser/content-sessionStore.js (content/content-sessionStore.js)

View File

@ -36,7 +36,9 @@ EXTRA_JS_MODULES.sessionstore = [
'SessionFile.jsm',
'SessionHistory.jsm',
'SessionMigration.jsm',
'SessionSaver.jsm',
'SessionStorage.jsm',
'SessionStore.jsm',
'SessionWorker.js',
'SessionWorker.jsm',
'TabAttributes.jsm',
@ -45,10 +47,5 @@ EXTRA_JS_MODULES.sessionstore = [
'Utils.jsm',
]
EXTRA_PP_JS_MODULES.sessionstore += [
'SessionSaver.jsm',
'SessionStore.jsm',
]
with Files('**'):
BUG_COMPONENT = ('Firefox', 'Session Restore')

View File

@ -574,9 +574,9 @@ class LSANLeaks(object):
# Don't various allocation-related stack frames, as they do not help much to
# distinguish different leaks.
unescapedSkipList = [
"malloc", "js_malloc", "malloc_", "__interceptor_malloc", "moz_malloc", "moz_xmalloc",
"calloc", "js_calloc", "calloc_", "__interceptor_calloc", "moz_calloc", "moz_xcalloc",
"realloc","js_realloc", "realloc_", "__interceptor_realloc", "moz_realloc", "moz_xrealloc",
"malloc", "js_malloc", "malloc_", "__interceptor_malloc", "moz_xmalloc",
"calloc", "js_calloc", "calloc_", "__interceptor_calloc", "moz_xcalloc",
"realloc","js_realloc", "realloc_", "__interceptor_realloc", "moz_xrealloc",
"new",
"js::MallocProvider",
]

View File

@ -35,3 +35,5 @@ if [ -z "$CXX" ]; then
fi
. "$topsrcdir/build/mozconfig.cache"
export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE=/builds/crash-stats-api.token

View File

@ -12,3 +12,5 @@ fi
# Some builds (eg: Mulet) don't want the installer, so only set this if it
# hasn't already been set.
MOZ_AUTOMATION_INSTALLER=${MOZ_AUTOMATION_INSTALLER-1}
export SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE=c:/builds/crash-stats-api.token

View File

@ -7,28 +7,14 @@ var MANIFESTS = [
do_get_file("data/test_bug519468.manifest")
];
Components.utils.import("resource://testing-common/MockRegistrar.jsm");
// Stub in the locale service so we can control what gets returned as the OS locale setting
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
let stubOSLocale = null;
stubID = Components.ID("9d09d686-d913-414c-a1e6-4be8652d7d93");
localeContractID = "@mozilla.org/intl/nslocaleservice;1";
StubLocaleService = {
classDescription: "Stub version of Locale service for testing",
classID: stubID,
contractID: localeContractID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsILocaleService, Ci.nsISupports, Ci.nsIFactory]),
createInstance: function (outer, iid) {
if (outer)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return this.QueryInterface(iid);
},
lockFactory: function (lock) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsILocaleService, Ci.nsISupports]),
getLocaleComponentForUserAgent: function SLS_getLocaleComponentForUserAgent()
{
@ -36,14 +22,7 @@ StubLocaleService = {
}
}
let registrar = Components.manager.nsIComponentRegistrar;
// Save original factory.
let localeCID = registrar.contractIDToCID(localeContractID)
let originalFactory =
Components.manager.getClassObject(Components.classes[localeContractID],
Components.interfaces.nsIFactory);
registrar.registerFactory(stubID, "Unit test Locale Service", localeContractID, StubLocaleService);
MockRegistrar.register("@mozilla.org/intl/nslocaleservice;1", StubLocaleService);
// Now fire up the test
do_test_pending()

View File

@ -6962,6 +6962,7 @@ elif test "$GNU_CC"; then
# -Wmaybe-uninitialized - too many false positives
# -Wdeprecated-declarations - we don't want our builds held hostage when a
# platform-specific API becomes deprecated.
# -Wfree-nonheap-object - false positives during PGO
MOZ_C_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_c_has_noerror_uninitialized)
MOZ_CXX_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_cxx_has_noerror_uninitialized)
MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
@ -6972,6 +6973,8 @@ elif test "$GNU_CC"; then
if test -n "$MOZ_PGO"; then
MOZ_C_SUPPORTS_WARNING(-W, no-error=coverage-mismatch, ac_c_has_noerror_coverage_mismatch)
MOZ_CXX_SUPPORTS_WARNING(-W, no-error=coverage-mismatch, ac_cxx_has_noerror_coverage_mismatch)
MOZ_C_SUPPORTS_WARNING(-W, no-error=free-nonheap-object, ac_c_has_noerror_free_nonheap_object)
MOZ_CXX_SUPPORTS_WARNING(-W, no-error=free-nonheap-object, ac_cxx_has_noerror_free_nonheap_object)
fi
fi

View File

@ -446,6 +446,11 @@ public:
nsresult StartTimeout();
void SetInterceptController(nsINetworkInterceptController* aInterceptController)
{
mInterceptController = aInterceptController;
}
private:
~nsPingListener();
@ -453,6 +458,7 @@ private:
nsCOMPtr<nsIContent> mContent;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsINetworkInterceptController> mInterceptController;
};
NS_IMPL_ISUPPORTS(nsPingListener, nsIStreamListener, nsIRequestObserver,
@ -517,8 +523,15 @@ NS_IMETHODIMP
nsPingListener::GetInterface(const nsIID& aIID, void** aResult)
{
if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
NS_ADDREF_THIS();
*aResult = (nsIChannelEventSink*)this;
nsCOMPtr<nsIChannelEventSink> copy(this);
*aResult = copy.forget().take();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsINetworkInterceptController)) &&
mInterceptController) {
nsCOMPtr<nsINetworkInterceptController> copy(mInterceptController);
*aResult = copy.forget().take();
return NS_OK;
}
@ -557,13 +570,14 @@ nsPingListener::AsyncOnChannelRedirect(nsIChannel* aOldChan,
return NS_OK;
}
struct SendPingInfo
struct MOZ_STACK_CLASS SendPingInfo
{
int32_t numPings;
int32_t maxPings;
bool requireSameHost;
nsIURI* target;
nsIURI* referrer;
nsIDocShell* docShell;
uint32_t referrerPolicy;
};
@ -697,6 +711,8 @@ SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
nsPingListener* pingListener =
new nsPingListener(info->requireSameHost, aContent, loadGroup);
nsCOMPtr<nsINetworkInterceptController> interceptController = do_QueryInterface(info->docShell);
pingListener->SetInterceptController(interceptController);
nsCOMPtr<nsIStreamListener> listener(pingListener);
// Observe redirects as well:
@ -721,7 +737,8 @@ SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
// Spec: http://whatwg.org/specs/web-apps/current-work/#ping
static void
DispatchPings(nsIContent* aContent,
DispatchPings(nsIDocShell* aDocShell,
nsIContent* aContent,
nsIURI* aTarget,
nsIURI* aReferrer,
uint32_t aReferrerPolicy)
@ -739,6 +756,7 @@ DispatchPings(nsIContent* aContent,
info.target = aTarget;
info.referrer = aReferrer;
info.referrerPolicy = aReferrerPolicy;
info.docShell = aDocShell;
ForEachPing(aContent, SendPing, &info);
}
@ -13522,7 +13540,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
aDocShell, // DocShell out-param
aRequest); // Request out-param
if (NS_SUCCEEDED(rv)) {
DispatchPings(aContent, aURI, referer, refererPolicy);
DispatchPings(this, aContent, aURI, referer, refererPolicy);
}
return rv;
}

View File

@ -20,7 +20,7 @@ public:
~BlobSet()
{
moz_free(mData);
free(mData);
}
nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
@ -52,7 +52,7 @@ protected:
if (!bufferLen.isValid())
return false;
void* data = moz_realloc(mData, bufferLen.value());
void* data = realloc(mData, bufferLen.value());
if (!data)
return false;

View File

@ -28,6 +28,7 @@
#include "nsIDOMWindowUtils.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsILoadContext.h"
#include "nsIProgrammingLanguage.h"
#include "nsIServiceManager.h"
#include "nsISupportsPrimitives.h"
#include "nsIWebNavigation.h"
@ -904,8 +905,7 @@ ReifyStack(nsIStackFrame* aStack, nsTArray<ConsoleStackEntry>& aRefiedStack)
nsresult rv = stack->GetLanguage(&language);
NS_ENSURE_SUCCESS(rv, rv);
if (language == nsIProgrammingLanguage::JAVASCRIPT ||
language == nsIProgrammingLanguage::JAVASCRIPT2) {
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
ConsoleStackEntry& data = *aRefiedStack.AppendElement();
rv = StackFrameToStackEntry(stack, data, language);
NS_ENSURE_SUCCESS(rv, rv);
@ -993,8 +993,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
return;
}
if (language == nsIProgrammingLanguage::JAVASCRIPT ||
language == nsIProgrammingLanguage::JAVASCRIPT2) {
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
callData->mTopStackFrame.emplace();
nsresult rv = StackFrameToStackEntry(stack,
*callData->mTopStackFrame,

View File

@ -84,7 +84,7 @@ public:
uint64_t aLength);
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
// freed by moz_free so it must be allocated by moz_malloc or something
// freed by free so it must be allocated by malloc or something
// compatible with it.
static already_AddRefed<File>
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
@ -92,7 +92,7 @@ public:
uint64_t aLastModifiedDate);
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
// freed by moz_free so it must be allocated by moz_malloc or something
// freed by free so it must be allocated by malloc or something
// compatible with it.
static already_AddRefed<File>
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
@ -552,7 +552,7 @@ public:
sDataOwners = nullptr;
}
moz_free(mData);
free(mData);
}
public:

View File

@ -102,7 +102,7 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
Clear();
moz_free(mImpl);
free(mImpl);
}
nsIContent*
@ -635,11 +635,11 @@ nsAttrAndChildArray::Compact()
// Then resize or free buffer
uint32_t newSize = attrCount * ATTRSIZE + childCount;
if (!newSize && !mImpl->mMappedAttrs) {
moz_free(mImpl);
free(mImpl);
mImpl = nullptr;
}
else if (newSize < mImpl->mBufferSize) {
mImpl = static_cast<Impl*>(moz_realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
mImpl = static_cast<Impl*>(realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
mImpl->mBufferSize = newSize;
@ -776,7 +776,7 @@ nsAttrAndChildArray::GrowBy(uint32_t aGrowSize)
}
bool needToInitialize = !mImpl;
Impl* newImpl = static_cast<Impl*>(moz_realloc(mImpl, size * sizeof(void*)));
Impl* newImpl = static_cast<Impl*>(realloc(mImpl, size * sizeof(void*)));
NS_ENSURE_TRUE(newImpl, false);
mImpl = newImpl;

View File

@ -6052,7 +6052,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
JS::MutableHandle<JS::Value> aBlob)
{
uint32_t blobLen = aData.Length();
void* blobData = moz_malloc(blobLen);
void* blobData = malloc(blobLen);
nsRefPtr<File> blob;
if (blobData) {
memcpy(blobData, aData.BeginReading(), blobLen);

View File

@ -863,14 +863,6 @@ nsDOMClassInfo::GetClassIDNoAlloc(nsCID *aClassID)
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
nsDOMClassInfo::GetImplementationLanguage(uint32_t *aImplLanguage)
{
*aImplLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;
}
NS_IMETHODIMP
nsDOMClassInfo::GetFlags(uint32_t *aFlags)
{

View File

@ -363,7 +363,7 @@ nsDOMFileReader::DoReadData(nsIAsyncInputStream* aStream, uint64_t aCount)
return NS_ERROR_OUT_OF_MEMORY;
}
if (mDataFormat != FILE_AS_ARRAYBUFFER) {
mFileData = (char *) moz_realloc(mFileData, mDataLen + aCount);
mFileData = (char *) realloc(mFileData, mDataLen + aCount);
NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
}

View File

@ -131,7 +131,7 @@ protected:
nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, uint32_t aDataLen, nsAString &aResult);
void FreeFileData() {
moz_free(mFileData);
free(mFileData);
mFileData = nullptr;
mDataLen = 0;
}

View File

@ -884,7 +884,8 @@ nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
// Don't show remote iframe if we are waiting for the completion of reflow.
if (!aFrame || !(aFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
mRemoteBrowser->UpdateDimensions(dimensions, size);
nsIntPoint chromeDisp = aFrame->GetChromeDisplacement();
mRemoteBrowser->UpdateDimensions(dimensions, size, chromeDisp);
}
}
@ -1382,12 +1383,6 @@ nsFrameLoader::StartDestroy()
}
}
// If the TabParent has installed any event listeners on the window, this is
// its last chance to remove them while we're still in the document.
if (mRemoteBrowser) {
mRemoteBrowser->RemoveWindowListeners();
}
nsCOMPtr<nsIDocument> doc;
bool dynamicSubframeRemoval = false;
if (mOwnerContent) {
@ -2063,7 +2058,8 @@ nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame *aIFrame)
ScreenIntSize size = aIFrame->GetSubdocumentSize();
nsIntRect dimensions;
NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE);
mRemoteBrowser->UpdateDimensions(dimensions, size);
nsIntPoint chromeDisp = aIFrame->GetChromeDisplacement();
mRemoteBrowser->UpdateDimensions(dimensions, size, chromeDisp);
}
return NS_OK;
}

View File

@ -229,9 +229,6 @@ public:
void ActivateUpdateHitRegion();
void DeactivateUpdateHitRegion();
// Properly retrieves documentSize of any subdocument type.
nsresult GetWindowDimensions(nsIntRect& aRect);
private:
void SetOwnerContent(mozilla::dom::Element* aContent);
@ -287,6 +284,9 @@ private:
nsresult MaybeCreateDocShell();
nsresult EnsureMessageManager();
// Properly retrieves documentSize of any subdocument type.
nsresult GetWindowDimensions(nsIntRect& aRect);
// Updates the subdocument position and size. This gets called only
// when we have our own in-process DocShell.
void UpdateBaseWindowPositionAndSize(nsSubDocumentFrame *aIFrame);

View File

@ -579,16 +579,29 @@ JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData)
static bool
GetParamsForMessage(JSContext* aCx,
const JS::Value& aJSON,
const JS::Value& aData,
JSAutoStructuredCloneBuffer& aBuffer,
StructuredCloneClosure& aClosure)
{
JS::Rooted<JS::Value> v(aCx, aJSON);
// First try to use structured clone on the whole thing.
JS::RootedValue v(aCx, aData);
if (WriteStructuredClone(aCx, v, aBuffer, aClosure)) {
return true;
}
JS_ClearPendingException(aCx);
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
nsAutoString filename;
uint32_t lineno = 0;
nsJSUtils::GetCallingLocation(aCx, filename, &lineno);
nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
error->Init(NS_LITERAL_STRING("Sending message that cannot be cloned. Are you trying to send an XPCOM object?"),
filename, EmptyString(),
lineno, 0, nsIScriptError::warningFlag, "chrome javascript");
console->LogMessage(error);
}
// Not clonable, try JSON
//XXX This is ugly but currently structured cloning doesn't handle
// properly cases when interface is implemented in JS and used

View File

@ -8,7 +8,6 @@
#include "nsAutoPtr.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsIProgrammingLanguage.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/URIUtils.h"
@ -235,13 +234,6 @@ nsHostObjectURI::GetClassID(nsCID * *aClassID)
return GetClassIDNoAlloc(*aClassID);
}
NS_IMETHODIMP
nsHostObjectURI::GetImplementationLanguage(uint32_t *aImplementationLanguage)
{
*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;
}
NS_IMETHODIMP
nsHostObjectURI::GetFlags(uint32_t *aFlags)
{

View File

@ -10,7 +10,6 @@
#include "nsStringGlue.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIProgrammingLanguage.h"
#include "jspubtd.h"
#include "js/GCAPI.h"

View File

@ -146,8 +146,6 @@ static const uint32_t kMaxICCDuration = 2000; // ms
// Trigger a CC if the purple buffer exceeds this size when we check it.
#define NS_CC_PURPLE_LIMIT 200
#define JAVASCRIPT nsIProgrammingLanguage::JAVASCRIPT
// Large value used to specify that a script should run essentially forever
#define NS_UNLIMITED_SCRIPT_RUNTIME (0x40000000LL << 32)

View File

@ -1461,7 +1461,7 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
}
rv = NS_OK;
} else {
moz_free(const_cast<uint8_t *>(aString));
free(const_cast<uint8_t *>(aString));
rv = NS_SUCCESS_ADOPTED_DATA;
}

View File

@ -84,7 +84,7 @@ void
nsTextFragment::ReleaseText()
{
if (mState.mLength && m1b && mState.mInHeap) {
moz_free(m2b); // m1b == m2b as far as moz_free is concerned
free(m2b); // m1b == m2b as far as free is concerned
}
m1b = nullptr;
@ -107,7 +107,7 @@ nsTextFragment::operator=(const nsTextFragment& aOther)
size_t m2bSize = aOther.mState.mLength *
(aOther.mState.mIs2b ? sizeof(char16_t) : sizeof(char));
m2b = static_cast<char16_t*>(moz_malloc(m2bSize));
m2b = static_cast<char16_t*>(malloc(m2bSize));
if (m2b) {
memcpy(m2b, aOther.m2b, m2bSize);
} else {
@ -255,7 +255,7 @@ nsTextFragment::SetTo(const char16_t* aBuffer, int32_t aLength, bool aUpdateBidi
if (first16bit != -1) { // aBuffer contains no non-8bit character
// Use ucs2 storage because we have to
size_t m2bSize = aLength * sizeof(char16_t);
m2b = (char16_t *)moz_malloc(m2bSize);
m2b = (char16_t *)malloc(m2bSize);
if (!m2b) {
return false;
}
@ -268,7 +268,7 @@ nsTextFragment::SetTo(const char16_t* aBuffer, int32_t aLength, bool aUpdateBidi
} else {
// Use 1 byte storage because we can
char* buff = (char *)moz_malloc(aLength * sizeof(char));
char* buff = (char *)malloc(aLength * sizeof(char));
if (!buff) {
return false;
}
@ -326,7 +326,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
if (mState.mIs2b) {
// Already a 2-byte string so the result will be too
char16_t* buff = (char16_t*)moz_realloc(m2b, (mState.mLength + aLength) * sizeof(char16_t));
char16_t* buff = (char16_t*)realloc(m2b, (mState.mLength + aLength) * sizeof(char16_t));
if (!buff) {
return false;
}
@ -348,8 +348,8 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
if (first16bit != -1) { // aBuffer contains no non-8bit character
// The old data was 1-byte, but the new is not so we have to expand it
// all to 2-byte
char16_t* buff = (char16_t*)moz_malloc((mState.mLength + aLength) *
sizeof(char16_t));
char16_t* buff =
(char16_t*)malloc((mState.mLength + aLength) * sizeof(char16_t));
if (!buff) {
return false;
}
@ -363,7 +363,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
mState.mIs2b = true;
if (mState.mInHeap) {
moz_free(m2b);
free(m2b);
}
m2b = buff;
@ -379,14 +379,14 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
// The new and the old data is all 1-byte
char* buff;
if (mState.mInHeap) {
buff = (char*)moz_realloc(const_cast<char*>(m1b),
(mState.mLength + aLength) * sizeof(char));
buff = (char*)realloc(const_cast<char*>(m1b),
(mState.mLength + aLength) * sizeof(char));
if (!buff) {
return false;
}
}
else {
buff = (char*)moz_malloc((mState.mLength + aLength) * sizeof(char));
buff = (char*)malloc((mState.mLength + aLength) * sizeof(char));
if (!buff) {
return false;
}

View File

@ -473,6 +473,10 @@ DOMInterfaces = {
'wrapperCache': False,
},
'FontFaceSetIterator': {
'wrapperCache': False,
},
'FormData': {
'nativeType': 'nsFormData'
},
@ -1525,7 +1529,7 @@ DOMInterfaces = {
'headerFile': 'mozilla/dom/WorkerScope.h',
'nativeType': 'mozilla::dom::workers::WorkerDebuggerGlobalScope',
'implicitJSContext': [
'dump', 'global', 'reportError',
'dump', 'global', 'setImmediate', 'reportError',
],
},

View File

@ -13,6 +13,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsIProgrammingLanguage.h"
#include "nsPIDOMWindow.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"

120
dom/cache/DBSchema.cpp vendored
View File

@ -20,13 +20,14 @@
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/ResponseBinding.h"
#include "Types.h"
#include "nsIContentPolicy.h"
namespace mozilla {
namespace dom {
namespace cache {
const int32_t DBSchema::kMaxWipeSchemaVersion = 4;
const int32_t DBSchema::kLatestSchemaVersion = 4;
const int32_t DBSchema::kMaxWipeSchemaVersion = 5;
const int32_t DBSchema::kLatestSchemaVersion = 5;
const int32_t DBSchema::kMaxEntriesPerStatement = 255;
// If any of the static_asserts below fail, it means that you have changed
@ -51,6 +52,40 @@ static_assert(int(RequestCredentials::Omit) == 0 &&
int(RequestCredentials::Include) == 2 &&
int(RequestCredentials::EndGuard_) == 3,
"RequestCredentials values are as expected");
static_assert(int(RequestContext::Audio) == 0 &&
int(RequestContext::Beacon) == 1 &&
int(RequestContext::Cspreport) == 2 &&
int(RequestContext::Download) == 3 &&
int(RequestContext::Embed) == 4 &&
int(RequestContext::Eventsource) == 5 &&
int(RequestContext::Favicon) == 6 &&
int(RequestContext::Fetch) == 7 &&
int(RequestContext::Font) == 8 &&
int(RequestContext::Form) == 9 &&
int(RequestContext::Frame) == 10 &&
int(RequestContext::Hyperlink) == 11 &&
int(RequestContext::Iframe) == 12 &&
int(RequestContext::Image) == 13 &&
int(RequestContext::Imageset) == 14 &&
int(RequestContext::Import) == 15 &&
int(RequestContext::Internal) == 16 &&
int(RequestContext::Location) == 17 &&
int(RequestContext::Manifest) == 18 &&
int(RequestContext::Object) == 19 &&
int(RequestContext::Ping) == 20 &&
int(RequestContext::Plugin) == 21 &&
int(RequestContext::Prefetch) == 22 &&
int(RequestContext::Script) == 23 &&
int(RequestContext::Serviceworker) == 24 &&
int(RequestContext::Sharedworker) == 25 &&
int(RequestContext::Subresource) == 26 &&
int(RequestContext::Style) == 27 &&
int(RequestContext::Track) == 28 &&
int(RequestContext::Video) == 29 &&
int(RequestContext::Worker) == 30 &&
int(RequestContext::Xmlhttprequest) == 31 &&
int(RequestContext::Xslt) == 32,
"RequestContext values are as expected");
static_assert(int(RequestCache::Default) == 0 &&
int(RequestCache::No_store) == 1 &&
int(RequestCache::Reload) == 2 &&
@ -76,6 +111,35 @@ static_assert(DEFAULT_NAMESPACE == 0 &&
NUMBER_OF_NAMESPACES == 2,
"Namespace values are as expected");
// If the static_asserts below fails, it means that you have changed the
// nsContentPolicy enum in a way that may be incompatible with the existing data
// stored in the DOM Cache. You would need to update the Cache database schema
// accordingly and adjust the failing static_assert.
static_assert(nsIContentPolicy::TYPE_INVALID == 0 &&
nsIContentPolicy::TYPE_OTHER == 1 &&
nsIContentPolicy::TYPE_SCRIPT == 2 &&
nsIContentPolicy::TYPE_IMAGE == 3 &&
nsIContentPolicy::TYPE_STYLESHEET == 4 &&
nsIContentPolicy::TYPE_OBJECT == 5 &&
nsIContentPolicy::TYPE_DOCUMENT == 6 &&
nsIContentPolicy::TYPE_SUBDOCUMENT == 7 &&
nsIContentPolicy::TYPE_REFRESH == 8 &&
nsIContentPolicy::TYPE_XBL == 9 &&
nsIContentPolicy::TYPE_PING == 10 &&
nsIContentPolicy::TYPE_XMLHTTPREQUEST == 11 &&
nsIContentPolicy::TYPE_DATAREQUEST == 11 &&
nsIContentPolicy::TYPE_OBJECT_SUBREQUEST == 12 &&
nsIContentPolicy::TYPE_DTD == 13 &&
nsIContentPolicy::TYPE_FONT == 14 &&
nsIContentPolicy::TYPE_MEDIA == 15 &&
nsIContentPolicy::TYPE_WEBSOCKET == 16 &&
nsIContentPolicy::TYPE_CSP_REPORT == 17 &&
nsIContentPolicy::TYPE_XSLT == 18 &&
nsIContentPolicy::TYPE_BEACON == 19 &&
nsIContentPolicy::TYPE_FETCH == 20 &&
nsIContentPolicy::TYPE_IMAGESET == 21,
"nsContentPolicytType values are as expected");
using mozilla::void_t;
// static
@ -139,6 +203,8 @@ DBSchema::CreateSchema(mozIStorageConnection* aConn)
"request_headers_guard INTEGER NOT NULL, "
"request_mode INTEGER NOT NULL, "
"request_credentials INTEGER NOT NULL, "
"request_contentpolicytype INTEGER NOT NULL, "
"request_context INTEGER NOT NULL, "
"request_cache INTEGER NOT NULL, "
"request_body_id TEXT NULL, "
"response_type INTEGER NOT NULL, "
@ -1021,6 +1087,8 @@ DBSchema::InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
"request_headers_guard, "
"request_mode, "
"request_credentials, "
"request_contentpolicytype, "
"request_context, "
"request_cache, "
"request_body_id, "
"response_type, "
@ -1031,7 +1099,7 @@ DBSchema::InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
"response_body_id, "
"response_security_info, "
"cache_id "
") VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17)"
") VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19)"
), getter_AddRefs(state));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
@ -1059,37 +1127,45 @@ DBSchema::InsertEntry(mozIStorageConnection* aConn, CacheId aCacheId,
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(7,
static_cast<int32_t>(aRequest.contentPolicyType()));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(8,
static_cast<int32_t>(aRequest.context()));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(9,
static_cast<int32_t>(aRequest.requestCache()));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = BindId(state, 8, aRequestBodyId);
rv = BindId(state, 10, aRequestBodyId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(9, static_cast<int32_t>(aResponse.type()));
rv = state->BindInt32Parameter(11, static_cast<int32_t>(aResponse.type()));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindStringParameter(10, aResponse.url());
rv = state->BindStringParameter(12, aResponse.url());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(11, aResponse.status());
rv = state->BindInt32Parameter(13, aResponse.status());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindUTF8StringParameter(12, aResponse.statusText());
rv = state->BindUTF8StringParameter(14, aResponse.statusText());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(13,
rv = state->BindInt32Parameter(15,
static_cast<int32_t>(aResponse.headersGuard()));
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = BindId(state, 14, aResponseBodyId);
rv = BindId(state, 16, aResponseBodyId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindBlobParameter(15, reinterpret_cast<const uint8_t*>
rv = state->BindBlobParameter(17, reinterpret_cast<const uint8_t*>
(aResponse.securityInfo().get()),
aResponse.securityInfo().Length());
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->BindInt32Parameter(16, aCacheId);
rv = state->BindInt32Parameter(18, aCacheId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
rv = state->Execute();
@ -1275,6 +1351,8 @@ DBSchema::ReadRequest(mozIStorageConnection* aConn, EntryId aEntryId,
"request_headers_guard, "
"request_mode, "
"request_credentials, "
"request_contentpolicytype, "
"request_context, "
"request_cache, "
"request_body_id "
"FROM entries "
@ -1318,19 +1396,31 @@ DBSchema::ReadRequest(mozIStorageConnection* aConn, EntryId aEntryId,
aSavedRequestOut->mValue.credentials() =
static_cast<RequestCredentials>(credentials);
int32_t requestContentPolicyType;
rv = state->GetInt32(7, &requestContentPolicyType);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
aSavedRequestOut->mValue.contentPolicyType() =
static_cast<nsContentPolicyType>(requestContentPolicyType);
int32_t requestContext;
rv = state->GetInt32(8, &requestContext);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
aSavedRequestOut->mValue.context() =
static_cast<RequestContext>(requestContext);
int32_t requestCache;
rv = state->GetInt32(7, &requestCache);
rv = state->GetInt32(9, &requestCache);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
aSavedRequestOut->mValue.requestCache() =
static_cast<RequestCache>(requestCache);
bool nullBody = false;
rv = state->GetIsNull(8, &nullBody);
rv = state->GetIsNull(10, &nullBody);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
aSavedRequestOut->mHasBodyId = !nullBody;
if (aSavedRequestOut->mHasBodyId) {
rv = ExtractId(state, 8, &aSavedRequestOut->mBodyId);
rv = ExtractId(state, 10, &aSavedRequestOut->mBodyId);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
}

View File

@ -11,6 +11,7 @@ using HeadersGuardEnum from "mozilla/dom/FetchIPCUtils.h";
using RequestCredentials from "mozilla/dom/FetchIPCUtils.h";
using RequestMode from "mozilla/dom/FetchIPCUtils.h";
using RequestCache from "mozilla/dom/FetchIPCUtils.h";
using RequestContext from "mozilla/dom/FetchIPCUtils.h";
using mozilla::dom::ResponseType from "mozilla/dom/FetchIPCUtils.h";
using mozilla::void_t from "ipc/IPCMessageUtils.h";
using struct nsID from "nsID.h";
@ -54,7 +55,8 @@ struct PCacheRequest
RequestMode mode;
RequestCredentials credentials;
PCacheReadStreamOrVoid body;
uint32_t context;
uint32_t contentPolicyType;
RequestContext context;
RequestCache requestCache;
};

View File

@ -224,7 +224,8 @@ TypeUtils::ToPCacheRequest(PCacheRequest& aOut, InternalRequest* aIn,
aOut.headersGuard() = headers->Guard();
aOut.mode() = aIn->Mode();
aOut.credentials() = aIn->GetCredentialsMode();
aOut.context() = aIn->ContentPolicyType();
aOut.contentPolicyType() = aIn->ContentPolicyType();
aOut.context() = aIn->Context();
aOut.requestCache() = aIn->GetCacheMode();
if (aBodyAction == IgnoreBody) {
@ -367,7 +368,11 @@ TypeUtils::ToInternalRequest(const PCacheRequest& aIn)
internalRequest->SetReferrer(aIn.referrer());
internalRequest->SetMode(aIn.mode());
internalRequest->SetCredentialsMode(aIn.credentials());
internalRequest->SetContentPolicyType(aIn.context());
internalRequest->SetContentPolicyType(aIn.contentPolicyType());
DebugOnly<RequestContext> contextAfterSetContentPolicyType = internalRequest->Context();
internalRequest->SetContext(aIn.context());
MOZ_ASSERT(contextAfterSetContentPolicyType.value == internalRequest->Context(),
"The RequestContext and nsContentPolicyType values should not get out of sync");
internalRequest->SetCacheMode(aIn.requestCache());
nsRefPtr<InternalHeaders> internalHeaders =

View File

@ -174,7 +174,7 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
if (!boundBuffer)
return ErrorInvalidOperation("bufferData: no buffer bound!");
UniquePtr<uint8_t> zeroBuffer((uint8_t*)moz_calloc(size, 1));
UniquePtr<uint8_t> zeroBuffer((uint8_t*)calloc(size, 1));
if (!zeroBuffer)
return ErrorOutOfMemory("bufferData: out of memory");

View File

@ -674,7 +674,7 @@ public:
~AutoFreeBuffer()
{
moz_free(mBuffer);
free(mBuffer);
}
void

View File

@ -37,6 +37,11 @@ namespace IPC {
mozilla::dom::RequestCache::Default,
mozilla::dom::RequestCache::EndGuard_> {};
template<>
struct ParamTraits<mozilla::dom::RequestContext> :
public ContiguousEnumSerializer<mozilla::dom::RequestContext,
mozilla::dom::RequestContext::Audio,
mozilla::dom::RequestContext::EndGuard_> {};
template<>
struct ParamTraits<mozilla::dom::ResponseType> :
public ContiguousEnumSerializer<mozilla::dom::ResponseType,
mozilla::dom::ResponseType::Basic,

View File

@ -38,6 +38,7 @@ InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult
// The default referrer is already about:client.
copy->mContentPolicyType = nsIContentPolicy::TYPE_FETCH;
copy->mContext = RequestContext::Fetch;
copy->mMode = mMode;
copy->mCredentialsMode = mCredentialsMode;
copy->mCacheMode = mCacheMode;
@ -74,6 +75,7 @@ InternalRequest::InternalRequest(const InternalRequest& aOther)
, mURL(aOther.mURL)
, mHeaders(new InternalHeaders(*aOther.mHeaders))
, mContentPolicyType(aOther.mContentPolicyType)
, mContext(aOther.mContext)
, mReferrer(aOther.mReferrer)
, mMode(aOther.mMode)
, mCredentialsMode(aOther.mCredentialsMode)
@ -97,5 +99,80 @@ InternalRequest::~InternalRequest()
{
}
void
InternalRequest::SetContentPolicyType(nsContentPolicyType aContentPolicyType)
{
mContentPolicyType = aContentPolicyType;
switch (aContentPolicyType) {
case nsIContentPolicy::TYPE_OTHER:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_SCRIPT:
mContext = RequestContext::Script;
break;
case nsIContentPolicy::TYPE_IMAGE:
mContext = RequestContext::Image;
break;
case nsIContentPolicy::TYPE_STYLESHEET:
mContext = RequestContext::Style;
break;
case nsIContentPolicy::TYPE_OBJECT:
mContext = RequestContext::Object;
break;
case nsIContentPolicy::TYPE_DOCUMENT:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_SUBDOCUMENT:
mContext = RequestContext::Iframe;
break;
case nsIContentPolicy::TYPE_REFRESH:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_XBL:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_PING:
mContext = RequestContext::Ping;
break;
case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
mContext = RequestContext::Xmlhttprequest;
break;
case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
mContext = RequestContext::Plugin;
break;
case nsIContentPolicy::TYPE_DTD:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_FONT:
mContext = RequestContext::Font;
break;
case nsIContentPolicy::TYPE_MEDIA:
mContext = RequestContext::Audio;
break;
case nsIContentPolicy::TYPE_WEBSOCKET:
mContext = RequestContext::Internal;
break;
case nsIContentPolicy::TYPE_CSP_REPORT:
mContext = RequestContext::Cspreport;
break;
case nsIContentPolicy::TYPE_XSLT:
mContext = RequestContext::Xslt;
break;
case nsIContentPolicy::TYPE_BEACON:
mContext = RequestContext::Beacon;
break;
case nsIContentPolicy::TYPE_FETCH:
mContext = RequestContext::Fetch;
break;
case nsIContentPolicy::TYPE_IMAGESET:
mContext = RequestContext::Imageset;
break;
default:
MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
mContext = RequestContext::Internal;
break;
}
}
} // namespace dom
} // namespace mozilla

View File

@ -25,6 +25,65 @@ class nsPIDOMWindow;
namespace mozilla {
namespace dom {
/*
* The mapping of RequestContext and nsContentPolicyType is currently as the
* following. Note that this mapping is not perfect yet (see the TODO comments
* below for examples), so for now we'll have to keep both an mContext and an
* mContentPolicyType, because we cannot have a two way conversion.
*
* RequestContext | nsContentPolicyType
* ------------------+--------------------
* audio | TYPE_MEDIA
* beacon | TYPE_BEACON
* cspreport | TYPE_CSP_REPORT
* download |
* embed | TYPE_OBJECT
* eventsource |
* favicon |
* fetch | TYPE_FETCH
* font | TYPE_FONT
* form |
* frame | TYPE_SUBDOCUMENT
* hyperlink |
* iframe | TYPE_SUBDOCUMENT
* image | TYPE_IMAGE
* imageset | TYPE_IMAGESET
* import | Not supported by Gecko
* internal | TYPE_DOCUMENT, TYPE_XBL, TYPE_OTHER
* location |
* manifest |
* object | TYPE_OBJECT
* ping | TYPE_PING
* plugin | TYPE_OBJECT_SUBREQUEST
* prefetch |
* script | TYPE_SCRIPT
* serviceworker |
* sharedworker |
* subresource | Not supported by Gecko
* style | TYPE_STYLESHEET
* track | TYPE_MEDIA
* video | TYPE_MEDIA
* worker |
* xmlhttprequest | TYPE_XMLHTTPREQUEST
* xslt | TYPE_XSLT
*
* TODO: Figure out if TYPE_REFRESH maps to anything useful
* TODO: Figure out if TYPE_DTD maps to anything useful
* TODO: Split TYPE_MEDIA into TYPE_AUDIO, TYPE_VIDEO and TYPE_TRACK
* TODO: Split TYPE_XMLHTTPREQUEST and TYPE_DATAREQUEST for EventSource
* TODO: Figure out if TYPE_WEBSOCKET maps to anything useful
* TODO: Differentiate between frame and iframe
* TODO: Add content types for different kinds of workers
* TODO: Add a content type for prefetch
* TODO: Use the content type for manifest when it becomes available
* TODO: Add a content type for location
* TODO: Add a content type for hyperlink
* TODO: Add a content type for form
* TODO: Add a content type for favicon
* TODO: Add a content type for download
* TODO: Split TYPE_OBJECT into TYPE_EMBED and TYPE_OBJECT
*/
class FetchBodyStream;
class Request;
@ -221,9 +280,18 @@ public:
}
void
SetContentPolicyType(nsContentPolicyType aContentPolicyType)
SetContentPolicyType(nsContentPolicyType aContentPolicyType);
RequestContext
Context() const
{
mContentPolicyType = aContentPolicyType;
return mContext;
}
void
SetContext(RequestContext aContext)
{
mContext = aContext;
}
bool
@ -312,9 +380,8 @@ private:
nsRefPtr<InternalHeaders> mHeaders;
nsCOMPtr<nsIInputStream> mBodyStream;
// nsContentPolicyType does not cover the complete set defined in the spec,
// but it is a good start.
nsContentPolicyType mContentPolicyType;
RequestContext mContext;
// Empty string: no-referrer
// "about:client": client (default)

View File

@ -33,7 +33,6 @@ Request::Request(nsIGlobalObject* aOwner, InternalRequest* aRequest)
: FetchBody<Request>()
, mOwner(aOwner)
, mRequest(aRequest)
, mContext(RequestContext::Fetch)
{
}

View File

@ -78,14 +78,20 @@ public:
RequestContext
Context() const
{
return mContext;
return mRequest->Context();
}
// [ChromeOnly]
void
SetContext(RequestContext aContext)
{
mContext = aContext;
mRequest->SetContext(aContext);
}
void
SetContentPolicyType(nsContentPolicyType aContentPolicyType)
{
mRequest->SetContentPolicyType(aContentPolicyType);
}
void
@ -126,7 +132,6 @@ private:
nsRefPtr<InternalRequest> mRequest;
// Lazily created.
nsRefPtr<Headers> mHeaders;
RequestContext mContext;
};
} // namespace dom

View File

@ -14785,14 +14785,14 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
reinterpret_cast<const char*>(mParams.cloneInfo().data().Elements());
size_t uncompressedLength = mParams.cloneInfo().data().Length();
// We don't have a smart pointer class that calls moz_free, so we need to
// We don't have a smart pointer class that calls free, so we need to
// manage | compressed | manually.
{
size_t compressedLength = snappy::MaxCompressedLength(uncompressedLength);
// moz_malloc is equivalent to NS_Alloc, which we use because mozStorage
// malloc is equivalent to NS_Alloc, which we use because mozStorage
// expects to be able to free the adopted pointer with NS_Free.
char* compressed = static_cast<char*>(moz_malloc(compressedLength));
char* compressed = static_cast<char*>(malloc(compressedLength));
if (NS_WARN_IF(!compressed)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -14808,7 +14808,7 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
rv = stmt->BindAdoptedBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
dataBufferLength);
if (NS_WARN_IF(NS_FAILED(rv))) {
moz_free(compressed);
free(compressed);
return rv;
}
}

View File

@ -7,8 +7,6 @@
#ifndef mozilla_dom_indexeddb_indexeddatabase_h__
#define mozilla_dom_indexeddb_indexeddatabase_h__
#include "nsIProgrammingLanguage.h"
#include "js/StructuredClone.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"

View File

@ -836,7 +836,7 @@ CreateBlobImpl(const nsTArray<uint8_t>& aMemoryData,
return nullptr;
}
void* buffer = moz_malloc(length * elementSizeMultiplier);
void* buffer = malloc(length * elementSizeMultiplier);
if (NS_WARN_IF(!buffer)) {
return nullptr;
}

View File

@ -2026,8 +2026,8 @@ TabChild::RecvUpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size,
mOrientation = orientation;
ScreenIntSize oldScreenSize = mInnerSize;
mInnerSize = size;
mWidget->Resize(rect.x + chromeDisp.x, rect.y + chromeDisp.y, size.width, size.height,
true);
mWidget->Resize(0, 0, size.width, size.height,
true);
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
baseWin->SetPositionAndSize(0, 0, size.width, size.height,

View File

@ -80,7 +80,6 @@
#include "nsICancelable.h"
#include "gfxPrefs.h"
#include "nsILoginManagerPrompter.h"
#include "nsPIWindowRoot.h"
#include <algorithm>
using namespace mozilla::dom;
@ -326,36 +325,10 @@ TabParent::CacheFrameLoader(nsFrameLoader* aFrameLoader)
void
TabParent::SetOwnerElement(Element* aElement)
{
// If we held previous content then unregister for its events.
RemoveWindowListeners();
// Update to the new content, and register to listen for events from it.
mFrameElement = aElement;
if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) {
nsCOMPtr<nsPIDOMWindow> window = mFrameElement->OwnerDoc()->GetWindow();
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
if (eventTarget) {
eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
this, false, false);
}
}
TryCacheDPIAndScale();
}
void
TabParent::RemoveWindowListeners()
{
if (mFrameElement && mFrameElement->OwnerDoc()->GetWindow()) {
nsCOMPtr<nsPIDOMWindow> window = mFrameElement->OwnerDoc()->GetWindow();
nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
if (eventTarget) {
eventTarget->RemoveEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
this, false);
}
}
}
void
TabParent::GetAppType(nsAString& aOut)
{
@ -907,7 +880,8 @@ TabParent::RecvSetDimensions(const uint32_t& aFlags,
}
void
TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size,
const nsIntPoint& aChromeDisp)
{
if (mIsDestroyed) {
return;
@ -918,20 +892,12 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size)
if (!mUpdatedDimensions || mOrientation != orientation ||
mDimensions != size || !mRect.IsEqualEdges(rect)) {
nsCOMPtr<nsIWidget> widget = GetWidget();
nsIntRect contentRect = rect;
if (widget) {
contentRect.x += widget->GetClientOffset().x;
contentRect.y += widget->GetClientOffset().y;
}
mUpdatedDimensions = true;
mRect = contentRect;
mRect = rect;
mDimensions = size;
mOrientation = orientation;
nsIntPoint chromeOffset = -LayoutDevicePixel::ToUntyped(GetChildProcessOffset());
unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, chromeOffset);
unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, aChromeDisp);
}
}
@ -2502,7 +2468,7 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
BrowserElementParent::OpenWindowResult opened =
BrowserElementParent::OpenWindowOOP(TabParent::GetFrom(aOpener),
this, aURL, aName, aFeatures);
*aOutWindowOpened = (opened != BrowserElementParent::OPEN_WINDOW_CANCELLED);
*aOutWindowOpened = (opened == BrowserElementParent::OPEN_WINDOW_ADDED);
return true;
}
@ -2774,27 +2740,6 @@ TabParent::DeallocPPluginWidgetParent(mozilla::plugins::PPluginWidgetParent* aAc
return true;
}
nsresult
TabParent::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("MozUpdateWindowPos") && !mIsDestroyed) {
// This event is sent when the widget moved. Therefore we only update
// the position.
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
return NS_OK;
}
nsIntRect windowDims;
NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE);
UpdateDimensions(windowDims, mDimensions);
return NS_OK;
}
return NS_OK;
}
class FakeChannel final : public nsIChannel,
public nsIAuthPromptCallback,
public nsIInterfaceRequestor,

View File

@ -60,7 +60,6 @@ class Element;
struct StructuredCloneData;
class TabParent final : public PBrowserParent
, public nsIDOMEventListener
, public nsITabParent
, public nsIAuthPromptProvider
, public nsISecureBrowserUI
@ -74,8 +73,6 @@ class TabParent final : public PBrowserParent
public:
// nsITabParent
NS_DECL_NSITABPARENT
// nsIDOMEventListener interfaces
NS_DECL_NSIDOMEVENTLISTENER
TabParent(nsIContentParent* aManager,
const TabId& aTabId,
@ -110,8 +107,6 @@ public:
void Destroy();
void RemoveWindowListeners();
virtual bool RecvMoveFocus(const bool& aForward) override;
virtual bool RecvEvent(const RemoteDOMEvent& aEvent) override;
virtual bool RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent) override;
@ -230,7 +225,8 @@ public:
// message-sending functions under a layer of indirection and
// eating the return values
void Show(const ScreenIntSize& size, bool aParentIsActive);
void UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size);
void UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size,
const nsIntPoint& chromeDisp);
void UpdateFrame(const layers::FrameMetrics& aFrameMetrics);
void UIResolutionChanged();
void RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,

View File

@ -54,7 +54,7 @@ EncodedBufferCache::ExtractBlob(nsISupports* aParent,
mDataSize = 0;
mFD = nullptr;
} else {
void* blobData = moz_malloc(mDataSize);
void* blobData = malloc(mDataSize);
NS_ASSERTION(blobData, "out of memory!!");
if (blobData) {

View File

@ -10,19 +10,32 @@
#include "nsComponentManagerUtils.h"
#include "nsThreadUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/RefPtr.h"
#include "SharedThreadPool.h"
namespace mozilla {
PRLogModuleInfo* gMediaTimerLog;
static void EnsureMediaTimerLog()
{
if (!gMediaTimerLog) {
gMediaTimerLog = PR_NewLogModule("MediaTimer");
}
}
NS_IMPL_ADDREF(MediaTimer)
NS_IMPL_RELEASE_WITH_DESTROY(MediaTimer, DispatchDestroy())
MediaTimer::MediaTimer()
: mMonitor("MediaTimer Monitor")
, mTimer(do_CreateInstance("@mozilla.org/timer;1"))
, mCreationTimeStamp(TimeStamp::Now())
, mUpdateScheduled(false)
{
EnsureMediaTimerLog();
TIMER_LOG("MediaTimer::MediaTimer");
// Use the SharedThreadPool to create an nsIThreadPool with a maximum of one
// thread, which is equivalent to an nsIThread for our purposes.
RefPtr<SharedThreadPool> threadPool(
@ -44,6 +57,7 @@ void
MediaTimer::Destroy()
{
MOZ_ASSERT(OnMediaTimerThread());
TIMER_LOG("MediaTimer::Destroy");
// Reject any outstanding entries. There's no need to acquire the monitor
// here, because we're on the timer thread and all other references to us
@ -71,6 +85,7 @@ nsRefPtr<MediaTimerPromise>
MediaTimer::WaitUntil(const TimeStamp& aTimeStamp, const char* aCallSite)
{
MonitorAutoLock mon(mMonitor);
TIMER_LOG("MediaTimer::WaitUntil %lld", RelativeMicroseconds(aTimeStamp));
Entry e(aTimeStamp, aCallSite);
nsRefPtr<MediaTimerPromise> p = e.mPromise.get();
mEntries.push(e);
@ -107,11 +122,15 @@ MediaTimer::UpdateLocked()
mMonitor.AssertCurrentThreadOwns();
mUpdateScheduled = false;
TIMER_LOG("MediaTimer::UpdateLocked");
// Resolve all the promises whose time is up.
TimeStamp now = TimeStamp::Now();
while (!mEntries.empty() && mEntries.top().mTimeStamp <= now) {
mEntries.top().mPromise->Resolve(true, __func__);
DebugOnly<TimeStamp> poppedTimeStamp = mEntries.top().mTimeStamp;
mEntries.pop();
MOZ_ASSERT_IF(!mEntries.empty(), *&poppedTimeStamp <= mEntries.top().mTimeStamp);
}
// If we've got no more entries, cancel any pending timer and bail out.
@ -158,6 +177,7 @@ MediaTimer::ArmTimer(const TimeStamp& aTarget, const TimeStamp& aNow)
// XPCOM timer resolution is in milliseconds. It's important to never resolve
// a timer when mTarget might compare < now (even if very close), so round up.
unsigned long delay = std::ceil((aTarget - aNow).ToMilliseconds());
TIMER_LOG("MediaTimer::ArmTimer delay=%lu", delay);
mCurrentTimerTarget = aTarget;
nsresult rv = mTimer->InitWithFuncCallback(&TimerCallback, this, delay, nsITimer::TYPE_ONE_SHOT);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));

View File

@ -19,6 +19,13 @@
namespace mozilla {
extern PRLogModuleInfo* gMediaTimerLog;
#define TIMER_LOG(x, ...) \
MOZ_ASSERT(gMediaTimerLog); \
PR_LOG(gMediaTimerLog, PR_LOG_DEBUG, ("[MediaTimer=%p relative_t=%lld]" x, this, \
RelativeMicroseconds(TimeStamp::Now()), ##__VA_ARGS__))
// This promise type is only exclusive because so far there isn't a reason for
// it not to be. Feel free to change that.
typedef MediaPromise<bool, bool, /* IsExclusive = */ true> MediaTimerPromise;
@ -62,6 +69,7 @@ private:
{
MOZ_ASSERT(OnMediaTimerThread());
if (TimerIsArmed()) {
TIMER_LOG("MediaTimer::CancelTimerIfArmed canceling timer");
mTimer->Cancel();
mCurrentTimerTarget = TimeStamp();
}
@ -78,9 +86,12 @@ private:
, mPromise(new MediaTimerPromise::Private(aCallSite))
{}
// Define a < overload that reverses ordering because std::priority_queue
// provides access to the largest element, and we want the smallest
// (i.e. the soonest).
bool operator<(const Entry& aOther) const
{
return mTimeStamp < aOther.mTimeStamp;
return mTimeStamp > aOther.mTimeStamp;
}
};
@ -91,6 +102,15 @@ private:
Monitor mMonitor;
nsCOMPtr<nsITimer> mTimer;
TimeStamp mCurrentTimerTarget;
// Timestamps only have relative meaning, so we need a base timestamp for
// logging purposes.
TimeStamp mCreationTimeStamp;
int64_t RelativeMicroseconds(const TimeStamp& aTimeStamp)
{
return (int64_t) (aTimeStamp - mCreationTimeStamp).ToMicroseconds();
}
bool mUpdateScheduled;
};

View File

@ -255,7 +255,7 @@ AnalyserNode::FFTAnalysis()
if (mWriteIndex == 0) {
inputBuffer = mBuffer.Elements();
} else {
inputBuffer = static_cast<float*>(moz_malloc(FftSize() * sizeof(float)));
inputBuffer = static_cast<float*>(malloc(FftSize() * sizeof(float)));
if (!inputBuffer) {
return false;
}
@ -280,7 +280,7 @@ AnalyserNode::FFTAnalysis()
}
if (allocated) {
moz_free(inputBuffer);
free(inputBuffer);
}
return true;
}

View File

@ -52,7 +52,7 @@ private:
uint32_t mChunkSize;
// chunking to 10ms support
FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use moz_free()
FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use free(), not delete
uint32_t mSamplesSaved;
};

View File

@ -603,7 +603,7 @@ MediaEngineGonkVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLeng
: mPhotoDataLength(aLength)
{
mCallbacks.SwapElements(aCallbacks);
mPhotoData = (uint8_t*) moz_malloc(aLength);
mPhotoData = (uint8_t*) malloc(aLength);
memcpy(mPhotoData, aData, mPhotoDataLength);
mMimeType = aMimeType;
}

View File

@ -67,7 +67,7 @@ AudioOutputObserver::AudioOutputObserver()
AudioOutputObserver::~AudioOutputObserver()
{
Clear();
moz_free(mSaved);
free(mSaved);
mSaved = nullptr;
}
@ -75,7 +75,7 @@ void
AudioOutputObserver::Clear()
{
while (mPlayoutFifo->size() > 0) {
moz_free(mPlayoutFifo->Pop());
free(mPlayoutFifo->Pop());
}
// we'd like to touch mSaved here, but we can't if we might still be getting callbacks
}
@ -544,7 +544,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
if (!mStarted) {
mStarted = true;
while (gFarendObserver->Size() > 1) {
moz_free(gFarendObserver->Pop()); // only call if size() > 0
free(gFarendObserver->Pop()); // only call if size() > 0
}
}
@ -557,7 +557,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
gFarendObserver->PlayoutChannels(),
mPlayoutDelay,
length);
moz_free(buffer);
free(buffer);
if (res == -1) {
return;
}

View File

@ -790,6 +790,7 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget,
tabContentBounds.ScaleInverseRoundOut(scaleFactor);
int32_t windowH = tabContentBounds.height + int(chromeSize.y);
// This is actually relative to window-chrome.
nsPoint pluginPosition = AsNsPoint(pluginFrame->GetScreenRect().TopLeft());
// Convert (sourceX, sourceY) to 'real' (not PuppetWidget) screen space.
@ -799,8 +800,8 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget,
nsPoint screenPoint;
switch (sourceSpace) {
case NPCoordinateSpacePlugin:
screenPoint = sourcePoint + pluginPosition +
pluginFrame->GetContentRectRelativeToSelf().TopLeft() / nsPresContext::AppUnitsPerCSSPixel();
screenPoint = sourcePoint + pluginFrame->GetContentRectRelativeToSelf().TopLeft() +
chromeSize + pluginPosition + windowPosition;
break;
case NPCoordinateSpaceWindow:
screenPoint = nsPoint(sourcePoint.x, windowH-sourcePoint.y) +
@ -823,8 +824,8 @@ NPBool nsPluginInstanceOwner::ConvertPointPuppet(PuppetWidget *widget,
nsPoint destPoint;
switch (destSpace) {
case NPCoordinateSpacePlugin:
destPoint = screenPoint - pluginPosition -
pluginFrame->GetContentRectRelativeToSelf().TopLeft() / nsPresContext::AppUnitsPerCSSPixel();
destPoint = screenPoint - pluginFrame->GetContentRectRelativeToSelf().TopLeft() -
chromeSize - pluginPosition - windowPosition;
break;
case NPCoordinateSpaceWindow:
destPoint = screenPoint - windowPosition;

View File

@ -265,13 +265,13 @@ NSCursorInfo::NSCursorInfo(const Cursor* aCursor)
}
}
moz_free(bitmap);
free(bitmap);
}
NSCursorInfo::~NSCursorInfo()
{
if (mCustomImageData) {
moz_free(mCustomImageData);
free(mCustomImageData);
}
}
@ -438,7 +438,7 @@ NSCursor* NSCursorInfo::GetTransparentCursor() const
}
}
moz_free(data);
free(data);
// Fall back to an arrow cursor if (for some reason) the above code failed.
if (!retval) {
@ -528,7 +528,7 @@ void NSCursorInfo::SetHotSpot(nsPoint aHotSpot)
void NSCursorInfo::SetCustomImageData(uint8_t* aData, uint32_t aDataLength)
{
if (mCustomImageData) {
moz_free(mCustomImageData);
free(mCustomImageData);
}
if (aDataLength) {
mCustomImageData = (uint8_t*) moz_xmalloc(aDataLength);

View File

@ -10,6 +10,21 @@
* liability, trademark and document use rules apply.
*/
// To implement FontFaceSet's iterator until we can use setlike.
dictionary FontFaceSetIteratorResult
{
required any value;
required boolean done;
};
// To implement FontFaceSet's iterator until we can use setlike.
[NoInterfaceObject]
interface FontFaceSetIterator {
[Throws] FontFaceSetIteratorResult next();
};
callback FontFaceSetForEachCallback = void (FontFace value, FontFace key, FontFaceSet set);
enum FontFaceSetLoadStatus { "loading", "loaded" };
// Bug 1072762 is for the FontFaceSet constructor.
@ -17,19 +32,16 @@ enum FontFaceSetLoadStatus { "loading", "loaded" };
[Pref="layout.css.font-loading-api.enabled"]
interface FontFaceSet : EventTarget {
// Emulate the Set interface, until we can extend Set correctly.
// Implementing these commented out operations and the iterator is
// bug 1072101.
// readonly attribute unsigned long size;
// Emulate setlike behavior until we can use that directly.
readonly attribute unsigned long size;
[Throws] void add(FontFace font);
boolean has(FontFace font);
[Throws] boolean delete(FontFace font);
void clear();
// Iterator entries();
[NewObject] FontFaceSetIterator entries();
// Iterator keys();
// Iterator values();
// void forEach(ForEachCallback cb, optional any thisArg);
// FontFace iterator;
[NewObject, Alias=keys, Alias="@@iterator"] FontFaceSetIterator values();
[Throws] void forEach(FontFaceSetForEachCallback cb, optional any thisArg);
// -- events for when loading state changes
attribute EventHandler onloading;
@ -52,12 +64,3 @@ interface FontFaceSet : EventTarget {
// loading state, "loading" while one or more fonts loading, "loaded" otherwise
readonly attribute FontFaceSetLoadStatus status;
};
// This provides access to the FontFace objects in the FontFaceSet until we
// get iterators working (bug 1072101). Don't enable the pref for the CSS Font
// Loading API until the iterator is available, as we don't want to expose more
// indexed properties on the Web.
partial interface FontFaceSet {
getter FontFace (unsigned long index);
readonly attribute unsigned long length;
};

View File

@ -15,6 +15,9 @@ interface WorkerDebuggerGlobalScope : EventTarget {
attribute EventHandler onmessage;
[Throws]
void setImmediate(Function handler);
void reportError(DOMString message);
};

View File

@ -246,7 +246,7 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
return;
}
nsCOMPtr<nsIEventTarget> stsThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIEventTarget> stsThread = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_WARN_IF(!stsThread)) {
return;
}

View File

@ -2144,6 +2144,7 @@ class FetchEventRunnable : public WorkerRunnable
bool mIsReload;
RequestMode mRequestMode;
RequestCredentials mRequestCredentials;
nsContentPolicyType mContentPolicyType;
public:
FetchEventRunnable(WorkerPrivate* aWorkerPrivate,
nsMainThreadPtrHandle<nsIInterceptedChannel>& aChannel,
@ -2159,6 +2160,7 @@ public:
// By default we set it to same-origin since normal HTTP fetches always
// send credentials to same-origin websites unless explicitly forbidden.
, mRequestCredentials(RequestCredentials::Same_origin)
, mContentPolicyType(nsIContentPolicy::TYPE_INVALID)
{
MOZ_ASSERT(aWorkerPrivate);
}
@ -2231,6 +2233,12 @@ public:
rv = httpChannel->VisitRequestHeaders(this);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadInfo> loadInfo;
rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_SUCCESS(rv, rv);
mContentPolicyType = loadInfo->GetContentPolicyType();
return NS_OK;
}
@ -2305,6 +2313,8 @@ private:
MOZ_ASSERT(internalReq);
internalReq->SetCreatedByFetchEvent();
request->SetContentPolicyType(mContentPolicyType);
RootedDictionary<FetchEventInit> init(aCx);
init.mRequest.Construct();
init.mRequest.Value() = request;

View File

@ -1677,6 +1677,54 @@ private:
}
};
class DebuggerImmediateRunnable : public WorkerRunnable
{
nsRefPtr<Function> mHandler;
public:
explicit DebuggerImmediateRunnable(WorkerPrivate* aWorkerPrivate,
Function& aHandler)
: WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
mHandler(&aHandler)
{ }
private:
virtual bool
IsDebuggerRunnable() const override
{
return true;
}
virtual bool
PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
{
// Silence bad assertions.
return true;
}
virtual void
PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
bool aDispatchResult) override
{
// Silence bad assertions.
}
virtual bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
{
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
JS::Rooted<JS::Value> callable(aCx, JS::ObjectValue(*mHandler->Callable()));
JS::HandleValueArray args = JS::HandleValueArray::empty();
JS::Rooted<JS::Value> rval(aCx);
if (!JS_CallFunctionValue(aCx, global, callable, args, &rval) &&
!JS_ReportPendingException(aCx)) {
return false;
}
return true;
}
};
void
DummyCallback(nsITimer* aTimer, void* aClosure)
{
@ -2385,6 +2433,7 @@ InterfaceRequestor::InterfaceRequestor(nsIPrincipal* aPrincipal,
callbacks->GetInterface(NS_GET_IID(nsILoadContext),
getter_AddRefs(baseContext));
}
mOuterRequestor = callbacks;
}
mLoadContext = new LoadContext(aPrincipal, baseContext);
@ -2443,6 +2492,13 @@ InterfaceRequestor::GetInterface(const nsIID& aIID, void** aSink)
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsINetworkInterceptController)) &&
mOuterRequestor) {
// If asked for the network intercept controller, ask the outer requestor,
// which could be the docshell.
return mOuterRequestor->GetInterface(aIID, aSink);
}
return NS_NOINTERFACE;
}
@ -6263,6 +6319,19 @@ WorkerPrivate::PostMessageToDebugger(const nsAString& aMessage)
mDebugger->PostMessageToDebugger(aMessage);
}
void
WorkerPrivate::SetDebuggerImmediate(JSContext* aCx, Function& aHandler,
ErrorResult& aRv)
{
AssertIsOnWorkerThread();
nsRefPtr<DebuggerImmediateRunnable> runnable =
new DebuggerImmediateRunnable(this, aHandler);
if (!runnable->Dispatch(aCx)) {
aRv.Throw(NS_ERROR_FAILURE);
}
}
void
WorkerPrivate::ReportErrorToDebugger(const nsAString& aFilename,
uint32_t aLineno,

View File

@ -985,6 +985,9 @@ public:
void
PostMessageToDebugger(const nsAString& aMessage);
void
SetDebuggerImmediate(JSContext* aCx, Function& aHandler, ErrorResult& aRv);
void
ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno,
const nsAString& aMessage);

View File

@ -531,6 +531,13 @@ WorkerDebuggerGlobalScope::PostMessage(const nsAString& aMessage)
mWorkerPrivate->PostMessageToDebugger(aMessage);
}
void
WorkerDebuggerGlobalScope::SetImmediate(JSContext* aCx, Function& aHandler,
ErrorResult& aRv)
{
mWorkerPrivate->SetDebuggerImmediate(aCx, aHandler, aRv);
}
void
WorkerDebuggerGlobalScope::ReportError(JSContext* aCx,
const nsAString& aMessage)

View File

@ -275,6 +275,9 @@ public:
IMPL_EVENT_HANDLER(message)
void
SetImmediate(JSContext* aCx, Function& aHandler, ErrorResult& aRv);
void
ReportError(JSContext* aCx, const nsAString& aMessage);

View File

@ -227,6 +227,7 @@ struct WorkerLoadInfo
already_AddRefed<nsITabChild> GetAnyLiveTabChild();
nsCOMPtr<nsILoadContext> mLoadContext;
nsCOMPtr<nsIInterfaceRequestor> mOuterRequestor;
// Array of weak references to nsITabChild. We do not want to keep TabChild
// actors alive for long after their ActorDestroy() methods are called.

View File

@ -0,0 +1,12 @@
"use strict";
this.onmessage = function (event) {
switch (event.data) {
case "ping":
setImmediate(function () {
postMessage("pong1");
});
postMessage("pong2");
break;
}
};

View File

@ -0,0 +1,3 @@
"use strict"
self.onmessage = function () {};

View File

@ -13,6 +13,8 @@ support-files =
WorkerDebuggerGlobalScope.reportError_childWorker.js
WorkerDebuggerGlobalScope.reportError_debugger.js
WorkerDebuggerGlobalScope.reportError_worker.js
WorkerDebuggerGlobalScope.setImmediate_debugger.js
WorkerDebuggerGlobalScope.setImmediate_worker.js
WorkerDebuggerManager_childWorker.js
WorkerDebuggerManager_worker.js
WorkerDebugger_childWorker.js
@ -45,6 +47,7 @@ support-files =
[test_WorkerDebugger.postMessage.xul]
[test_WorkerDebuggerGlobalScope.enterEventLoop.xul]
[test_WorkerDebuggerGlobalScope.reportError.xul]
[test_WorkerDebuggerGlobalScope.setImmediate.xul]
[test_WorkerDebuggerManager.xul]
[test_bug883784.jsm]
[test_bug883784.xul]

View File

@ -122,7 +122,7 @@ function waitForDebuggerMessage(dbg, message) {
if (message !== message1) {
return;
}
info(true, "Should receive " + message + " message from debugger.");
ok(true, "Should receive " + message + " message from debugger.");
dbg.removeListener(this);
resolve();
}

View File

@ -0,0 +1,43 @@
/*
* This is based on dom/tests/mochitest/beacon/beacon-originheader-handler.sjs.
*/
function handleRequest(request, response)
{
response.setHeader("Cache-Control", "no-cache", false);
response.setHeader("Content-Type", "text/plain", false);
// case XHR-REQUEST: the xhr-request tries to query the
// stored context from the beacon request.
if (request.queryString == "queryContext") {
var context = getState("interceptContext");
// if the beacon already stored the context - return.
if (context) {
response.write(context);
setState("interceptContext", "");
return;
}
// otherwise wait for the beacon request
response.processAsync();
setObjectState("sw-xhr-response", response);
return;
}
// case BEACON-REQUEST: get the beacon context and
// store the context on the server.
var context = request.queryString;
setState("interceptContext", context);
// if there is an xhr-request waiting, return the context now.
try{
getObjectState("sw-xhr-response", function(xhrResponse) {
if (!xhrResponse) {
return;
}
setState("interceptContext", "");
xhrResponse.write(context);
xhrResponse.finish();
});
} catch(e) {
}
}

View File

@ -1,15 +1,119 @@
self.addEventListener("fetch", function(event) {
if (event.request.url.indexOf("index.html") >= 0 ||
event.request.url.indexOf("register.html") >= 0 ||
event.request.url.indexOf("unregister.html") >= 0) {
event.request.url.indexOf("unregister.html") >= 0 ||
event.request.url.indexOf("ping.html") >= 0 ||
event.request.url.indexOf("xml.xml") >= 0 ||
event.request.url.indexOf("csp-violate.sjs") >= 0) {
// Handle pass-through requests
event.respondWith(fetch(event.request));
} else if (event.request.url.indexOf("fetch.txt") >= 0) {
var body = event.request.context == "fetch" ?
"so fetch" : "so unfetch";
event.respondWith(new Response(body));
} else {
// Fail any request that we don't know about.
event.respondWith(Promise.reject());
} else if (event.request.url.indexOf("img.jpg") >= 0) {
if (event.request.context == "image") {
event.respondWith(fetch("realimg.jpg"));
}
} else if (event.request.url.indexOf("responsive.jpg") >= 0) {
if (event.request.context == "imageset") {
event.respondWith(fetch("realimg.jpg"));
}
} else if (event.request.url.indexOf("audio.ogg") >= 0) {
if (event.request.context == "audio") {
event.respondWith(fetch("realaudio.ogg"));
}
} else if (event.request.url.indexOf("video.ogg") >= 0) {
// FIXME: Bug 1147668: This should be "video".
if (event.request.context == "audio") {
event.respondWith(fetch("realaudio.ogg"));
}
} else if (event.request.url.indexOf("beacon.sjs") >= 0) {
if (event.request.url.indexOf("queryContext") == -1) {
event.respondWith(fetch("beacon.sjs?" + event.request.context));
} else {
event.respondWith(fetch(event.request));
}
} else if (event.request.url.indexOf("csp-report.sjs") >= 0) {
respondToServiceWorker(event, "csp-report");
} else if (event.request.url.indexOf("embed") >= 0) {
respondToServiceWorker(event, "embed");
} else if (event.request.url.indexOf("object") >= 0) {
respondToServiceWorker(event, "object");
} else if (event.request.url.indexOf("font") >= 0) {
respondToServiceWorker(event, "font");
} else if (event.request.url.indexOf("iframe") >= 0) {
if (event.request.context == "iframe") {
event.respondWith(fetch("context_test.js"));
}
} else if (event.request.url.indexOf("frame") >= 0) {
// FIXME: Bug 1148044: This should be "frame".
if (event.request.context == "iframe") {
event.respondWith(fetch("context_test.js"));
}
} else if (event.request.url.indexOf("newwindow") >= 0) {
respondToServiceWorker(event, "newwindow");
} else if (event.request.url.indexOf("ping") >= 0) {
respondToServiceWorker(event, "ping");
} else if (event.request.url.indexOf("plugin") >= 0) {
respondToServiceWorker(event, "plugin");
} else if (event.request.url.indexOf("script.js") >= 0) {
if (event.request.context == "script") {
event.respondWith(new Response(""));
}
} else if (event.request.url.indexOf("style.css") >= 0) {
respondToServiceWorker(event, "style");
} else if (event.request.url.indexOf("track") >= 0) {
respondToServiceWorker(event, "track");
} else if (event.request.url.indexOf("xhr") >= 0) {
if (event.request.context == "xmlhttprequest") {
event.respondWith(new Response(""));
}
} else if (event.request.url.indexOf("xslt") >= 0) {
respondToServiceWorker(event, "xslt");
} else if (event.request.url.indexOf("cache") >= 0) {
var cache;
var origContext = event.request.context;
event.respondWith(caches.open("cache")
.then(function(c) {
cache = c;
// Store the Request in the cache.
return cache.put(event.request, new Response("fake"));
}).then(function() {
// Read it back.
return cache.keys(event.request);
}).then(function(res) {
var req = res[0];
// Check to see if the context remained the same.
var success = req.context === origContext;
return clients.matchAll()
.then(function(clients) {
// Report it back to the main page.
clients.forEach(function(c) {
c.postMessage({data: "cache", success: success});
});
})}).then(function() {
// Cleanup.
return caches.delete("cache");
}).then(function() {
return new Response("ack");
}));
}
// Fail any request that we don't know about.
try {
event.respondWith(Promise.reject(event.request.url));
} catch(e) {
// Eat up the possible InvalidStateError exception that we may get if some
// code above has called respondWith too.
}
});
function respondToServiceWorker(event, data) {
event.respondWith(clients.matchAll()
.then(function(clients) {
clients.forEach(function(c) {
c.postMessage({data: data, context: event.request.context});
});
return new Response("ack");
}));
}

View File

@ -0,0 +1,6 @@
function handleRequest(request, response)
{
response.setHeader("Content-Security-Policy", "default-src 'none'; report-uri /tests/dom/workers/test/serviceworkers/fetch/context/csp-report.sjs", false);
response.setHeader("Content-Type", "text/html", false);
response.write("<link rel=stylesheet href=style.css>");
}

View File

@ -1,5 +1,8 @@
<!DOCTYPE html>
<script>
var isAndroid = navigator.userAgent.contains("Android");
var isB2G = !isAndroid && /Mobile|Tablet/.test(navigator.userAgent);
function ok(v, msg) {
window.parent.postMessage({status: "ok", result: !!v, message: msg}, "*");
}
@ -20,8 +23,358 @@
});
}
testFetch()
function testImage() {
return new Promise(function(resolve, reject) {
var img = document.createElement("img");
img.src = "img.jpg";
// The service worker will respond with an existing image only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
img.onload = resolve;
img.onerror = reject;
});
}
function testImageSrcSet() {
return new Promise(function(resolve, reject) {
var img = document.createElement("img");
img.srcset = "responsive.jpg 100w";
// The service worker will respond with an existing image only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
img.onload = resolve;
img.onerror = reject;
});
}
function testPicture() {
return new Promise(function(resolve, reject) {
var pic = document.createElement("picture");
var img = document.createElement("img");
pic.appendChild(img);
img.src = "responsive.jpg?picture";
// The service worker will respond with an existing image only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
img.onload = resolve;
img.onerror = reject;
});
}
function testAudio() {
return new Promise(function(resolve, reject) {
var audio = document.createElement("audio");
audio.src = "audio.ogg";
audio.preload = "metadata";
// The service worker will respond with an existing audio only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
audio.onloadedmetadata = resolve;
audio.onerror = reject;
});
}
function testVideo() {
return new Promise(function(resolve, reject) {
var video = document.createElement("video");
video.src = "video.ogg";
video.preload = "metadata";
// The service worker will respond with an existing video only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
video.onloadedmetadata = resolve;
video.onerror = reject;
});
}
function testBeacon() {
ok(navigator.sendBeacon("beacon.sjs"), "Sending the beacon should succeed");
// query the context from beacon.sjs
return fetch("beacon.sjs?queryContext")
.then(function(r) {
return r.text();
}).then(function(body) {
is(body, "beacon", "The context for the intercepted beacon should be correct");
});
}
function testCSPReport() {
return new Promise(function(resolve, reject) {
var iframe = document.createElement("iframe");
iframe.src = "csp-violate.sjs";
document.documentElement.appendChild(iframe);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "csp-report") {
is(e.data.context, "cspreport", "Expected the cspreport context on a CSP violation report");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testEmbed() {
return new Promise(function(resolve, reject) {
var embed = document.createElement("embed");
embed.src = "embed";
document.documentElement.appendChild(embed);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "embed") {
// FIXME: Bug 1148030: This should be "embed".
is(e.data.context, "object", "Expected the object context on an embed");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testObject() {
return new Promise(function(resolve, reject) {
var object = document.createElement("object");
object.data = "object";
document.documentElement.appendChild(object);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "object") {
is(e.data.context, "object", "Expected the object context on an object");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testFont() {
return new Promise(function(resolve, reject) {
var css = '@font-face { font-family: "sw-font"; src: url("font"); }';
css += '* { font-family: "sw-font"; }';
var style = document.createElement("style");
style.appendChild(document.createTextNode(css));
document.documentElement.appendChild(style);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "font") {
is(e.data.context, "font", "Expected the font context on an font");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testIFrame() {
return new Promise(function(resolve, reject) {
var iframe = document.createElement("iframe");
iframe.src = "iframe";
document.documentElement.appendChild(iframe);
// The service worker will respond with an existing document only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
iframe.onload = resolve;
iframe.onerror = reject;
});
}
function testFrame() {
return new Promise(function(resolve, reject) {
var frame = document.createElement("frame");
frame.src = "frame";
document.documentElement.appendChild(frame);
// The service worker will respond with an existing document only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
frame.onload = resolve;
frame.onerror = reject;
});
}
function testInternal() {
if (isB2G) {
// We can't open new windows on b2g, so skip this part of the test there.
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
// Test this with a new window opened through script. There are of course
// other possible ways of testing this too.
var win = window.open("newwindow", "_blank", "width=100,height=100");
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "newwindow") {
is(e.data.context, "internal", "Expected the internal context on a newly opened window");
navigator.serviceWorker.removeEventListener("message", onMessage);
win.close();
resolve();
}
}, false);
});
}
function testPing() {
return new Promise(function(resolve, reject) {
var iframe = document.createElement("iframe");
iframe.src = "ping.html";
document.documentElement.appendChild(iframe);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "ping") {
is(e.data.context, "ping", "Expected the ping context on an anchor ping");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testPlugin() {
var isMobile = /Mobile|Tablet/.test(navigator.userAgent);
if (isMobile || parent.isMulet()) {
// We can't use plugins on mobile, so skip this part of the test there.
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
var embed = document.createElement("embed");
embed.type = "application/x-test";
embed.setAttribute("posturl", "plugin");
embed.setAttribute("postmode", "stream");
embed.setAttribute("streammode", "normal");
embed.setAttribute("src", "fetch.txt");
document.documentElement.appendChild(embed);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "plugin") {
is(e.data.context, "plugin", "Expected the plugin context on a request coming from a plugin");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testScript() {
return new Promise(function(resolve, reject) {
var script = document.createElement("script");
script.src = "script.js";
document.documentElement.appendChild(script);
// The service worker will respond with an existing script only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
script.onload = resolve;
script.onerror = reject;
});
}
function testStyle() {
return new Promise(function(resolve, reject) {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
document.documentElement.appendChild(link);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "style") {
is(e.data.context, "style", "Expected the style context on a request coming from a stylesheet");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testTrack() {
return new Promise(function(resolve, reject) {
var video = document.createElement("video");
var track = document.createElement("track");
track.src = "track";
video.appendChild(track);
document.documentElement.appendChild(video);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "track") {
// FIXME: Bug 1147668: This should be "track".
is(e.data.context, "audio", "Expected the audio context on a request coming from a track");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testXHR() {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("get", "xhr", true);
xhr.send();
// The service worker will respond with an existing resource only if the
// Request has the correct context, otherwise the Promise will get
// rejected and the test will fail.
xhr.onload = resolve;
xhr.onerror = reject;
});
}
function testXSLT() {
return new Promise(function(resolve, reject) {
var iframe = document.createElement("iframe");
iframe.src = "xml.xml";
document.documentElement.appendChild(iframe);
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "xslt") {
is(e.data.context, "xslt", "Expected the xslt context on an XSLT stylesheet");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
function testCache() {
if (isAndroid) {
// FIXME: Re-enable this test on Android once bug 1148818 gets fixed.
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
// Issue an XHR that will be intercepted by the SW in order to start off
// the test with a RequestContext value that is not the default ("fetch").
// This needs to run inside a fetch event handler because synthesized
// RequestContext objects can only have the "fetch" context, and we'd
// prefer to test the more general case of some other RequestContext value.
var xhr = new XMLHttpRequest();
xhr.open("get", "cache", true);
xhr.send();
navigator.serviceWorker.addEventListener("message", function onMessage(e) {
if (e.data.data == "cache") {
ok(e.data.success, "The RequestContext can be persisted in the cache.");
navigator.serviceWorker.removeEventListener("message", onMessage);
resolve();
}
}, false);
});
}
Promise.all([
testFetch(),
testImage(),
testImageSrcSet(),
testPicture(),
testAudio(),
testVideo(),
testBeacon(),
testCSPReport(),
testEmbed(),
testObject(),
testFont(),
testIFrame(),
testFrame(),
testInternal(),
testPing(),
testPlugin(),
testScript(),
testStyle(),
testTrack(),
testXHR(),
testXSLT(),
// Also, test to see if the type of the request can be persisted in the database.
testCache(),
])
.then(function() {
finish();
}, function(e) {
ok(false, "A promise was rejected: " + e);
finish();
});
</script>

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<script>
onload = function() {
document.querySelector("a").click();
};
</script>
<a ping="ping" href="fetch.txt">link</a>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="xslt"?>
<root/>

View File

@ -30,6 +30,12 @@ support-files =
fetch/context/register.html
fetch/context/unregister.html
fetch/context/context_test.js
fetch/context/realimg.jpg
fetch/context/realaudio.ogg
fetch/context/beacon.sjs
fetch/context/csp-violate.sjs
fetch/context/ping.html
fetch/context/xml.xml
fetch/https/index.html
fetch/https/register.html
fetch/https/unregister.html

View File

@ -17,6 +17,46 @@
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
// Copied from /dom/plugins/test/mochitest/utils.js
function getTestPlugin(pluginName) {
var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
.getService(SpecialPowers.Ci.nsIPluginHost);
var tags = ph.getPluginTags();
var name = pluginName || "Test Plug-in";
for (var tag of tags) {
if (tag.name == name) {
return tag;
}
}
ok(false, "Could not find plugin tag with plugin name '" + name + "'");
return null;
}
function setTestPluginEnabledState(newEnabledState, pluginName) {
var oldEnabledState = SpecialPowers.setTestPluginEnabledState(newEnabledState, pluginName);
if (!oldEnabledState) {
return;
}
var plugin = getTestPlugin(pluginName);
while (plugin.enabledState != newEnabledState) {
// Run a nested event loop to wait for the preference change to
// propagate to the child. Yuck!
SpecialPowers.Services.tm.currentThread.processNextEvent(true);
}
SimpleTest.registerCleanupFunction(function() {
SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
});
}
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function isMulet() {
try {
return SpecialPowers.getBoolPref("b2g.is_mulet");
} catch(e) {
return false;
}
}
var iframe;
function runTest() {
iframe = document.querySelector("iframe");
@ -39,6 +79,12 @@
SimpleTest.waitForExplicitFinish();
onload = function() {
SpecialPowers.pushPrefEnv({"set": [
["beacon.enabled", true],
["browser.send_pings", true],
["browser.send_pings.max_per_link", -1],
["dom.caches.enabled", true],
["dom.image.picture.enabled", true],
["dom.image.srcset.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],

View File

@ -33,14 +33,14 @@
let worker = new Worker(WORKER_URL);
let [dbg, childDbg] = yield promise;
info("Send a request to the worker debugger. This should cause a " +
"response to be received from the worker debugger.");
info("Send a request to the worker debugger. This should cause the " +
"the worker debugger to send a response.");
promise = waitForDebuggerMessage(dbg, "pong");
dbg.postMessage("ping");
yield promise;
info("Send a request to the child worker debugger. This should cause " +
"a response to be received from the child worker debugger.");
"the child worker debugger to send a response.");
promise = waitForDebuggerMessage(childDbg, "pong");
childDbg.postMessage("ping");
yield promise;

View File

@ -33,22 +33,23 @@
let worker = new Worker(WORKER_URL);
let [dbg, childDbg] = yield promise;
info("Send a request to the child worker. This should cause a nested " +
"event loop to be entered.");
info("Send a request to the child worker. This should cause the " +
"child worker debugger to enter a nested event loop.");
promise = waitForDebuggerMessage(childDbg, "paused");
worker.postMessage("child:ping");
yield promise;
info("Send a request to the child worker debugger. This should cause " +
"a second nested event loop to be entered.");
"the child worker debugger to enter a second nested event loop.");
promise = waitForDebuggerMessage(childDbg, "paused");
childDbg.postMessage("eval");
yield promise;
info("Send a request to the child worker debugger. This should cause " +
"the second nested event loop to be left. Check that a response " +
"for the previous request is not received from the child worker " +
"debugger until after the event loop is left.");
"the child worker debugger to leave its second nested event " +
"loop. The child worker debugger should not send a response " +
"for its previous request until after it has left the nested " +
"event loop.");
promise = waitForMultiple([
waitForDebuggerMessage(childDbg, "resumed"),
waitForDebuggerMessage(childDbg, "evalled")
@ -57,9 +58,10 @@
yield promise;
info("Send a request to the child worker debugger. This should cause " +
"the first nested event loop to be left. Check that a response " +
"for the previous request is not received from the child worker " +
"until after the event loop is left.");
"the child worker debugger to leave its first nested event loop." +
"The child worker should not send a response for its earlier " +
"request until after the child worker debugger has left the " +
"nested event loop.");
promise = waitForMultiple([
waitForDebuggerMessage(childDbg, "resumed"),
waitForWorkerMessage(worker, "child:pong")
@ -67,30 +69,30 @@
childDbg.postMessage("resume");
yield promise;
info("Send a request to the worker. This should cause a nested event " +
"loop to be entered.");
info("Send a request to the worker. This should cause the worker " +
"debugger to enter a nested event loop.");
promise = waitForDebuggerMessage(dbg, "paused");
worker.postMessage("ping");
yield promise;
info("Terminate the worker. This should not cause the worker " +
"debugger to stop running.");
"debugger to terminate as well.");
worker.terminate();
worker.onmessage = function () {
ok(false, "Worker should have been terminated.");
};
info("Send a request to the worker debugger. This should cause a " +
"second nested event loop to be entered.");
info("Send a request to the worker debugger. This should cause the " +
"worker debugger to enter a second nested event loop.");
promise = waitForDebuggerMessage(dbg, "paused");
dbg.postMessage("eval");
yield promise;
info("Send a request to the worker debugger. This should cause the " +
"second nested event loop to be left. Check that a response for " +
"the previous request is not received from the worker " +
"debugger until after the event loop is left.");
"worker debugger to leave its second nested event loop. The " +
"worker debugger should not send a response for the previous " +
"request until after leaving the nested event loop.");
promise = waitForMultiple([
waitForDebuggerMessage(dbg, "resumed"),
waitForDebuggerMessage(dbg, "evalled")
@ -98,9 +100,9 @@
dbg.postMessage("resume");
yield promise;
info("Send a request to the child worker debugger. This should cause " +
"the first nested event loop to be left. No response for the " +
"previous request should be received from the worker debugger, " +
info("Send a request to the worker debugger. This should cause the " +
"worker debugger to leave its first nested event loop. The " +
"worker should not send a response for its earlier request, " +
"since it has been terminated.");
promise = waitForMultiple([
waitForDebuggerMessage(dbg, "resumed"),

View File

@ -37,8 +37,8 @@
ok(false, "Debugger error events should not be fired at workers.");
};
info("Send a message to the worker debugger and wait for it to " +
"report an error.");
info("Send a request to the worker debugger. This should cause the " +
"worker debugger to report an error.");
promise = waitForDebuggerError(dbg);
dbg.postMessage("report");
let error = yield promise;
@ -48,8 +48,8 @@
"lineNumber should be line number from which error is reported.");
is(error.message, "reported", "message should be reported.");
info("Send a message to the worker debugger and wait for it to " +
"throw an error.");
info("Send a request to the worker debugger. This should cause the " +
"worker debugger to throw an error.");
promise = waitForDebuggerError(dbg);
dbg.postMessage("throw");
error = yield promise;
@ -59,8 +59,8 @@
"lineNumber should be line number from which error is thrown");
is(error.message, "Error: thrown", "message should be Error: thrown");
info("Send a message to the child worker debugger and wait for it to " +
"report an error.");
info("Send a reqeust to the child worker debugger. This should cause " +
"the child worker debugger to report an error.");
promise = waitForDebuggerError(childDbg);
childDbg.postMessage("report");
error = yield promise;
@ -70,8 +70,8 @@
"lineNumber should be line number from which error is reported.");
is(error.message, "reported", "message should be reported.");
info("Send a message to the child worker debugger and wait for it to " +
"report throw an error.");
info("Send a message to the child worker debugger. This should cause " +
"the child worker debugger to throw an error.");
promise = waitForDebuggerError(childDbg);
childDbg.postMessage("throw");
error = yield promise;

View File

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<window title="Test for WorkerDebuggerGlobalScope.setImmediate"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript" src="dom_worker_helper.js"/>
<script type="application/javascript">
<![CDATA[
const WORKER_URL = "WorkerDebuggerGlobalScope.setImmediate_worker.js";
const DEBUGGER_URL = BASE_URL + "WorkerDebuggerGlobalScope.setImmediate_debugger.js";
function test() {
Task.spawn(function* () {
SimpleTest.waitForExplicitFinish();
let promise = waitForRegister(WORKER_URL, DEBUGGER_URL);
let worker = new Worker(WORKER_URL);
let dbg = yield promise;
info("Send a request to the worker debugger. This should cause a " +
"the worker debugger to send two responses. The worker debugger " +
"should send the second response before the first one, since " +
"the latter is delayed until the next tick of the event loop.");
promise = waitForMultiple([
waitForDebuggerMessage(dbg, "pong2"),
waitForDebuggerMessage(dbg, "pong1")
]);
dbg.postMessage("ping");
yield promise;
SimpleTest.finish();
});
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
<label id="test-result"/>
</window>

View File

@ -25,6 +25,7 @@
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMXULDocument.h"
#include "nsIFormControl.h"
#include "nsIProgrammingLanguage.h"
#include "mozilla/dom/NodeInfo.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
@ -183,7 +184,7 @@ XULContentSinkImpl::~XULContentSinkImpl()
NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
mContextStack.Clear();
moz_free(mText);
free(mText);
}
//----------------------------------------------------------------------
@ -1050,7 +1051,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
{
// Create buffer when we first need it
if (0 == mTextSize) {
mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096);
mText = (char16_t *) malloc(sizeof(char16_t) * 4096);
if (nullptr == mText) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1073,7 +1074,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
}
else {
mTextSize += aLength;
mText = (char16_t *) moz_realloc(mText, sizeof(char16_t) * mTextSize);
mText = (char16_t *) realloc(mText, sizeof(char16_t) * mTextSize);
if (nullptr == mText) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -1452,15 +1452,9 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer,
if (textFound) {
nsString tipText(tooltipText);
LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset();
double scaleFactor = 1.0;
if (shell->GetPresContext()) {
scaleFactor = double(nsPresContext::AppUnitsPerCSSPixel())/
shell->GetPresContext()->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
}
// ShowTooltip expects widget-relative position.
self->ShowTooltip(self->mMouseScreenX - screenDot.x / scaleFactor,
self->mMouseScreenY - screenDot.y / scaleFactor,
tipText);
self->ShowTooltip(self->mMouseScreenX - screenDot.x,
self->mMouseScreenY - screenDot.y,
tipText);
}
}

View File

@ -134,14 +134,14 @@ struct AlignedArray
}
#endif
moz_free(mStorage);
free(mStorage);
mStorage = nullptr;
mPtr = nullptr;
}
MOZ_ALWAYS_INLINE void Realloc(size_t aCount, bool aZero = false)
{
moz_free(mStorage);
free(mStorage);
CheckedInt32 storageByteCount =
CheckedInt32(sizeof(T)) * aCount + (alignment - 1);
if (!storageByteCount.isValid()) {
@ -155,9 +155,9 @@ struct AlignedArray
if (aZero) {
// calloc can be more efficient than new[] for large chunks,
// so we use calloc/malloc/free for everything.
mStorage = static_cast<uint8_t *>(moz_calloc(1, storageByteCount.value()));
mStorage = static_cast<uint8_t *>(calloc(1, storageByteCount.value()));
} else {
mStorage = static_cast<uint8_t *>(moz_malloc(storageByteCount.value()));
mStorage = static_cast<uint8_t *>(malloc(storageByteCount.value()));
}
if (!mStorage) {
mStorage = nullptr;

View File

@ -35,7 +35,7 @@ GLContextProviderNull::CreateHeadless(bool)
}
GLContext*
GLContextProviderNull::GetGlobalContext(ContextFlags)
GLContextProviderNull::GetGlobalContext()
{
return nullptr;
}

View File

@ -6,7 +6,7 @@
#ifndef MOZ_GR_MALLOC_H
#define MOZ_GR_MALLOC_H
// Override malloc() and friends to call moz_malloc() etc, so that we get
// Override malloc() and friends to call moz_xmalloc() etc, so that we get
// predictable, safe OOM crashes rather than relying on the code to handle
// allocation failures reliably.
@ -15,6 +15,5 @@
#define malloc moz_xmalloc
#define calloc moz_xcalloc
#define realloc moz_xrealloc
#define free moz_free
#endif // MOZ_GR_MALLOC_H

View File

@ -189,7 +189,9 @@ AppendToString(std::stringstream& aStream, const FrameMetrics& m,
aStream << nsPrintfCString("] um=%d", m.GetUseDisplayPortMargins()).get();
AppendToString(aStream, m.GetRootCompositionSize(), "] [rcs=");
AppendToString(aStream, m.GetViewport(), "] [v=");
aStream << nsPrintfCString("] [z=(ld=%.3f r=%.3f").get();
aStream << nsPrintfCString("] [z=(ld=%.3f r=%.3f",
m.GetDevPixelsPerCSSPixel().scale,
m.GetPresShellResolution()).get();
AppendToString(aStream, m.GetCumulativeResolution(), " cr=");
AppendToString(aStream, m.GetZoom(), " z=");
AppendToString(aStream, m.GetExtraResolution(), " er=");

View File

@ -145,6 +145,12 @@ DIBTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
void
DIBTextureHost::Updated(const nsIntRegion* aRegion)
{
if (!mCompositor) {
// This can happen if we send textures to a compositable that isn't yet
// attached to a layer.
return;
}
if (!mTextureSource) {
mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
}

Some files were not shown because too many files have changed in this diff Show More