[mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 09:39:41 +0000 (09:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 09:39:41 +0000 (09:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168409
<rdar://problem/30799198>

Patch by Antoine Quint <graouts@apple.com> on 2017-03-29
Reviewed by Dean Jackson.

Source/WebCore:

Add a new internals setting to opt into ScriptedAnimationController logging through DOM events dispatched
through the document. This should allow this flaky test to get information as to why the frame isn't
firing when it times out.

* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::suspend):
(WebCore::ScriptedAnimationController::resume):
(WebCore::ScriptedAnimationController::addThrottlingReason):
(WebCore::ScriptedAnimationController::removeThrottlingReason):
(WebCore::ScriptedAnimationController::registerCallback):
(WebCore::ScriptedAnimationController::cancelCallback):
(WebCore::ScriptedAnimationController::serviceScriptedAnimations):
(WebCore::ScriptedAnimationController::scheduleAnimation):
(WebCore::ScriptedAnimationController::dispatchLoggingEventIfRequired):
* dom/ScriptedAnimationController.h:
* page/Settings.in:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::resetToConsistentState):
(WebCore::InternalSettings::shouldDispatchRequestAnimationFrameEvents):
(WebCore::InternalSettings::setShouldDispatchRequestAnimationFrameEvents):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

LayoutTests:

Opt into ScriptedAnimationController logging.

* media/modern-media-controls/airplay-button/airplay-button-expected.txt:
* media/modern-media-controls/airplay-button/airplay-button.html:

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

LayoutTests/ChangeLog
LayoutTests/media/modern-media-controls/airplay-button/airplay-button-expected.txt
LayoutTests/media/modern-media-controls/airplay-button/airplay-button.html
Source/WebCore/ChangeLog
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/dom/ScriptedAnimationController.h
Source/WebCore/page/Settings.in
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl

index 10726ec..5ce5722 100644 (file)
@@ -1,3 +1,16 @@
+2017-03-29  Antoine Quint  <graouts@apple.com>
+
+        [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
+        https://bugs.webkit.org/show_bug.cgi?id=168409
+        <rdar://problem/30799198>
+
+        Reviewed by Dean Jackson.
+
+        Opt into ScriptedAnimationController logging.
+
+        * media/modern-media-controls/airplay-button/airplay-button-expected.txt:
+        * media/modern-media-controls/airplay-button/airplay-button.html:
+
 2017-03-28  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] After r214441 addIceCandidate no longer accepts an RTCIceCandidateInit dictionary
index b14c380..aa679a1 100644 (file)
@@ -3,8 +3,19 @@ Testing the AirplayButton class.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS airplayButton.element.localName is "button"
+PASS airplayButton.element.classList.contains("icon") is true
+PASS airplayButton.element.classList.contains("airplay") is true
+PASS airplayButton.iconName is Icons.Airplay
+PASS airplayButton.width is 0
+PASS airplayButton.height is 0
+PASS airplayButton._image is iconService.imageForIconNameAndLayoutTraits(Icons.Airplay.name, LayoutTraits.macOS)
+PASS airplayButton._image.src is not ""
+PASS airplayButton._image.complete is false
 scheduleLayout() - start
 _requestFrameIfNeeded()
+[ScriptedAnimationController] raf-register-callback
+[ScriptedAnimationController] raf-schedule-animation
 _requestFrameIfNeeded() - registered rAF, _frameID = 1
 scheduleLayout() - _layoutCallbacks.size = 1
 scheduleLayout() - end
@@ -18,15 +29,6 @@ _requestFrameIfNeeded()
 _requestFrameIfNeeded() - failed to register rAF call, _frameID = 1, _layoutCallbacks.size = 1
 scheduleLayout() - _layoutCallbacks.size = 1
 scheduleLayout() - end
-PASS airplayButton.element.localName is "button"
-PASS airplayButton.element.classList.contains("icon") is true
-PASS airplayButton.element.classList.contains("airplay") is true
-PASS airplayButton.iconName is Icons.Airplay
-FAIL airplayButton.width should be 0. Was 25.
-FAIL airplayButton.height should be 0. Was 22.
-PASS airplayButton._image is iconService.imageForIconNameAndLayoutTraits(Icons.Airplay.name, LayoutTraits.macOS)
-PASS airplayButton._image.src is not ""
-FAIL airplayButton._image.complete should be false. Was true.
 PASS airplayButton.width is not 0
 PASS airplayButton.height is not 0
 PASS airplayButton.needsLayout is true
@@ -34,6 +36,9 @@ PASS scheduler.hasScheduledLayoutCallbacks is true
 PASS scheduler._layoutCallbacks.size is 1
 PASS scheduler._frameID is not -1
 PASS dirtyNodes.has(airplayButton) is true
+PASS airplayButton.element.style.webkitMaskImage.includes("macOS/airplay@") became true
+[ScriptedAnimationController] raf-service-scripted-animations
+[ScriptedAnimationController] raf-will-fire
 _frameDidFire() - start
 frameWillFire()
 PASS dirtyNodes.has(airplayButton) is true
@@ -48,7 +53,7 @@ PASS dirtyNodes.has(airplayButton) is false
 PASS airplayButton.needsLayout is false
 PASS airplayButton.element.getAttribute('aria-label') is "AirPlay"
 _frameDidFire() - end
-PASS airplayButton.element.style.webkitMaskImage.includes("macOS/airplay@") became true
+[ScriptedAnimationController] raf-did-fire
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 4696c1e..877d2d6 100644 (file)
@@ -5,11 +5,34 @@
 <body>
 <script type="text/javascript">
 
+let reachedEndOfTest = false;
+let receivedRAFDidFireEvent = false;
+
 window.jsTestIsAsync = true;
 scheduler.debug = debug;
 
 description("Testing the <code>AirplayButton</code> class.");
 
+if (window.internals) {
+    ["raf-suspend", "raf-resume", "raf-add-throttling-reason", "raf-remove-throttling-reason", "raf-register-callback", "raf-cancel-callback", "raf-did-cancel-callback", "raf-service-scripted-animations", "raf-will-fire", "raf-did-fire", "raf-schedule-animation", "raf-schedule-animation-display-refresh-monitor", "raf-schedule-animation-timer", "raf-schedule-animation-frame-view"].forEach(eventType => document.addEventListener(eventType, handleRAFEvent));
+    window.internals.settings.setShouldDispatchRequestAnimationFrameEvents(true);
+}
+
+function handleRAFEvent(event)
+{
+    debug(`[ScriptedAnimationController] ${event.type}`);
+    if (event.type === "raf-did-fire") {
+        receivedRAFDidFireEvent = true;
+        considerFinishingTest();
+    }
+}
+
+function considerFinishingTest()
+{
+    if (reachedEndOfTest && receivedRAFDidFireEvent)
+        finishJSTest();
+}
+
 const airplayButton = new AirplayButton({ layoutTraits: LayoutTraits.macOS });
 
 shouldBeEqualToString("airplayButton.element.localName", "button");
@@ -44,7 +67,10 @@ airplayButton._image.addEventListener("load", event => {
         shouldBeFalse("airplayButton.needsLayout");
         shouldBeEqualToString("airplayButton.element.getAttribute('aria-label')", "AirPlay");
     }
-    shouldBecomeEqual('airplayButton.element.style.webkitMaskImage.includes("macOS/airplay@")', "true", finishJSTest);
+    shouldBecomeEqual('airplayButton.element.style.webkitMaskImage.includes("macOS/airplay@")', "true", () => {
+        reachedEndOfTest = true;
+        considerFinishingTest();
+    });
     // shouldBecomeEqual('airplayButton.element.style.webkitMaskImage.includes("macOS/airplay@")', "true", () => {
     //     shouldBecomeEqual('macOSFullscreenAirplayButton.element.style.webkitMaskImage.includes("macOS/airplay-fullscreen@")', "true", () => {
     //         shouldBecomeEqual('iOSAirplayButton.element.style.webkitMaskImage.includes("iOS/airplay@")', "true", finishJSTest);
index 534eb7d..1e49019 100644 (file)
@@ -1,3 +1,34 @@
+2017-03-29  Antoine Quint  <graouts@apple.com>
+
+        [mac-wk1] LayoutTest media/modern-media-controls/airplay-button/airplay-button.html is a flaky timeout
+        https://bugs.webkit.org/show_bug.cgi?id=168409
+        <rdar://problem/30799198>
+
+        Reviewed by Dean Jackson.
+
+        Add a new internals setting to opt into ScriptedAnimationController logging through DOM events dispatched
+        through the document. This should allow this flaky test to get information as to why the frame isn't
+        firing when it times out.
+
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::ScriptedAnimationController::suspend):
+        (WebCore::ScriptedAnimationController::resume):
+        (WebCore::ScriptedAnimationController::addThrottlingReason):
+        (WebCore::ScriptedAnimationController::removeThrottlingReason):
+        (WebCore::ScriptedAnimationController::registerCallback):
+        (WebCore::ScriptedAnimationController::cancelCallback):
+        (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
+        (WebCore::ScriptedAnimationController::scheduleAnimation):
+        (WebCore::ScriptedAnimationController::dispatchLoggingEventIfRequired):
+        * dom/ScriptedAnimationController.h:
+        * page/Settings.in:
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::resetToConsistentState):
+        (WebCore::InternalSettings::shouldDispatchRequestAnimationFrameEvents):
+        (WebCore::InternalSettings::setShouldDispatchRequestAnimationFrameEvents):
+        * testing/InternalSettings.h:
+        * testing/InternalSettings.idl:
+
 2017-03-28  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] After r214441 addIceCandidate no longer accepts an RTCIceCandidateInit dictionary
index 605df6e..2172374 100644 (file)
@@ -81,11 +81,13 @@ bool ScriptedAnimationController::requestAnimationFrameEnabled() const
 
 void ScriptedAnimationController::suspend()
 {
+    dispatchLoggingEventIfRequired("raf-suspend");
     ++m_suspendCount;
 }
 
 void ScriptedAnimationController::resume()
 {
+    dispatchLoggingEventIfRequired("raf-resume");
     // It would be nice to put an ASSERT(m_suspendCount > 0) here, but in WK1 resume() can be called
     // even when suspend hasn't (if a tab was created in the background).
     if (m_suspendCount > 0)
@@ -134,6 +136,7 @@ void ScriptedAnimationController::addThrottlingReason(ThrottlingReason reason)
     m_throttlingReasons |= reason;
 
     RELEASE_LOG_IF_ALLOWED("addThrottlingReason(%s) -> %s", throttlingReasonToString(reason), throttlingReasonsToString(m_throttlingReasons).utf8().data());
+    dispatchLoggingEventIfRequired("raf-add-throttling-reason");
 
     if (m_animationTimer.isActive()) {
         m_animationTimer.stop();
@@ -153,6 +156,7 @@ void ScriptedAnimationController::removeThrottlingReason(ThrottlingReason reason
     m_throttlingReasons -= reason;
 
     RELEASE_LOG_IF_ALLOWED("removeThrottlingReason(%s) -> %s", throttlingReasonToString(reason), throttlingReasonsToString(m_throttlingReasons).utf8().data());
+    dispatchLoggingEventIfRequired("raf-remove-throttling-reason");
 
     if (m_animationTimer.isActive()) {
         m_animationTimer.stop();
@@ -180,6 +184,7 @@ ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
     m_callbacks.append(WTFMove(callback));
 
     InspectorInstrumentation::didRequestAnimationFrame(m_document, id);
+    dispatchLoggingEventIfRequired("raf-register-callback");
 
     if (!m_suspendCount)
         scheduleAnimation();
@@ -188,11 +193,13 @@ ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCal
 
 void ScriptedAnimationController::cancelCallback(CallbackId id)
 {
+    dispatchLoggingEventIfRequired("raf-cancel-callback");
     for (size_t i = 0; i < m_callbacks.size(); ++i) {
         if (m_callbacks[i]->m_id == id) {
             m_callbacks[i]->m_firedOrCancelled = true;
             InspectorInstrumentation::didCancelAnimationFrame(m_document, id);
             m_callbacks.remove(i);
+            dispatchLoggingEventIfRequired("raf-did-cancel-callback");
             return;
         }
     }
@@ -200,6 +207,7 @@ void ScriptedAnimationController::cancelCallback(CallbackId id)
 
 void ScriptedAnimationController::serviceScriptedAnimations(double timestamp)
 {
+    dispatchLoggingEventIfRequired("raf-service-scripted-animations");
     if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
         return;
 
@@ -220,11 +228,13 @@ void ScriptedAnimationController::serviceScriptedAnimations(double timestamp)
         if (!callback->m_firedOrCancelled) {
             callback->m_firedOrCancelled = true;
             InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id);
+            dispatchLoggingEventIfRequired("raf-will-fire");
             if (callback->m_useLegacyTimeBase)
                 callback->handleEvent(legacyHighResNowMs);
             else
                 callback->handleEvent(highResNowMs);
             InspectorInstrumentation::didFireAnimationFrame(cookie);
+            dispatchLoggingEventIfRequired("raf-did-fire");
         }
     }
 
@@ -270,6 +280,7 @@ Page* ScriptedAnimationController::page() const
 
 void ScriptedAnimationController::scheduleAnimation()
 {
+    dispatchLoggingEventIfRequired("raf-schedule-animation");
     if (!requestAnimationFrameEnabled())
         return;
 
@@ -280,6 +291,7 @@ void ScriptedAnimationController::scheduleAnimation()
             return;
 
         m_isUsingTimer = true;
+        dispatchLoggingEventIfRequired("raf-schedule-animation-display-refresh-monitor");
     }
 #endif
     if (m_animationTimer.isActive())
@@ -288,9 +300,11 @@ void ScriptedAnimationController::scheduleAnimation()
     Seconds animationInterval = interval();
     double scheduleDelay = std::max<double>(animationInterval.value() - (m_document->domWindow()->nowTimestamp() - m_lastAnimationFrameTimestamp), 0);
     m_animationTimer.startOneShot(scheduleDelay);
+    dispatchLoggingEventIfRequired("raf-schedule-animation-timer");
 #else
     if (FrameView* frameView = m_document->view())
         frameView->scheduleAnimation();
+    dispatchLoggingEventIfRequired("raf-schedule-animation-frame-view");
 #endif
 }
 
@@ -322,4 +336,10 @@ RefPtr<DisplayRefreshMonitor> ScriptedAnimationController::createDisplayRefreshM
 }
 #endif
 
+void ScriptedAnimationController::dispatchLoggingEventIfRequired(const AtomicString& type)
+{
+    if (m_document && m_document->frame() && m_document->frame()->settings().shouldDispatchRequestAnimationFrameEvents())
+        m_document->dispatchEvent(Event::create(type, false, false));
+}
+
 }
index 875a366..ce91daf 100644 (file)
@@ -31,6 +31,7 @@
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
 
 #if USE(REQUEST_ANIMATION_FRAME_TIMER)
 #include "Timer.h"
@@ -96,6 +97,7 @@ private:
     int m_suspendCount { 0 };
 
     void scheduleAnimation();
+    void dispatchLoggingEventIfRequired(const AtomicString&);
 
 #if USE(REQUEST_ANIMATION_FRAME_TIMER)
     void animationTimerFired();
index 13ed3e0..6b64f83 100644 (file)
@@ -274,6 +274,8 @@ visualViewportEnabled initial=false, setNeedsStyleRecalcInAllFrames=1
 
 inputEventsEnabled initial=true
 
+shouldDispatchRequestAnimationFrameEvents initial=false
+
 quickTimePluginReplacementEnabled initial=defaultQuickTimePluginReplacementEnabled
 youTubeFlashPluginReplacementEnabled initial=defaultYouTubeFlashPluginReplacementEnabled
 
index 6661c91..e9ea4cb 100644 (file)
@@ -253,6 +253,8 @@ void InternalSettings::resetToConsistentState()
     m_page->mainFrame().setPageAndTextZoomFactors(1, 1);
     m_page->setCanStartMedia(true);
 
+    settings().setShouldDispatchRequestAnimationFrameEvents(false);
+
     settings().setForcePendingWebGLPolicy(false);
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     settings().setAllowsAirPlayForMediaPlayback(false);
@@ -709,6 +711,16 @@ void InternalSettings::setWebGPUEnabled(bool enabled)
 #endif
 }
 
+bool InternalSettings::shouldDispatchRequestAnimationFrameEvents()
+{
+    return settings().shouldDispatchRequestAnimationFrameEvents();
+}
+
+void InternalSettings::setShouldDispatchRequestAnimationFrameEvents(bool shouldDispatchRequestAnimationFrameEvents)
+{
+    settings().setShouldDispatchRequestAnimationFrameEvents(shouldDispatchRequestAnimationFrameEvents);
+}
+
 ExceptionOr<String> InternalSettings::userInterfaceDirectionPolicy()
 {
     if (!m_page)
index 486c306..20a7363 100644 (file)
@@ -109,6 +109,9 @@ public:
     ForcedAccessibilityValue forcedPrefersReducedMotionAccessibilityValue() const;
     void setForcedPrefersReducedMotionAccessibilityValue(ForcedAccessibilityValue);
 
+    bool shouldDispatchRequestAnimationFrameEvents();
+    void setShouldDispatchRequestAnimationFrameEvents(bool);
+
     // RuntimeEnabledFeatures.
     static void setIndexedDBWorkersEnabled(bool);
     static void setCSSGridLayoutEnabled(bool);
index 5780888..ef53d9f 100644 (file)
@@ -96,6 +96,9 @@ enum ForcedAccessibilityValue { "system", "on", "off" };
     [MayThrowException] boolean deferredCSSParserEnabled();
     [MayThrowException] void setDeferredCSSParserEnabled(boolean enabled);
 
+    boolean shouldDispatchRequestAnimationFrameEvents();
+    void setShouldDispatchRequestAnimationFrameEvents(boolean shouldDispatchRequestAnimationFrameEvents);
+
     attribute ForcedAccessibilityValue forcedColorsAreInvertedAccessibilityValue;
     attribute ForcedAccessibilityValue forcedDisplayIsMonochromeAccessibilityValue;
     attribute ForcedAccessibilityValue forcedPrefersReducedMotionAccessibilityValue;