Bug 982183 - Put VTTRegion DOM API behind a pref. r=rillian, r=bz, a=sledru
authorRick Eyre <rick.eyre@hotmail.com>
Wed, 12 Mar 2014 13:55:45 -0400
changeset 183439 d5e919d7459131b28ce5eb3de36c6a4860fc73bb
parent 183438 6ed30f0dfd58f8f1ba8779019d9c7c42db3f179f
child 183440 be394c2b331a5bef9a346ae6f3ec86f1f847abe1
push id3350
push userryanvm@gmail.com
push dateWed, 19 Mar 2014 21:00:39 +0000
treeherdermozilla-beta@be394c2b331a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian, bz, sledru
bugs982183
milestone29.0
Bug 982183 - Put VTTRegion DOM API behind a pref. r=rillian, r=bz, a=sledru
content/media/TextTrackRegion.h
content/media/test/test_texttrackcue.html
content/media/test/test_texttrackregion.html
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/VTTCue.webidl
dom/webidl/VTTRegion.webidl
modules/libpref/src/init/all.js
--- a/content/media/TextTrackRegion.h
+++ b/content/media/TextTrackRegion.h
@@ -8,31 +8,38 @@
 #define mozilla_dom_TextTrackRegion_h
 
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/TextTrack.h"
+#include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace dom {
 
 class GlobalObject;
 class TextTrack;
 
 class TextTrackRegion MOZ_FINAL : public nsISupports,
                                   public nsWrapperCache
 {
 public:
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TextTrackRegion)
 
+  static bool RegionsEnabled(JSContext* cx, JSObject* obj)
+  {
+    return Preferences::GetBool("media.webvtt.enabled") &&
+           Preferences::GetBool("media.webvtt.regions.enabled");
+  }
+
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   nsISupports* GetParentObject() const
   {
     return mParent;
   }
 
--- a/content/media/test/test_texttrackcue.html
+++ b/content/media/test/test_texttrackcue.html
@@ -12,17 +12,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body>
 <p id="display"></p>
 <div id="content">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
+SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
+                                   ["media.webvtt.regions.enabled", true]]},
   function() {
     var video = document.createElement("video");
     video.src = "seek.webm";
     video.preload = "auto";
     var trackElement = document.createElement("track");
     trackElement.src = "basic.vtt";
     trackElement.kind = "subtitles";
     document.getElementById("content").appendChild(video);
--- a/content/media/test/test_texttrackregion.html
+++ b/content/media/test/test_texttrackregion.html
@@ -12,17 +12,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body>
 <p id="display"></p>
 <div id="content">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
-SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
+SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true],
+                                   ["media.webvtt.regions.enabled", true]]},
   function() {
     var video = document.createElement("video");
     video.src = "seek.webm";
     video.preload = "auto";
     var trackElement = document.createElement("track");
     trackElement.src = "region.vtt";
     trackElement.kind = "subtitles";
     document.getElementById("content").appendChild(video);
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -1118,17 +1118,17 @@ var interfaceNamesInGlobalScope =
     {name: "USSDReceivedEvent", b2g: true, pref: "dom.mobileconnection.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "ValidityState",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "VideoStreamTrack",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "VTTCue",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    "VTTRegion",
+    {name: "VTTRegion", pref: "media.webvtt.regions.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "VTTRegionList",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "WaveShaperNode",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "WebGLActiveInfo",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "WebGLBuffer",
--- a/dom/webidl/VTTCue.webidl
+++ b/dom/webidl/VTTCue.webidl
@@ -27,16 +27,17 @@ enum DirectionSetting {
  Pref="media.webvtt.enabled"]
 interface VTTCue : EventTarget {
   readonly attribute TextTrack? track;
 
   attribute DOMString id;
   attribute double startTime;
   attribute double endTime;
   attribute boolean pauseOnExit;
+  [Pref="media.webvtt.regions.enabled"]
   attribute DOMString regionId;
   attribute DirectionSetting vertical;
   attribute boolean snapToLines;
   attribute (long or AutoKeyword) line;
   [SetterThrows]
   attribute AlignSetting lineAlign;
   [SetterThrows]
   attribute long position;
--- a/dom/webidl/VTTRegion.webidl
+++ b/dom/webidl/VTTRegion.webidl
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is
  *  http://dev.w3.org/html5/webvtt/#extension-of-the-texttrack-interface-for-region-support
  */
 
-[Constructor, Pref="media.webvtt.enabled"]
+[Constructor, Func="TextTrackRegion::RegionsEnabled"]
 interface VTTRegion {
   readonly attribute TextTrack? track;
            attribute DOMString id;
 
            [SetterThrows]
            attribute double width;
 
            attribute long lines;
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -273,16 +273,17 @@ pref("media.navigator.enabled", true);
 #endif
 
 pref("media.tabstreaming.width", 320);
 pref("media.tabstreaming.height", 240);
 pref("media.tabstreaming.time_per_frame", 40);
 
 // TextTrack support
 pref("media.webvtt.enabled", true);
+pref("media.webvtt.regions.enabled", false);
 
 // Whether to enable MediaSource support
 pref("media.mediasource.enabled", false);
 
 #ifdef MOZ_WEBSPEECH
 pref("media.webspeech.recognition.enable", false);
 #endif
 #ifdef MOZ_WEBM_ENCODER