Quantcast

[HtmlUnit] SVN: [13748] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[HtmlUnit] SVN: [13748] trunk/htmlunit/src

rbri
Revision: 13748
          http://sourceforge.net/p/htmlunit/code/13748
Author:   rbri
Date:     2017-03-15 20:10:13 +0000 (Wed, 15 Mar 2017)
Log Message:
-----------
simple impl for MediaSource.isTypeSupported added (returns always false)

Modified Paths:
--------------
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSource.java

Added Paths:
-----------
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/media/
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSourceTest.java

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml 2017-03-15 20:08:18 UTC (rev 13747)
+++ trunk/htmlunit/src/changes/changes.xml 2017-03-15 20:10:13 UTC (rev 13748)
@@ -8,6 +8,9 @@
 
     <body>
         <release version="2.26" date="???" description="Bugfixes">
+            <action type="add" dev="rbri">
+                JavaScript: simple impl for MediaSource.isTypeSupported added (returns always false).
+            </action>
             <action type="add" dev="asashour">
                 WebClientOptions: add option for screen width/height.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSource.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSource.java 2017-03-15 20:08:18 UTC (rev 13747)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSource.java 2017-03-15 20:10:13 UTC (rev 13748)
@@ -20,6 +20,7 @@
 
 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
 import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
+import com.gargoylesoftware.htmlunit.javascript.configuration.JsxStaticFunction;
 import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser;
 import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget;
 
@@ -37,4 +38,17 @@
     @JsxConstructor
     public MediaSource() {
     }
+
+    /**
+     * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/isTypeSupported">
+     * MDN MediaSource#isTypeSupported </a>
+     *
+     * @param mimeType the mimeType to check
+     * @return indicating if the given MIME type is supported by the
+     * current user agent — this is, if it can successfully create SourceBuffer objects for that MIME type
+     */
+    @JsxStaticFunction
+    public static boolean isTypeSupported(final String mimeType) {
+        return false;
+    }
 }

Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSourceTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSourceTest.java                        (rev 0)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/media/MediaSourceTest.java 2017-03-15 20:10:13 UTC (rev 13748)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2002-2017 Gargoyle Software Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gargoylesoftware.htmlunit.javascript.host.media;
+
+import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.CHROME;
+import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.gargoylesoftware.htmlunit.BrowserRunner;
+import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
+import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented;
+import com.gargoylesoftware.htmlunit.WebDriverTestCase;
+
+/**
+ * Tests for {@link MediaSource}.
+ *
+ * @author Ronald Brill
+ */
+@RunWith(BrowserRunner.class)
+public class MediaSourceTest extends WebDriverTestCase {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected boolean supportsWebDriver() {
+        return true;
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts(DEFAULT = "true",
+            IE = "false")
+    public void inWindow() throws Exception {
+        final String html
+            = "<html>\n"
+            + "<head>\n"
+            + "  <script>\n"
+            + "    function test() {\n"
+            + "      alert('MediaSource' in window);\n"
+            + "    }\n"
+            + "  </script>\n"
+            + "</head>\n"
+            + "<body onload='test()'>\n"
+            + "</body>\n"
+            + "</html>";
+
+        loadPageWithAlerts2(html);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts(DEFAULT = { "true", "true", "false" },
+            CHROME = { "true", "false", "false" },
+            IE = "MediaSource not available")
+    @NotYetImplemented({FF, CHROME})
+    public void isTypeSypported() throws Exception {
+        final String html
+            = "<html>\n"
+            + "<head>\n"
+            + "  <script>\n"
+            + "    function test() {\n"
+            + "      if (!('MediaSource' in window)) {\n"
+            + "        alert('MediaSource not available');\n"
+            + "        return;\n"
+            + "      }\n"
+
+            + "      supported('video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"');\n"
+            + "      supported('video/mp4');\n"
+            + "      supported('');\n"
+            + "    }\n"
+            + "    function supported(mime) {\n"
+            + "      alert(MediaSource.isTypeSupported(mime));\n"
+            + "    }\n"
+            + "  </script>\n"
+            + "</head>\n"
+            + "<body onload='test()'>\n"
+            + "</body>\n"
+            + "</html>";
+
+        loadPageWithAlerts2(html);
+    }
+}


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...