Changeset 244823 in webkit
- Timestamp:
- May 1, 2019 8:56:34 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r244821 r244823 1 2019-05-01 Eric Carlson <eric.carlson@apple.com> 2 3 XMLHttpRequest should propagate user gestures for media playback 4 https://bugs.webkit.org/show_bug.cgi?id=197428 5 <rdar://problem/46677392> 6 7 Reviewed by Jer Noble. 8 9 * fast/events/popup-blocking-timers5-expected.txt: 10 * fast/events/popup-blocking-timers5.html: Decrease the timer interval from 1000 to 900 11 because the user gesture is invalidated based on wall clock time. 12 * fast/events/popup-blocking-timers6-expected.txt: 13 * fast/events/popup-blocking-timers6.html: Increase the timer interval from 1001 to 1100 14 because the user gesture is invalidated based on wall clock time. 15 * http/tests/media/user-gesture-preserved-across-xmlhttprequest-expected.txt: Added. 16 * http/tests/media/user-gesture-preserved-across-xmlhttprequest.html: Added. 17 1 18 2019-04-29 Darin Adler <darin@apple.com> 2 19 -
trunk/LayoutTests/fast/events/popup-blocking-timers5-expected.txt
r130200 r244823 1 1 Click Here 2 Test calling window.open() with a 1000 ms delay. A popup should be allowed.2 Test calling window.open() with a 900 ms delay. A popup should be allowed. 3 3 PASS newWindow is non-null. 4 4 -
trunk/LayoutTests/fast/events/popup-blocking-timers5.html
r155267 r244823 16 16 newWindow = window.open("about:blank"); 17 17 self.focus(); 18 debug("Test calling window.open() with a 1000 ms delay. A popup should be allowed.")18 debug("Test calling window.open() with a 900 ms delay. A popup should be allowed.") 19 19 shouldBeNonNull("newWindow"); 20 20 if (window.testRunner) 21 21 testRunner.notifyDone(); 22 }, 1000);22 }, 900); 23 23 24 24 if (window.eventSender) 25 eventSender.leapForward( 1000);25 eventSender.leapForward(900); 26 26 } 27 27 -
trunk/LayoutTests/fast/events/popup-blocking-timers6-expected.txt
r206777 r244823 1 1 Click Here 2 Test calling window.open() with a 1 001ms delay. A popup should not be allowed.2 Test calling window.open() with a 1100 ms delay. A popup should not be allowed. 3 3 PASS newWindow is null 4 4 -
trunk/LayoutTests/fast/events/popup-blocking-timers6.html
r206777 r244823 16 16 newWindow = window.open("about:blank"); 17 17 self.focus(); 18 debug("Test calling window.open() with a 1 001ms delay. A popup should not be allowed.")18 debug("Test calling window.open() with a 1100 ms delay. A popup should not be allowed.") 19 19 shouldBeNull("newWindow"); 20 20 21 21 if (window.testRunner) 22 22 testRunner.notifyDone(); 23 }, 1 001);23 }, 1100); 24 24 if (window.eventSender) 25 eventSender.leapForward(1 001);25 eventSender.leapForward(1100); 26 26 } 27 27 -
trunk/Source/WebCore/ChangeLog
r244821 r244823 1 2019-05-01 Eric Carlson <eric.carlson@apple.com> 2 3 XMLHttpRequest should propagate user gestures for media playback 4 https://bugs.webkit.org/show_bug.cgi?id=197428 5 <rdar://problem/46677392> 6 7 Reviewed by Jer Noble. 8 9 A user gesture the would allow media state change in effect when XMLHttpRequest.send is 10 called should be active when the event handlers fire after the transaction completes successfully. 11 12 Test: http/tests/media/user-gesture-preserved-across-xmlhttprequest.html 13 14 * dom/UserGestureIndicator.cpp: 15 (WebCore::UserGestureIndicator::UserGestureIndicator): Add a 'scope' parameter to potentially 16 limit the scope of the gesture to just media. 17 (WebCore::UserGestureIndicator::~UserGestureIndicator): Clear the scope. 18 * dom/UserGestureIndicator.h: 19 (WebCore::UserGestureToken::processingUserGesture const): 20 (WebCore::UserGestureToken::setScope): 21 (WebCore::UserGestureToken::resetScope): 22 (WebCore::UserGestureToken::hasExpired const): 23 24 * page/DOMTimer.cpp: 25 (WebCore::DOMTimerFireState::DOMTimerFireState): Don't need to store the nested timer interval, 26 UserGestureIndicator knows when it started. 27 (WebCore::DOMTimer::DOMTimer): Ditto. 28 (WebCore::DOMTimer::fired): Ditto. 29 (WebCore::DOMTimerFireState::nestedTimerInterval const): Deleted. 30 (WebCore::shouldForwardUserGesture): Deleted. 31 (WebCore::userGestureTokenToForward): Deleted. 32 (WebCore::currentNestedTimerInterval): Deleted. 33 * page/DOMTimer.h: 34 35 * testing/Internals.cpp: 36 (WebCore::Internals::setXHRMaximumIntervalForUserGestureForwarding): Override the maximum 37 user gesture interval for testing. 38 * testing/Internals.h: 39 * testing/Internals.idl: 40 41 * xml/XMLHttpRequest.cpp: 42 (WebCore::XMLHttpRequest::XMLHttpRequest): 43 (WebCore::XMLHttpRequest::send): Stash the user gesture token. 44 (WebCore::XMLHttpRequest::dispatchEvent): Clear user gesture token if it has expired. If still 45 valid, activate it. 46 * xml/XMLHttpRequest.h: 47 1 48 2019-04-29 Darin Adler <darin@apple.com> 2 49 -
trunk/Source/WebCore/dom/UserGestureIndicator.cpp
r242776 r244823 71 71 } 72 72 73 UserGestureIndicator::UserGestureIndicator(RefPtr<UserGestureToken> token )73 UserGestureIndicator::UserGestureIndicator(RefPtr<UserGestureToken> token, UserGestureToken::GestureScope scope) 74 74 { 75 75 // Silently ignore UserGestureIndicators on non main threads. … … 80 80 m_previousToken = currentToken(); 81 81 82 if (token) 82 if (token) { 83 token->setScope(scope); 83 84 currentToken() = token; 85 } 84 86 } 85 87 … … 89 91 return; 90 92 91 if (auto token = currentToken()) 93 if (auto token = currentToken()) { 92 94 token->resetDOMPasteAccess(); 95 token->resetScope(); 96 } 93 97 94 98 currentToken() = m_previousToken; -
trunk/Source/WebCore/dom/UserGestureIndicator.h
r242776 r244823 28 28 #include "DOMPasteAccess.h" 29 29 #include <wtf/Function.h> 30 #include <wtf/MonotonicTime.h> 30 31 #include <wtf/Noncopyable.h> 31 32 #include <wtf/RefCounted.h> … … 54 55 55 56 ProcessingUserGestureState state() const { return m_state; } 56 bool processingUserGesture() const { return m_s tate == ProcessingUserGesture; }57 bool processingUserGesture() const { return m_scope == GestureScope::All && m_state == ProcessingUserGesture; } 57 58 bool processingUserGestureForMedia() const { return m_state == ProcessingUserGesture || m_state == ProcessingPotentialUserGesture; } 58 59 UserGestureType gestureType() const { return m_gestureType; } … … 79 80 void resetDOMPasteAccess() { m_domPasteAccessPolicy = DOMPasteAccessPolicy::NotRequestedYet; } 80 81 82 enum class GestureScope { All, MediaOnly }; 83 void setScope(GestureScope scope) { m_scope = scope; } 84 void resetScope() { m_scope = GestureScope::All; } 85 86 bool hasExpired(Seconds expirationInterval) const 87 { 88 return m_startTime + expirationInterval < MonotonicTime::now(); 89 } 90 81 91 private: 82 92 UserGestureToken(ProcessingUserGestureState state, UserGestureType gestureType) … … 90 100 UserGestureType m_gestureType; 91 101 DOMPasteAccessPolicy m_domPasteAccessPolicy { DOMPasteAccessPolicy::NotRequestedYet }; 102 GestureScope m_scope { GestureScope::All }; 103 MonotonicTime m_startTime { MonotonicTime::now() }; 92 104 }; 93 105 … … 104 116 enum class ProcessInteractionStyle { Immediate, Delayed }; 105 117 WEBCORE_EXPORT explicit UserGestureIndicator(Optional<ProcessingUserGestureState>, Document* = nullptr, UserGestureType = UserGestureType::Other, ProcessInteractionStyle = ProcessInteractionStyle::Immediate); 106 WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr<UserGestureToken> );118 WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr<UserGestureToken>, UserGestureToken::GestureScope = UserGestureToken::GestureScope::All); 107 119 WEBCORE_EXPORT ~UserGestureIndicator(); 108 120 -
trunk/Source/WebCore/page/DOMTimer.cpp
r242340 r244823 54 54 class DOMTimerFireState { 55 55 public: 56 DOMTimerFireState(ScriptExecutionContext& context, int nestingLevel , const Seconds& nestedTimerInterval)56 DOMTimerFireState(ScriptExecutionContext& context, int nestingLevel) 57 57 : m_context(context) 58 , m_nestedTimerInterval(nestedTimerInterval)59 58 , m_contextIsDocument(is<Document>(m_context)) 60 59 { … … 79 78 Document* contextDocument() const { return m_contextIsDocument ? &downcast<Document>(m_context) : nullptr; } 80 79 81 const Seconds& nestedTimerInterval() const { return m_nestedTimerInterval; }82 83 80 void setScriptMadeUserObservableChanges() { m_scriptMadeUserObservableChanges = true; } 84 81 void setScriptMadeNonUserObservableChanges() { m_scriptMadeNonUserObservableChanges = true; } … … 99 96 private: 100 97 ScriptExecutionContext& m_context; 101 Seconds m_nestedTimerInterval;102 98 uint64_t m_initialDOMTreeVersion; 103 99 DOMTimerFireState* m_previous; … … 163 159 164 160 bool NestedTimersMap::isTrackingNestedTimers = false; 165 166 static inline bool shouldForwardUserGesture(Seconds interval)167 {168 return UserGestureIndicator::processingUserGesture()169 && interval <= maxIntervalForUserGestureForwarding;170 }171 172 static inline RefPtr<UserGestureToken> userGestureTokenToForward(Seconds interval)173 {174 if (!shouldForwardUserGesture(interval))175 return nullptr;176 177 return UserGestureIndicator::currentUserGesture();178 }179 180 static inline Seconds currentNestedTimerInterval()181 {182 if (DOMTimerFireState::current)183 return DOMTimerFireState::current->nestedTimerInterval();184 return { };185 }186 161 187 162 DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, Seconds interval, bool singleShot) … … 192 167 , m_throttleState(Undetermined) 193 168 , m_currentTimerInterval(intervalClampedToMinimum()) 194 , m_nestedTimerInterval(currentNestedTimerInterval()) 195 , m_userGestureTokenToForward(userGestureTokenToForward(m_nestedTimerInterval + m_currentTimerInterval)) 169 , m_userGestureTokenToForward(UserGestureIndicator::currentUserGesture()) 196 170 { 197 171 RefPtr<DOMTimer> reference = adoptRef(this); … … 311 285 ScriptExecutionContext& context = *scriptExecutionContext(); 312 286 313 DOMTimerFireState fireState(context, std::min(m_nestingLevel + 1, maxTimerNestingLevel), m_nestedTimerInterval + m_currentTimerInterval); 287 DOMTimerFireState fireState(context, std::min(m_nestingLevel + 1, maxTimerNestingLevel)); 288 289 if (m_userGestureTokenToForward && m_userGestureTokenToForward->hasExpired(maxIntervalForUserGestureForwarding)) 290 m_userGestureTokenToForward = nullptr; 314 291 315 292 ASSERT(!isSuspended()); -
trunk/Source/WebCore/page/DOMTimer.h
r239427 r244823 93 93 TimerThrottleState m_throttleState; 94 94 Seconds m_currentTimerInterval; 95 Seconds m_nestedTimerInterval;96 95 RefPtr<UserGestureToken> m_userGestureTokenToForward; 97 96 }; -
trunk/Source/WebCore/testing/Internals.cpp
r244749 r244823 5033 5033 } 5034 5034 5035 void Internals::setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest& request, double interval) 5036 { 5037 request.setMaximumIntervalForUserGestureForwarding(interval); 5038 } 5039 5035 5040 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r244749 r244823 817 817 818 818 void testDictionaryLogging(); 819 819 820 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest&, double); 821 820 822 private: 821 823 explicit Internals(Document&); -
trunk/Source/WebCore/testing/Internals.idl
r244749 r244823 748 748 749 749 void testDictionaryLogging(); 750 }; 750 751 void setXHRMaximumIntervalForUserGestureForwarding(XMLHttpRequest xhr, double interval); 752 }; -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r244617 r244823 67 67 namespace WebCore { 68 68 69 static const Seconds maximumIntervalForUserGestureForwarding { 10_s }; 70 69 71 WTF_MAKE_ISO_ALLOCATED_IMPL(XMLHttpRequest); 70 72 … … 122 124 , m_networkErrorTimer(*this, &XMLHttpRequest::networkErrorTimerFired) 123 125 , m_timeoutTimer(*this, &XMLHttpRequest::didReachTimeout) 126 , m_maximumIntervalForUserGestureForwarding(maximumIntervalForUserGestureForwarding) 124 127 { 125 128 #ifndef NDEBUG … … 437 440 { 438 441 InspectorInstrumentation::willSendXMLHttpRequest(scriptExecutionContext(), url()); 442 m_userGestureToken = UserGestureIndicator::currentUserGesture(); 439 443 440 444 ExceptionOr<void> result; … … 1090 1094 } 1091 1095 1096 void XMLHttpRequest::dispatchEvent(Event& event) 1097 { 1098 if (m_userGestureToken && m_userGestureToken->hasExpired(m_maximumIntervalForUserGestureForwarding)) 1099 m_userGestureToken = nullptr; 1100 1101 if (readyState() != DONE || !m_userGestureToken || !m_userGestureToken->processingUserGesture()) { 1102 EventTarget::dispatchEvent(event); 1103 return; 1104 } 1105 1106 UserGestureIndicator gestureIndicator(m_userGestureToken, UserGestureToken::GestureScope::MediaOnly); 1107 EventTarget::dispatchEvent(event); 1108 } 1109 1092 1110 void XMLHttpRequest::dispatchErrorEvents(const AtomicString& type) 1093 1111 { … … 1189 1207 } 1190 1208 1209 void XMLHttpRequest::setMaximumIntervalForUserGestureForwarding(double interval) 1210 { 1211 m_maximumIntervalForUserGestureForwarding = Seconds(interval); 1212 } 1213 1191 1214 } // namespace WebCore -
trunk/Source/WebCore/xml/XMLHttpRequest.h
r244377 r244823 27 27 #include "ResourceResponse.h" 28 28 #include "ThreadableLoaderClient.h" 29 #include "UserGestureIndicator.h" 29 30 #include <wtf/URL.h> 30 31 #include "XMLHttpRequestEventTarget.h" … … 128 129 size_t memoryCost() const; 129 130 131 WEBCORE_EXPORT void setMaximumIntervalForUserGestureForwarding(double); 132 130 133 private: 131 134 explicit XMLHttpRequest(ScriptExecutionContext&); … … 187 190 188 191 void dispatchErrorEvents(const AtomicString&); 192 193 using EventTarget::dispatchEvent; 194 void dispatchEvent(Event&) override; 189 195 190 196 void resumeTimerFired(); … … 244 250 245 251 Optional<ExceptionCode> m_exceptionCode; 252 RefPtr<UserGestureToken> m_userGestureToken; 253 Seconds m_maximumIntervalForUserGestureForwarding; 246 254 }; 247 255
Note: See TracChangeset
for help on using the changeset viewer.