Bug 1471843: Remove audioWorklet attribute from Window. r?karlt,baku draft
authorArnaud Bienner <arnaud.bienner@gmail.com>
Tue, 03 Jul 2018 16:58:16 +0200
changeset 814120 113b2d4f3359010355367ed96908b960396ef391
parent 813626 546b7b24b71b371321f0cd7b6b49babd09aeddd7
push id115107
push userbmo:arnaud.bienner@gmail.com
push dateWed, 04 Jul 2018 14:26:06 +0000
reviewerskarlt, baku
bugs1471843
milestone63.0a1
Bug 1471843: Remove audioWorklet attribute from Window. r?karlt,baku MozReview-Commit-ID: 9SJRZ2keJpb
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/webidl/Window.webidl
dom/worklet/tests/mochitest.ini
dom/worklet/tests/test_basic.html
dom/worklet/tests/test_console.html
dom/worklet/tests/test_dump.html
dom/worklet/tests/test_exception.html
dom/worklet/tests/test_import_with_cache.html
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1300,17 +1300,16 @@ nsGlobalWindowInner::FreeInnerObjects()
   mToolbar = nullptr;
   mLocationbar = nullptr;
   mPersonalbar = nullptr;
   mStatusbar = nullptr;
   mScrollbars = nullptr;
 
   mConsole = nullptr;
 
-  mAudioWorklet = nullptr;
   mPaintWorklet = nullptr;
 
   mExternal = nullptr;
   mInstallTrigger = nullptr;
 
   mPerformance = nullptr;
 
 #ifdef MOZ_WEBSPEECH
@@ -1456,17 +1455,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mToolbar)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocationbar)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPersonalbar)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStatusbar)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScrollbars)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCrypto)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mU2F)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsole)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioWorklet)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPaintWorklet)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExternal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInstallTrigger)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIntlUtils)
 
   tmp->TraverseHostObjectURIs(cb);
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mMessageManager)
@@ -1544,17 +1542,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mToolbar)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocationbar)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPersonalbar)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mStatusbar)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mScrollbars)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCrypto)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mU2F)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mConsole)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioWorklet)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPaintWorklet)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mExternal)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mInstallTrigger)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mIntlUtils)
 
   tmp->UnlinkHostObjectURIs();
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mIdleRequestExecutor)
@@ -7990,32 +7987,16 @@ nsGlobalWindowInner::AbstractMainThreadF
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (GetDocGroup()) {
     return GetDocGroup()->AbstractMainThreadFor(aCategory);
   }
   return DispatcherTrait::AbstractMainThreadFor(aCategory);
 }
 
 Worklet*
-nsGlobalWindowInner::GetAudioWorklet(ErrorResult& aRv)
-{
-  if (!mAudioWorklet) {
-    nsIPrincipal* principal = GetPrincipal();
-    if (!principal) {
-      aRv.Throw(NS_ERROR_FAILURE);
-      return nullptr;
-    }
-
-    mAudioWorklet = new Worklet(this, principal, Worklet::eAudioWorklet);
-  }
-
-  return mAudioWorklet;
-}
-
-Worklet*
 nsGlobalWindowInner::GetPaintWorklet(ErrorResult& aRv)
 {
   if (!mPaintWorklet) {
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -701,19 +701,16 @@ public:
   // Exposed only for testing
   static bool
   TokenizeDialogOptions(nsAString& aToken, nsAString::const_iterator& aIter,
                         nsAString::const_iterator aEnd);
   static void
   ConvertDialogOptions(const nsAString& aOptions, nsAString& aResult);
 
   mozilla::dom::Worklet*
-  GetAudioWorklet(mozilla::ErrorResult& aRv);
-
-  mozilla::dom::Worklet*
   GetPaintWorklet(mozilla::ErrorResult& aRv);
 
   void
   GetRegionalPrefsLocales(nsTArray<nsString>& aLocales);
 
   mozilla::dom::IntlUtils*
   GetIntlUtils(mozilla::ErrorResult& aRv);
 
@@ -1375,17 +1372,16 @@ protected:
   RefPtr<mozilla::dom::BarProp> mStatusbar;
   RefPtr<mozilla::dom::BarProp> mScrollbars;
 
   RefPtr<nsGlobalWindowObserver> mObserver;
   RefPtr<mozilla::dom::Crypto>  mCrypto;
   RefPtr<mozilla::dom::U2F> mU2F;
   RefPtr<mozilla::dom::cache::CacheStorage> mCacheStorage;
   RefPtr<mozilla::dom::Console> mConsole;
-  RefPtr<mozilla::dom::Worklet> mAudioWorklet;
   RefPtr<mozilla::dom::Worklet> mPaintWorklet;
   // We need to store an nsISupports pointer to this object because the
   // mozilla::dom::External class doesn't exist on b2g and using the type
   // forward declared here means that ~nsGlobalWindow wouldn't compile because
   // it wouldn't see the ~External function's declaration.
   nsCOMPtr<nsISupports>         mExternal;
   RefPtr<mozilla::dom::InstallTriggerImpl> mInstallTrigger;
 
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -10,17 +10,16 @@
  * http://dev.w3.org/csswg/cssom/
  * http://dev.w3.org/csswg/cssom-view/
  * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html
  * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
  * https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html
  * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
  * https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
  * https://w3c.github.io/requestidlecallback/
- * https://webaudio.github.io/web-audio-api/#widl-Window-audioWorklet
  * https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet
  */
 
 interface ApplicationCache;
 interface IID;
 interface nsIBrowserDOMWindow;
 interface XULControllers;
 
@@ -504,22 +503,16 @@ partial interface Window {
   [Pref="dom.vr.enabled"]
   attribute EventHandler onvrdisplayactivate;
   [Pref="dom.vr.enabled"]
   attribute EventHandler onvrdisplaydeactivate;
   [Pref="dom.vr.enabled"]
   attribute EventHandler onvrdisplaypresentchange;
 };
 
-// https://webaudio.github.io/web-audio-api/#widl-Window-audioWorklet
-partial interface Window {
-  [Pref="dom.audioWorklet.enabled", Throws]
-  readonly attribute Worklet audioWorklet;
-};
-
 // https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet
 partial interface Window {
     [Pref="dom.paintWorklet.enabled", Throws]
     readonly attribute Worklet paintWorklet;
 };
 
 Window implements WindowOrWorkerGlobalScope;
 
--- a/dom/worklet/tests/mochitest.ini
+++ b/dom/worklet/tests/mochitest.ini
@@ -1,21 +1,23 @@
 [DEFAULT]
+scheme = https
 skip-if = release_or_beta
 support-files =
   common.js
 
 [test_basic.html]
 [test_console.html]
 support-files=worklet_console.js
 [test_import_with_cache.html]
 skip-if = verify
 support-files=server_import_with_cache.sjs
 [test_dump.html]
 support-files=worklet_dump.js
 [test_audioWorklet_insecureContext.html]
+scheme = http
 [test_audioWorklet.html]
 support-files=worklet_audioWorklet.js
-scheme = https
 [test_exception.html]
 support-files=worklet_exception.js
 [test_paintWorklet.html]
+scheme = http
 support-files=worklet_paintWorklet.js
--- a/dom/worklet/tests/test_basic.html
+++ b/dom/worklet/tests/test_basic.html
@@ -7,51 +7,52 @@
   <script type="application/javascript" src="common.js"></script>
 </head>
 <body>
 
 <script type="application/javascript">
 
 function configureTest() {
   return SpecialPowers.pushPrefEnv(
-    {"set": [["dom.audioWorklet.enabled", true],
+    {"set": [["dom.audioworklet.enabled", true],
              ["dom.worklet.enabled", true]]});
 }
 
 // This function is called into an iframe.
 function runTestInIframe() {
-  ok(!!audioWorklet, "audioWorklet exists");
+  var audioContext = new AudioContext();
+  ok(!!audioContext.audioWorklet, "audioContext.audioWorklet exists");
 
   // First loading
-  audioWorklet.import("common.js")
+  audioContext.audioWorklet.import("common.js")
   .then(() => {
     ok(true, "Import should load a resource.");
   })
 
   // Second loading - same file
   .then(() => {
-    return audioWorklet.import("common.js")
+    return audioContext.audioWorklet.import("common.js")
   })
   .then(() => {
     ok(true, "Import should load a resource.");
   })
 
   // 3rd loading - a network error
   .then(() => {
-    return audioWorklet.import("404.js");
+    return audioContext.audioWorklet.import("404.js");
   })
   .then(() => {
     ok(false, "The loading should fail.");
   }, () => {
     ok(true, "The loading should fail.");
   })
 
   // 4th loading - a network error
   .then(() => {
-    return audioWorklet.import("404.js");
+    return audioContext.audioWorklet.import("404.js");
   })
   .then(() => {
     ok(false, "The loading should fail.");
   }, () => {
     ok(true, "The loading should fail.");
   })
 
   // done
--- a/dom/worklet/tests/test_console.html
+++ b/dom/worklet/tests/test_console.html
@@ -28,20 +28,21 @@ function configureTest() {
         }
       }
     }
   }
 
   var cl = new consoleListener();
 
   return SpecialPowers.pushPrefEnv(
-    {"set": [["dom.audioWorklet.enabled", true],
+    {"set": [["dom.audioworklet.enabled", true],
              ["dom.worklet.enabled", true]]});
 }
 
 // This function is called into an iframe.
 function runTestInIframe() {
-  audioWorklet.import("worklet_console.js");
+  var audioContext = new AudioContext();
+  audioContext.audioWorklet.import("worklet_console.js");
 }
 
 </script>
 </body>
 </html>
--- a/dom/worklet/tests/test_dump.html
+++ b/dom/worklet/tests/test_dump.html
@@ -7,23 +7,24 @@
   <script type="application/javascript" src="common.js"></script>
 </head>
 <body>
 
 <script type="application/javascript">
 
 function configureTest() {
   return SpecialPowers.pushPrefEnv(
-    {"set": [["dom.audioWorklet.enabled", true],
+    {"set": [["dom.audioworklet.enabled", true],
              ["dom.worklet.enabled", true]]});
 }
 
 // This function is called into an iframe.
 function runTestInIframe() {
-  audioWorklet.import("worklet_dump.js")
+  var audioContext = new AudioContext();
+  audioContext.audioWorklet.import("worklet_dump.js")
   .then(() => {
     ok(true, "All good!");
     SimpleTest.finish();
   });
 }
 </script>
 </body>
 </html>
--- a/dom/worklet/tests/test_exception.html
+++ b/dom/worklet/tests/test_exception.html
@@ -7,33 +7,34 @@
   <script type="application/javascript" src="common.js"></script>
 </head>
 <body>
 
 <script type="application/javascript">
 
 function configureTest() {
   return SpecialPowers.pushPrefEnv(
-    {"set": [["dom.audioWorklet.enabled", true],
+    {"set": [["dom.audioworklet.enabled", true],
              ["dom.worklet.enabled", true]]});
 }
 
 // This function is called into an iframe.
 function runTestInIframe() {
   // This loading should fail
-  audioWorklet.import("404.js")
+  var audioContext = new AudioContext();
+  audioContext.audioWorklet.import("404.js")
   .then(() => {
     ok(false, "We should not be called!");
   }, () => {
     ok(true, "The script thrown but we are still here.");
   })
 
   // This should throw from JS
   .then(() => {
-    return audioWorklet.import("worklet_exception.js")
+    return audioContext.audioWorklet.import("worklet_exception.js")
   })
   .then(() => {
     ok(false, "We should not be called!");
   }, () => {
     ok(true, "The script thrown but we are still here.");
   })
 
   .then(() => {
--- a/dom/worklet/tests/test_import_with_cache.html
+++ b/dom/worklet/tests/test_import_with_cache.html
@@ -7,24 +7,25 @@
   <script type="application/javascript" src="common.js"></script>
 </head>
 <body>
 
 <script type="application/javascript">
 
 function configureTest() {
   return SpecialPowers.pushPrefEnv(
-    {"set": [["dom.audioWorklet.enabled", true],
+    {"set": [["dom.audioworklet.enabled", true],
              ["dom.worklet.enabled", true]]});
 }
 
 // This function is called into an iframe.
 function runTestInIframe() {
+  var audioContext = new AudioContext();
   function loading() {
-    audioWorklet.import("server_import_with_cache.sjs")
+    audioContext.audioWorklet.import("server_import_with_cache.sjs")
     .then(() => {
       ok(true, "Import should load a resource.");
     }, () => {
       ok(false, "Import should load a resource.");
     })
     .then(() => {
       done();
     });