Bug 1442560 - Add a note for deprecating passing a storage option to indexedDB.open(). r=asuth draft
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 05 Mar 2018 20:01:00 +0100
changeset 764509 f087aeb9fdd608fbd0f38b4f846c24fa01dcdfa6
parent 764272 493e45400842b6ccfffb63b58b40b33a0b8154ab
push id101775
push userjhofmann@mozilla.com
push dateWed, 07 Mar 2018 21:13:00 +0000
reviewersasuth
bugs1442560
milestone60.0a1
Bug 1442560 - Add a note for deprecating passing a storage option to indexedDB.open(). r=asuth MozReview-Commit-ID: 44yCmYrPP26
dom/base/nsDeprecatedOperationList.h
dom/indexedDB/IDBFactory.cpp
dom/locales/en-US/chrome/dom/dom.properties
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -42,8 +42,9 @@ DEPRECATED_OPERATION(URLCreateObjectURL_
 DEPRECATED_OPERATION(XMLBaseAttribute)
 DEPRECATED_OPERATION(WindowContentUntrusted)
 DEPRECATED_OPERATION(RegisterProtocolHandlerInsecure)
 DEPRECATED_OPERATION(MixedDisplayObjectSubrequest)
 DEPRECATED_OPERATION(MotionEvent)
 DEPRECATED_OPERATION(OrientationEvent)
 DEPRECATED_OPERATION(ProximityEvent)
 DEPRECATED_OPERATION(AmbientLightEvent)
+DEPRECATED_OPERATION(IDBOpenDBOptions_StorageType)
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -449,16 +449,24 @@ IDBFactory::Open(JSContext* aCx,
                  const nsAString& aName,
                  const IDBOpenDBOptions& aOptions,
                  CallerType aCallerType,
                  ErrorResult& aRv)
 {
   if (!IsChrome() &&
       aOptions.mStorage.WasPassed()) {
 
+    if (mWindow && mWindow->GetExtantDoc()) {
+      mWindow->GetExtantDoc()->WarnOnceAbout(nsIDocument::eIDBOpenDBOptions_StorageType);
+    } else if (!NS_IsMainThread()) {
+      // The method below reports on the main thread too, so we need to make sure we're on a worker.
+      // Workers don't have a WarnOnceAbout mechanism, so this will be reported every time.
+      WorkerPrivate::ReportErrorToConsole("IDBOpenDBOptions_StorageType");
+    }
+
     bool ignore = false;
     // Ignore internal usage on about: pages.
     if (NS_IsMainThread()) {
       nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(*mPrincipalInfo);
       if (principal) {
         nsCOMPtr<nsIURI> uri;
         nsresult rv = principal->GetURI(getter_AddRefs(uri));
         if (NS_SUCCEEDED(rv) && uri) {
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -354,8 +354,10 @@ InvalidKeyframePropertyValue=Keyframe property value “%1$S” is invalid according to the syntax for “%2$S”.
 ReadableStreamReadingFailed=Failed to read data from the ReadableStream: “%S”.
 # LOCALIZATION NOTE: Do not translate "registerProtocolHandler".
 RegisterProtocolHandlerInsecureWarning=Use of the registerProtocolHandler for insecure connections will be removed in version 62.
 MixedDisplayObjectSubrequestWarning=Loading insecure content within a plugin embedded in a secure connection is going to be removed.
 MotionEventWarning=Use of the motion sensor is deprecated.
 OrientationEventWarning=Use of the orientation sensor is deprecated.
 ProximityEventWarning=Use of the proximity sensor is deprecated.
 AmbientLightEventWarning=Use of the ambient light sensor is deprecated.
+# LOCALIZATION NOTE: Do not translate "storage", "indexedDB.open" and "navigator.storage.persist()".
+IDBOpenDBOptions_StorageTypeWarning=The ‘storage’ attribute in options passed to indexedDB.open is deprecated and will soon be removed. To get persistent storage, please use navigator.storage.persist() instead.