Title: [189023] trunk
Revision
189023
Author
[email protected]
Date
2015-08-27 07:46:08 -0700 (Thu, 27 Aug 2015)

Log Message

Initial infrastructure of media controls testing
https://bugs.webkit.org/show_bug.cgi?id=148426
<rdar://problem/22417286>

Reviewed by Eric Carlson.

Source/WebCore:

Expose a JS API from Internals that allows a layout test
to ask the controls instance what it thinks it is
doing.

Test: media/controls/basic.html

* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.getCurrentControlsStatus): New method. Currently
returns a simple JSON string.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): Call into
the controls instance.
* html/HTMLMediaElement.h:
* testing/Internals.cpp:
(WebCore::Internals::getCurrentMediaControlsStatusForElement): Link
between the Internals API and the HTMLMediaElement.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Very simple test that calls into the status object
of the media controls instance.

* media/controls/basic-expected.txt: Added.
* media/controls/basic.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189022 => 189023)


--- trunk/LayoutTests/ChangeLog	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/LayoutTests/ChangeLog	2015-08-27 14:46:08 UTC (rev 189023)
@@ -1,3 +1,17 @@
+2015-08-27  Dean Jackson  <[email protected]>
+
+        Initial infrastructure of media controls testing
+        https://bugs.webkit.org/show_bug.cgi?id=148426
+        <rdar://problem/22417286>
+
+        Reviewed by Eric Carlson.
+
+        Very simple test that calls into the status object
+        of the media controls instance.
+
+        * media/controls/basic-expected.txt: Added.
+        * media/controls/basic.html: Added.
+
 2015-08-26  Wenson Hsieh  <[email protected]>
 
         Add a Layout test for r188991

Added: trunk/LayoutTests/media/controls/basic-expected.txt (0 => 189023)


--- trunk/LayoutTests/media/controls/basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/controls/basic-expected.txt	2015-08-27 14:46:08 UTC (rev 189023)
@@ -0,0 +1,10 @@
+This is a basic test of the internal controls status API.
+
+This test only runs in DRT!
+
+
+EVENT(canplaythrough)
+TEST(currentStatus != null) OK
+EXPECTED (currentStatus.status == 'ok') OK
+END OF TEST
+
Property changes on: trunk/LayoutTests/media/controls/basic-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/media/controls/basic.html (0 => 189023)


--- trunk/LayoutTests/media/controls/basic.html	                        (rev 0)
+++ trunk/LayoutTests/media/controls/basic.html	2015-08-27 14:46:08 UTC (rev 189023)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            var video;
+            var currentStatus;
+
+            function init()
+            {
+                findMediaElement();
+                video.src = "" "../content/test");
+
+                waitForEvent("canplaythrough", canplaythrough);
+                waitForEventAndFail("error");
+            }
+
+            function canplaythrough()
+            {
+                if (!window.testRunner)
+                    return;
+
+                currentStatus = JSON.parse(internals.getCurrentMediaControlsStatusForElement(video));
+                test("currentStatus != null");
+                if (currentStatus)
+                    testExpected("currentStatus.status", "ok");
+                endTest();
+            }
+        </script>
+    </head>
+    <body _onload_="init()">
+        <p>This is a basic test of the internal controls status API.</p>
+        <p>This test only runs in DRT!</p>
+        <video controls></video>
+    </body>
+</html>
Property changes on: trunk/LayoutTests/media/controls/basic.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (189022 => 189023)


--- trunk/Source/WebCore/ChangeLog	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/ChangeLog	2015-08-27 14:46:08 UTC (rev 189023)
@@ -1,3 +1,30 @@
+2015-08-27  Dean Jackson  <[email protected]>
+
+        Initial infrastructure of media controls testing
+        https://bugs.webkit.org/show_bug.cgi?id=148426
+        <rdar://problem/22417286>
+
+        Reviewed by Eric Carlson.
+
+        Expose a JS API from Internals that allows a layout test
+        to ask the controls instance what it thinks it is
+        doing.
+
+        Test: media/controls/basic.html
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.getCurrentControlsStatus): New method. Currently
+        returns a simple JSON string.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus): Call into
+        the controls instance.
+        * html/HTMLMediaElement.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::getCurrentMediaControlsStatusForElement): Link
+        between the Internals API and the HTMLMediaElement.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2015-08-27  Gyuyoung Kim  <[email protected]>
 
         [EFL] Move RenderThemeEfl.cpp|h from WebCore/platform/efl to WebCore/rendering

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (189022 => 189023)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2015-08-27 14:46:08 UTC (rev 189023)
@@ -2087,6 +2087,13 @@
         this.setNeedsTimelineMetricsUpdate();
         this.updateTimelineMetricsIfNeeded();
         this.drawTimelineBackground();
+    },
+
+    getCurrentControlsStatus: function ()
+    {
+        return JSON.stringify({
+            status: "ok"
+        });
     }
 
 };

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (189022 => 189023)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2015-08-27 14:46:08 UTC (rev 189023)
@@ -6280,6 +6280,39 @@
 
     setPageScaleFactorProperty(exec, controllerValue, page->pageScaleFactor());
 }
+
+String HTMLMediaElement::getCurrentMediaControlsStatus()
+{
+    DOMWrapperWorld& world = ensureIsolatedWorld();
+    ScriptController& scriptController = document().frame()->script();
+    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
+    JSC::ExecState* exec = globalObject->globalExec();
+    JSC::JSLockHolder lock(exec);
+
+    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
+    JSC::JSObject* controllerObject = controllerValue.toObject(exec);
+
+    if (exec->hadException())
+        return "";
+
+    JSC::JSValue functionValue = controllerObject->get(exec, JSC::Identifier::fromString(exec, "getCurrentControlsStatus"));
+    if (exec->hadException() || functionValue.isUndefinedOrNull())
+        return "";
+
+    JSC::JSObject* function = functionValue.toObject(exec);
+    JSC::CallData callData;
+    JSC::CallType callType = function->methodTable()->getCallData(function, callData);
+    JSC::MarkedArgumentBuffer argList;
+    if (callType == JSC::CallTypeNone)
+        return "";
+
+    JSC::JSValue outputValue = JSC::call(exec, function, callType, callData, controllerObject, argList);
+
+    if (exec->hadException())
+        return "";
+
+    return outputValue.getString(exec);
+}
 #endif // ENABLE(MEDIA_CONTROLS_SCRIPT)
 
 unsigned long long HTMLMediaElement::fileSize() const

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (189022 => 189023)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2015-08-27 14:46:08 UTC (rev 189023)
@@ -434,6 +434,7 @@
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     void pageScaleFactorChanged();
+    WEBCORE_EXPORT String getCurrentMediaControlsStatus();
 #endif
 
     MediaControlsHost* mediaControlsHost() { return m_mediaControlsHost.get(); }

Modified: trunk/Source/WebCore/testing/Internals.cpp (189022 => 189023)


--- trunk/Source/WebCore/testing/Internals.cpp	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/testing/Internals.cpp	2015-08-27 14:46:08 UTC (rev 189023)
@@ -3052,4 +3052,18 @@
     return pathString;
 }
 
+
+String Internals::getCurrentMediaControlsStatusForElement(HTMLMediaElement* mediaElement)
+{
+#if !ENABLE(MEDIA_CONTROLS_SCRIPT)
+    UNUSED_PARAM(mediaElement);
+    return String();
+#else
+    if (!mediaElement)
+        return String();
+
+    return mediaElement->getCurrentMediaControlsStatus();
+#endif
 }
+
+}

Modified: trunk/Source/WebCore/testing/Internals.h (189022 => 189023)


--- trunk/Source/WebCore/testing/Internals.h	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/testing/Internals.h	2015-08-27 14:46:08 UTC (rev 189023)
@@ -431,6 +431,8 @@
 
     String pathStringWithShrinkWrappedRects(Vector<double> rectComponents, double radius, ExceptionCode&);
 
+    String getCurrentMediaControlsStatusForElement(HTMLMediaElement*);
+
 private:
     explicit Internals(Document*);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (189022 => 189023)


--- trunk/Source/WebCore/testing/Internals.idl	2015-08-27 14:26:20 UTC (rev 189022)
+++ trunk/Source/WebCore/testing/Internals.idl	2015-08-27 14:46:08 UTC (rev 189023)
@@ -399,4 +399,6 @@
 #endif
 
     [RaisesException] DOMString pathStringWithShrinkWrappedRects(sequence<double> rectComponents, double radius);
+
+    DOMString getCurrentMediaControlsStatusForElement(HTMLMediaElement element);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to