diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index fadb37fc41..c4b9e38797 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -870,10 +870,6 @@ pref("consoleservice.buffered", false); pref("toolkit.storage.pageSize", 2048); #endif -// Enable captive portal detection. -pref("captivedetect.canonicalURL", "http://detectportal.firefox.com/success.txt"); -pref("captivedetect.canonicalContent", "success\n"); - // The url of the manifest we use for ADU pings. pref("ping.manifestURL", "https://marketplace.firefox.com/packaged.webapp"); diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index 76d6665a9b..49f7ab5527 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -68,11 +68,9 @@ XPCOMUtils.defineLazyGetter(this, "libcutils", function () { }); #endif -#ifdef MOZ_CAPTIVEDETECT XPCOMUtils.defineLazyServiceGetter(Services, 'captivePortalDetector', '@mozilla.org/toolkit/captive-detector;1', 'nsICaptivePortalDetector'); -#endif function getContentWindow() { return shell.contentBrowser.contentWindow; diff --git a/b2g/confvars.sh b/b2g/confvars.sh index bcf7f661c9..1bf86c9098 100755 --- a/b2g/confvars.sh +++ b/b2g/confvars.sh @@ -19,7 +19,6 @@ MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official MOZ_SERVICES_COMMON=1 MOZ_SERVICES_METRICS=1 -MOZ_CAPTIVEDETECT=1 MOZ_WEBSMS_BACKEND=1 MOZ_NO_SMART_CARDS=1 diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index ab80e26276..651bddcee8 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -313,9 +313,7 @@ @RESPATH@/components/services-crypto.xpt #endif @RESPATH@/components/services-crypto-component.xpt -#ifdef MOZ_CAPTIVEDETECT @RESPATH@/components/captivedetect.xpt -#endif @RESPATH@/components/shellservice.xpt @RESPATH@/components/shistory.xpt @RESPATH@/components/spellchecker.xpt @@ -616,10 +614,8 @@ @RESPATH@/components/HealthReportComponents.manifest @RESPATH@/components/HealthReportService.js #endif -#ifdef MOZ_CAPTIVEDETECT @RESPATH@/components/CaptivePortalDetectComponents.manifest @RESPATH@/components/captivedetect.js -#endif @RESPATH@/components/TelemetryStartup.js @RESPATH@/components/TelemetryStartup.manifest @RESPATH@/components/XULStore.js diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index dd0ac82455..057a5edf54 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -325,9 +325,7 @@ @RESPATH@/components/saxparser.xpt @RESPATH@/browser/components/sessionstore.xpt @RESPATH@/components/services-crypto-component.xpt -#ifdef MOZ_CAPTIVEDETECT @RESPATH@/components/captivedetect.xpt -#endif @RESPATH@/browser/components/shellservice.xpt #ifdef MOZ_BROWSER_STATUSBAR @RESPATH@/browser/components/status4evar.xpt @@ -535,10 +533,8 @@ @RESPATH@/components/SyncComponents.manifest @RESPATH@/components/Weave.js #endif -#ifdef MOZ_CAPTIVEDETECT @RESPATH@/components/CaptivePortalDetectComponents.manifest @RESPATH@/components/captivedetect.js -#endif @RESPATH@/components/servicesComponents.manifest @RESPATH@/components/cryptoComponents.manifest @RESPATH@/components/TelemetryStartup.js diff --git a/configure.in b/configure.in index 7e5ff49b0d..03596ec107 100644 --- a/configure.in +++ b/configure.in @@ -8038,12 +8038,6 @@ if test -n "$MOZ_SERVICES_CLOUDSYNC"; then AC_DEFINE(MOZ_SERVICES_CLOUDSYNC) fi -dnl Build Captive Portal Detector if required -AC_SUBST(MOZ_CAPTIVEDETECT) -if test -n "$MOZ_CAPTIVEDETECT"; then - AC_DEFINE(MOZ_CAPTIVEDETECT) -fi - dnl Build second screen and casting features for external devices if required AC_SUBST(MOZ_DEVICES) if test -n "$MOZ_DEVICES"; then diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c130430451..2b186a6858 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13708,6 +13708,22 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent, nsCOMPtr referer = refererDoc->GetDocumentURI(); uint32_t refererPolicy = refererDoc->GetReferrerPolicy(); + // get referrer attribute from clicked link and parse it + // if per element referrer is enabled, the element referrer overrules + // the document wide referrer + if (IsElementAnchor(aContent)) { + MOZ_ASSERT(aContent->IsHTMLElement()); + if (Preferences::GetBool("network.http.enablePerElementReferrer", false)) { + nsAutoString referrerPolicy; + if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::referrer, referrerPolicy)) { + uint32_t refPolEnum = mozilla::net::ReferrerPolicyFromString(referrerPolicy); + if (refPolEnum != mozilla::net::RP_Unset) { + refererPolicy = refPolEnum; + } + } + } + } + // referer could be null here in some odd cases, but that's ok, // we'll just load the link w/o sending a referer in those cases. diff --git a/dom/apps/AppsUtils.jsm b/dom/apps/AppsUtils.jsm index 5cb77529f8..b682f48bf4 100644 --- a/dom/apps/AppsUtils.jsm +++ b/dom/apps/AppsUtils.jsm @@ -508,7 +508,7 @@ this.AppsUtils = { let hadCharset = { }; let charset = { }; let netutil = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil); - let contentType = netutil.parseContentType(aContentType, charset, hadCharset); + let contentType = netutil.parseResponseContentType(aContentType, charset, hadCharset); if (aInstallOrigin != aWebappOrigin && !(contentType == "application/x-web-app-manifest+json" || contentType == "application/manifest+json")) { diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 25e7e64d46..04ac9cfe0f 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -198,6 +198,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioChannelManager) #endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCameraManager) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaDevices) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessagesManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeviceStorageStores) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimeManager) @@ -303,6 +304,7 @@ Navigator::Invalidate() #endif mCameraManager = nullptr; + mMediaDevices = nullptr; if (mMessagesManager) { mMessagesManager = nullptr; diff --git a/dom/base/crashtests/1154598.xhtml b/dom/base/crashtests/1154598.xhtml new file mode 100644 index 0000000000..64d5506540 --- /dev/null +++ b/dom/base/crashtests/1154598.xhtml @@ -0,0 +1,9 @@ + + + + + diff --git a/dom/base/crashtests/1157995.html b/dom/base/crashtests/1157995.html new file mode 100644 index 0000000000..5d822c0a68 --- /dev/null +++ b/dom/base/crashtests/1157995.html @@ -0,0 +1,9 @@ + + + + + diff --git a/dom/base/crashtests/1181619.html b/dom/base/crashtests/1181619.html new file mode 100644 index 0000000000..929207964d --- /dev/null +++ b/dom/base/crashtests/1181619.html @@ -0,0 +1,14 @@ + + + + + diff --git a/dom/base/crashtests/crashtests.list b/dom/base/crashtests/crashtests.list index b247569122..bbc2211af5 100644 --- a/dom/base/crashtests/crashtests.list +++ b/dom/base/crashtests/crashtests.list @@ -201,3 +201,6 @@ HTTP(..) load xhr_abortinprogress.html load xhr_empty_datauri.html load xhr_html_nullresponse.html load structured_clone_container_throws.html +load 1154598.xhtml +load 1157995.html +load 1181619.html diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index d31cc79e12..667fb9ae43 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -12153,6 +12153,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout, // New script entry point required, due to the "Create a script" sub-step of // http://www.whatwg.org/specs/web-apps/current-work/#timer-initialisation-steps + nsAutoMicroTask mt; AutoEntryScript entryScript(this, reason, true, aScx->GetNativeContext()); entryScript.TakeOwnershipOfErrorReporting(); JS::CompileOptions options(entryScript.cx()); diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index ca8337ea62..854f575f10 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -48,6 +48,7 @@ #include "mozilla/EventStates.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ScriptSettings.h" +#include "mozilla/Preferences.h" #ifdef LoadImage // Undefine LoadImage to prevent naming conflict with Windows. @@ -940,14 +941,26 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI, loadFlags |= imgILoader::LOAD_CORS_USE_CREDENTIALS; } + // get document wide referrer policy + mozilla::net::ReferrerPolicy referrerPolicy = aDocument->GetReferrerPolicy(); + bool referrerAttributeEnabled = Preferences::GetBool("network.http.enablePerElementReferrer", false); + // if referrer attributes are enabled in preferences, load img referrer attribute + nsresult rv; + if (referrerAttributeEnabled) { + mozilla::net::ReferrerPolicy imgReferrerPolicy = GetImageReferrerPolicy(); + // if the image does not provide a referrer attribute, ignore this + if (imgReferrerPolicy != mozilla::net::RP_Unset) { + referrerPolicy = imgReferrerPolicy; + } + } + // Not blocked. Do the load. nsRefPtr& req = PrepareNextRequest(aImageLoadType); nsIContent* content = AsContent(); - nsresult rv; rv = nsContentUtils::LoadImage(aNewURI, aDocument, aDocument->NodePrincipal(), aDocument->GetDocumentURI(), - aDocument->GetReferrerPolicy(), + referrerPolicy, this, loadFlags, content->LocalName(), getter_AddRefs(req), @@ -1586,3 +1599,11 @@ nsImageLoadingContent::ImageObserver::~ImageObserver() MOZ_COUNT_DTOR(ImageObserver); NS_CONTENT_DELETE_LIST_MEMBER(ImageObserver, this, mNext); } + +// Only HTMLInputElement.h overrides this for tags +// all other subclasses use this one, i.e. ignore referrer attributes +mozilla::net::ReferrerPolicy +nsImageLoadingContent::GetImageReferrerPolicy() +{ + return mozilla::net::RP_Unset; +}; diff --git a/dom/base/nsImageLoadingContent.h b/dom/base/nsImageLoadingContent.h index 8ea77e5837..e3c09f7947 100644 --- a/dom/base/nsImageLoadingContent.h +++ b/dom/base/nsImageLoadingContent.h @@ -25,6 +25,7 @@ #include "nsAutoPtr.h" #include "nsIContentPolicy.h" #include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/net/ReferrerPolicy.h" class nsIURI; class nsIDocument; @@ -203,6 +204,8 @@ protected: */ virtual mozilla::CORSMode GetCORSMode(); + virtual mozilla::net::ReferrerPolicy GetImageReferrerPolicy(); + // Subclasses are *required* to call BindToTree/UnbindFromTree. void BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers); diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index 84dbc7e5f6..c1e528d069 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -174,6 +174,8 @@ nsJSUtils::EvaluateString(JSContext* aCx, MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(aEvaluationGlobal) == aEvaluationGlobal); MOZ_ASSERT_IF(aOffThreadToken, aCompileOptions.noScriptRval); + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(nsContentUtils::IsInMicroTask()); // Unfortunately, the JS engine actually compiles scripts with a return value // in a different, less efficient way. Furthermore, it can't JIT them in many @@ -183,7 +185,6 @@ nsJSUtils::EvaluateString(JSContext* aCx, // aCompileOptions.noScriptRval set to true. aRetValue.setUndefined(); - nsAutoMicroTask mt; nsresult rv = NS_OK; nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 37f5e0a8f6..2a511168e9 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -1850,7 +1850,7 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI) // end up trying to dispatch to a nsFrameLoader, which will complain that // it couldn't find a way to handle application/octet-stream nsAutoCString parsedMime, dummy; - NS_ParseContentType(newMime, parsedMime, dummy); + NS_ParseResponseContentType(newMime, parsedMime, dummy); if (!parsedMime.IsEmpty()) { mChannel->SetContentType(parsedMime); } diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 2a170f5ab8..7e2f7e0c93 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -51,7 +51,6 @@ #include "ImportManager.h" #include "mozilla/dom/EncodingUtils.h" -#include "mozilla/CORSMode.h" #include "mozilla/Attributes.h" #include "mozilla/unused.h" @@ -60,70 +59,41 @@ static PRLogModuleInfo* gCspPRLog; using namespace mozilla; using namespace mozilla::dom; -////////////////////////////////////////////////////////////// -// Per-request data structure -////////////////////////////////////////////////////////////// - -class nsScriptLoadRequest final : public nsISupports { - ~nsScriptLoadRequest() - { - js_free(mScriptTextBuf); - } - -public: - nsScriptLoadRequest(nsIScriptElement* aElement, - uint32_t aVersion, - CORSMode aCORSMode) - : mElement(aElement), - mLoading(true), - mIsInline(true), - mHasSourceMapURL(false), - mScriptTextBuf(nullptr), - mScriptTextLength(0), - mJSVersion(aVersion), - mLineNo(1), - mCORSMode(aCORSMode), - mReferrerPolicy(mozilla::net::RP_Default) - { - } - - NS_DECL_THREADSAFE_ISUPPORTS - - void FireScriptAvailable(nsresult aResult) - { - mElement->ScriptAvailable(aResult, mElement, mIsInline, mURI, mLineNo); - } - void FireScriptEvaluated(nsresult aResult) - { - mElement->ScriptEvaluated(aResult, mElement, mIsInline); - } - - bool IsPreload() - { - return mElement == nullptr; - } - - nsCOMPtr mElement; - bool mLoading; // Are we still waiting for a load to complete? - bool mIsInline; // Is the script inline or loaded? - bool mHasSourceMapURL; // Does the HTTP header have a source map url? - nsString mSourceMapURL; // Holds source map url for loaded scripts - char16_t* mScriptTextBuf; // Holds script text for non-inline scripts. Don't - size_t mScriptTextLength; // use nsString so we can give ownership to jsapi. - uint32_t mJSVersion; - nsCOMPtr mURI; - nsCOMPtr mOriginPrincipal; - nsAutoCString mURL; // Keep the URI's filename alive during off thread parsing. - int32_t mLineNo; - const CORSMode mCORSMode; - mozilla::net::ReferrerPolicy mReferrerPolicy; -}; - // The nsScriptLoadRequest is passed as the context to necko, and thus // it needs to be threadsafe. Necko won't do anything with this // context, but it will AddRef and Release it on other threads. NS_IMPL_ISUPPORTS0(nsScriptLoadRequest) +nsScriptLoadRequestList::~nsScriptLoadRequestList() +{ + Clear(); +} + +void +nsScriptLoadRequestList::Clear() +{ + while (!isEmpty()) { + nsRefPtr first = StealFirst(); + first->Cancel(); + // And just let it go out of scope and die. + } +} + +#ifdef DEBUG +bool +nsScriptLoadRequestList::Contains(nsScriptLoadRequest* aElem) +{ + for (nsScriptLoadRequest* req = getFirst(); + req; req = req->getNext()) { + if (req == aElem) { + return true; + } + } + + return false; +} +#endif // DEBUG + ////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////// @@ -149,20 +119,30 @@ nsScriptLoader::~nsScriptLoader() mParserBlockingRequest->FireScriptAvailable(NS_ERROR_ABORT); } - for (uint32_t i = 0; i < mXSLTRequests.Length(); i++) { - mXSLTRequests[i]->FireScriptAvailable(NS_ERROR_ABORT); + for (nsScriptLoadRequest* req = mXSLTRequests.getFirst(); req; + req = req->getNext()) { + req->FireScriptAvailable(NS_ERROR_ABORT); } - for (uint32_t i = 0; i < mDeferRequests.Length(); i++) { - mDeferRequests[i]->FireScriptAvailable(NS_ERROR_ABORT); + for (nsScriptLoadRequest* req = mDeferRequests.getFirst(); req; + req = req->getNext()) { + req->FireScriptAvailable(NS_ERROR_ABORT); } - for (uint32_t i = 0; i < mAsyncRequests.Length(); i++) { - mAsyncRequests[i]->FireScriptAvailable(NS_ERROR_ABORT); + for (nsScriptLoadRequest* req = mLoadingAsyncRequests.getFirst(); req; + req = req->getNext()) { + req->FireScriptAvailable(NS_ERROR_ABORT); } - for (uint32_t i = 0; i < mNonAsyncExternalScriptInsertedRequests.Length(); i++) { - mNonAsyncExternalScriptInsertedRequests[i]->FireScriptAvailable(NS_ERROR_ABORT); + for (nsScriptLoadRequest* req = mLoadedAsyncRequests.getFirst(); req; + req = req->getNext()) { + req->FireScriptAvailable(NS_ERROR_ABORT); + } + + for(nsScriptLoadRequest* req = mNonAsyncExternalScriptInsertedRequests.getFirst(); + req; + req = req->getNext()) { + req->FireScriptAvailable(NS_ERROR_ABORT); } // Unblock the kids, in case any of them moved to a different document @@ -667,11 +647,14 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) request->mJSVersion = version; if (aElement->GetScriptAsync()) { - mAsyncRequests.AppendElement(request); + request->mIsAsync = true; if (!request->mLoading) { + mLoadedAsyncRequests.AppendElement(request); // The script is available already. Run it ASAP when the event // loop gets a chance to spin. ProcessPendingRequestsAsync(); + } else { + mLoadingAsyncRequests.AppendElement(request); } return false; } @@ -679,6 +662,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) // Violate the HTML5 spec in order to make LABjs and the "order" plug-in // for RequireJS work with their Gecko-sniffed code path. See // http://lists.w3.org/Archives/Public/public-html/2010Oct/0088.html + request->mIsNonAsyncScriptInserted = true; mNonAsyncExternalScriptInsertedRequests.AppendElement(request); if (!request->mLoading) { // The script is available already. Run it ASAP when the event @@ -707,6 +691,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) // Need to maintain order for XSLT-inserted scripts NS_ASSERTION(!mParserBlockingRequest, "Parser-blocking scripts and XSLT scripts in the same doc!"); + request->mIsXSLT = true; mXSLTRequests.AppendElement(request); if (!request->mLoading) { // The script is available already. Run it ASAP when the event @@ -727,7 +712,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) // Web page. NS_ASSERTION(!mParserBlockingRequest, "There can be only one parser-blocking script at a time"); - NS_ASSERTION(mXSLTRequests.IsEmpty(), + NS_ASSERTION(mXSLTRequests.isEmpty(), "Parser-blocking scripts and XSLT scripts in the same doc!"); mParserBlockingRequest = request; ProcessPendingRequestsAsync(); @@ -737,7 +722,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) // The script will be run when it loads or the style sheet loads. NS_ASSERTION(!mParserBlockingRequest, "There can be only one parser-blocking script at a time"); - NS_ASSERTION(mXSLTRequests.IsEmpty(), + NS_ASSERTION(mXSLTRequests.isEmpty(), "Parser-blocking scripts and XSLT scripts in the same doc!"); mParserBlockingRequest = request; return true; @@ -763,7 +748,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) request->mLineNo = aElement->GetScriptLineNumber(); if (aElement->GetParserCreated() == FROM_PARSER_XSLT && - (!ReadyToExecuteScripts() || !mXSLTRequests.IsEmpty())) { + (!ReadyToExecuteScripts() || !mXSLTRequests.isEmpty())) { // Need to maintain order for XSLT-inserted scripts NS_ASSERTION(!mParserBlockingRequest, "Parser-blocking scripts and XSLT scripts in the same doc!"); @@ -782,7 +767,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) NS_ASSERTION(!mParserBlockingRequest, "There can be only one parser-blocking script at a time"); mParserBlockingRequest = request; - NS_ASSERTION(mXSLTRequests.IsEmpty(), + NS_ASSERTION(mXSLTRequests.isEmpty(), "Parser-blocking scripts and XSLT scripts in the same doc!"); return true; } @@ -1148,6 +1133,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, // New script entry point required, due to the "Create a script" sub-step of // http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-block + nsAutoMicroTask mt; AutoEntryScript entryScript(globalObject, "