HTMLElement factory doesn't need to call MediaPlayer::isAvailable
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 20:11:52 +0000 (20:11 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 20:11:52 +0000 (20:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183946
<rdar://problem/38802687>

Reviewed by Youenn Fablet.

Source/WebCore:

Test: media/media-disabled.html

* dom/make_names.pl:
(printConstructorInterior):
* page/Settings.yaml:
* page/SettingsDefaultValues.h:

LayoutTests:

* media/media-disabled-expected.txt: Added.
* media/media-disabled.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229915 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/media-disabled-expected.txt [new file with mode: 0644]
LayoutTests/media/media-disabled.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/make_names.pl
Source/WebCore/page/Settings.yaml
Source/WebCore/page/SettingsDefaultValues.h

index c300ea8..aa6be8f 100644 (file)
@@ -1,3 +1,14 @@
+2018-03-23  Eric Carlson  <eric.carlson@apple.com>
+
+        HTMLElement factory doesn't need to call MediaPlayer::isAvailable
+        https://bugs.webkit.org/show_bug.cgi?id=183946
+        <rdar://problem/38802687>
+
+        Reviewed by Youenn Fablet.
+
+        * media/media-disabled-expected.txt: Added.
+        * media/media-disabled.html: Added.
+
 2018-03-23  Ryan Haddad  <ryanhaddad@apple.com>
 
         Only enable LayoutTest fast/css/apple-system-control-colors.html on macOS.
diff --git a/LayoutTests/media/media-disabled-expected.txt b/LayoutTests/media/media-disabled-expected.txt
new file mode 100644 (file)
index 0000000..58dc64d
--- /dev/null
@@ -0,0 +1,15 @@
+RUN(internals.settings.setMediaEnabled(false))
+RUN(video = document.createElement("video"))
+EXPECTED (video instanceof HTMLVideoElement == 'false') OK
+EXPECTED (video instanceof HTMLUnknownElement == 'true') OK
+RUN(audio = document.createElement("audio"))
+EXPECTED (audio instanceof HTMLAudioElement == 'false') OK
+EXPECTED (audio instanceof HTMLUnknownElement == 'true') OK
+
+RUN(internals.settings.setMediaEnabled(true))
+RUN(video = document.createElement("video"))
+EXPECTED (video instanceof HTMLVideoElement == 'true') OK
+RUN(audio = document.createElement("audio"))
+EXPECTED (audio instanceof HTMLAudioElement == 'true') OK
+END OF TEST
+
diff --git a/LayoutTests/media/media-disabled.html b/LayoutTests/media/media-disabled.html
new file mode 100644 (file)
index 0000000..c01b809
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>media-disabled</title>
+    <script src=video-test.js></script>
+    <script>
+        
+        window.addEventListener('load', event => {
+            run("internals.settings.setMediaEnabled(false)");
+            run('video = document.createElement("video")');
+            testExpected('video instanceof HTMLVideoElement', false);
+            testExpected('video instanceof HTMLUnknownElement', true);
+
+            run('audio = document.createElement("audio")');
+            testExpected('audio instanceof HTMLAudioElement', false);
+            testExpected('audio instanceof HTMLUnknownElement', true);
+
+            consoleWrite("");
+            run("internals.settings.setMediaEnabled(true)");
+            run('video = document.createElement("video")');
+            testExpected('video instanceof HTMLVideoElement', true);
+
+            run('audio = document.createElement("audio")');
+            testExpected('audio instanceof HTMLAudioElement', true);
+
+            endTest();
+        });
+    </script>
+</head>
+<body>
+</body>
+</html>
+
+
index 00fb17a..544d1b0 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-23  Eric Carlson  <eric.carlson@apple.com>
+
+        HTMLElement factory doesn't need to call MediaPlayer::isAvailable
+        https://bugs.webkit.org/show_bug.cgi?id=183946
+        <rdar://problem/38802687>
+
+        Reviewed by Youenn Fablet.
+
+        Test: media/media-disabled.html
+
+        * dom/make_names.pl:
+        (printConstructorInterior):
+        * page/Settings.yaml:
+        * page/SettingsDefaultValues.h:
+
 2018-03-23  David Kilzer  <ddkilzer@apple.com>
 
         Stop using dispatch_set_target_queue()
index 1b30002..b1e76cf 100755 (executable)
@@ -412,7 +412,7 @@ sub printConstructorInterior
     # instead of having all the support for this here in this script?
     if ($enabledTags{$tagName}{wrapperOnlyIfMediaIsAvailable}) {
         print F <<END
-    if (!MediaPlayer::isAvailable() || !document.settings().mediaEnabled())
+    if (!document.settings().mediaEnabled())
         return $parameters{fallbackInterfaceName}::create($constructorTagName, document);
     
 END
index 5381e53..3fa1034 100644 (file)
@@ -328,7 +328,7 @@ requestAnimationFrameEnabled:
 cookieEnabled:
   initial: true
 mediaEnabled:
-  initial: true
+  initial: defaultMediaEnabled
 DOMPasteAllowed:
   initial: false
 
index 3ea8110..0f021e9 100644 (file)
@@ -98,4 +98,10 @@ static const bool defaultUnifiedTextCheckerEnabled = false;
 static const bool defaultSmartInsertDeleteEnabled = true;
 static const bool defaultSelectTrailingWhitespaceEnabled = false;
 
+#if ENABLE(VIDEO) && (USE(AVFOUNDATION) || USE(GSTREAMER))
+static const bool defaultMediaEnabled = true;
+#else
+static const bool defaultMediaEnabled = false;
+#endif
+
 }