Bug 1573720 - Convert dom.mapped_arraybuffer.enabled to a static pref. r=mccr8
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 15 Aug 2019 05:31:10 +0000
changeset 488379 fbb952df34648f42973d2a58404d1edd50e77e09
parent 488378 1dea742635b1f839f4230e82eab1b50b72965d99
child 488380 53019621c04ed8460626f88a9d650ffab5d96aa9
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1573720
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1573720 - Convert dom.mapped_arraybuffer.enabled to a static pref. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D41918
dom/xhr/XMLHttpRequestMainThread.cpp
dom/xhr/XMLHttpRequestMainThread.h
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -2853,17 +2853,17 @@ nsresult XMLHttpRequestMainThread::SendI
 
   // Check if we should enable cross-origin upload listeners.
   if (mUpload && mUpload->HasListeners()) {
     mFlagHadUploadListenersOnSend = true;
   }
 
   mIsMappedArrayBuffer = false;
   if (mResponseType == XMLHttpRequestResponseType::Arraybuffer &&
-      IsMappedArrayBufferEnabled()) {
+      StaticPrefs::dom_mapped_arraybuffer_enabled()) {
     nsCOMPtr<nsIURI> uri;
     nsAutoCString scheme;
 
     rv = mChannel->GetURI(getter_AddRefs(uri));
     if (NS_SUCCEEDED(rv)) {
       uri->GetScheme(scheme);
       if (scheme.LowerCaseEqualsLiteral("jar")) {
         mIsMappedArrayBuffer = true;
@@ -2949,30 +2949,16 @@ nsresult XMLHttpRequestMainThread::SendI
 
   if (!mChannel) {
     return MaybeSilentSendFailure(NS_ERROR_DOM_NETWORK_ERR);
   }
 
   return rv;
 }
 
-/* static */
-bool XMLHttpRequestMainThread::IsMappedArrayBufferEnabled() {
-  static bool sMappedArrayBufferAdded = false;
-  static bool sIsMappedArrayBufferEnabled;
-
-  if (!sMappedArrayBufferAdded) {
-    Preferences::AddBoolVarCache(&sIsMappedArrayBufferEnabled,
-                                 "dom.mapped_arraybuffer.enabled", true);
-    sMappedArrayBufferAdded = true;
-  }
-
-  return sIsMappedArrayBufferEnabled;
-}
-
 // http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#dom-xmlhttprequest-setrequestheader
 void XMLHttpRequestMainThread::SetRequestHeader(const nsACString& aName,
                                                 const nsACString& aValue,
                                                 ErrorResult& aRv) {
   NOT_CALLABLE_IN_SYNC_SEND_RV
 
   // Step 1
   if (mState != XMLHttpRequest_Binding::OPENED) {
--- a/dom/xhr/XMLHttpRequestMainThread.h
+++ b/dom/xhr/XMLHttpRequestMainThread.h
@@ -295,20 +295,16 @@ class XMLHttpRequestMainThread final : p
   nsresult SendInternal(const BodyExtractorBase* aBody,
                         bool aBodyIsDocumentOrString = false);
 
   bool IsCrossSiteCORSRequest() const;
   bool IsDeniedCrossSiteCORSRequest();
 
   void UnsuppressEventHandlingAndResume();
 
-  // Check pref "dom.mapped_arraybuffer.enabled" to make sure ArrayBuffer is
-  // supported.
-  static bool IsMappedArrayBufferEnabled();
-
   void MaybeLowerChannelPriority();
 
  public:
   virtual void Send(
       JSContext* aCx,
       const Nullable<
           DocumentOrBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString>&
           aData,
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1623,16 +1623,22 @@
   mirror: always
 
 # Whether window.onappinstalled from "W3C Web Manifest" is enabled
 - name: dom.manifest.onappinstalled
   type: bool
   value: false
   mirror: always
 
+# Enable mapped array buffer by default.
+- name: dom.mapped_arraybuffer.enabled
+  type: bool
+  value: true
+  mirror: always
+
 # This pref is used to enable/disable the `document.autoplayPolicy` API which
 # returns a enum string which presents current autoplay policy and can change
 # overtime based on user session activity.
 - name: dom.media.autoplay.autoplay-policy-api
   type: bool
   value: false
   mirror: always
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5030,19 +5030,16 @@ pref("network.trr.excluded-domains", "lo
 pref("network.traffic_analyzer.enabled", true);
 
 pref("captivedetect.canonicalURL", "http://detectportal.firefox.com/success.txt");
 pref("captivedetect.canonicalContent", "success\n");
 pref("captivedetect.maxWaitingTime", 5000);
 pref("captivedetect.pollingTime", 3000);
 pref("captivedetect.maxRetryCount", 5);
 
-// Enable mapped array buffer by default.
-pref("dom.mapped_arraybuffer.enabled", true);
-
 // The tables used for Safebrowsing phishing and malware checks
 pref("urlclassifier.malwareTable", "goog-malware-proto,goog-unwanted-proto,moztest-harmful-simple,moztest-malware-simple,moztest-unwanted-simple");
 #ifdef MOZILLA_OFFICIAL
   // In official builds, we are allowed to use Google's private phishing
   // list (see bug 1288840).
   pref("urlclassifier.phishTable", "goog-phish-proto,moztest-phish-simple");
 #else
   pref("urlclassifier.phishTable", "googpub-phish-proto,moztest-phish-simple");