Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1197)

Unified Diff: Source/modules/serviceworkers/WaitUntilObserver.cpp

Issue 896043004: Tests for WaitUntilObserver and focus/openining windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sw_client_focus_cleanup
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/WaitUntilObserver.cpp
diff --git a/Source/modules/serviceworkers/WaitUntilObserver.cpp b/Source/modules/serviceworkers/WaitUntilObserver.cpp
index bf4ed4e459ed914644c38adc2f24df6041e8e076..2edc4828dc05e14b6478d253c0ca4caed940175c 100644
--- a/Source/modules/serviceworkers/WaitUntilObserver.cpp
+++ b/Source/modules/serviceworkers/WaitUntilObserver.cpp
@@ -21,6 +21,17 @@
namespace blink {
+namespace {
+
+unsigned& windowInteractionTimeout()
+{
+ DEFINE_STATIC_LOCAL(unsigned, windowInteractionTimeout, (ServiceWorkerGlobalScope::kWindowInteractionTimeout));
+ fprintf(stderr, "%s%d\n", "windowInteractionTimeout = ", windowInteractionTimeout);
dominicc (has gone to gerrit) 2015/02/05 18:58:13 Hmm, what happens if unit tests run in parallel?
mlamouri (slow - plz ping) 2015/02/05 20:23:12 Yeah... So I moved to another model. There is now
+ return windowInteractionTimeout;
+}
+
+} // anonymous namespace
+
class WaitUntilObserver::ThenFunction final : public ScriptFunction {
public:
enum ResolveType {
@@ -97,7 +108,7 @@ void WaitUntilObserver::waitUntil(ScriptState* scriptState, const ScriptValue& v
// will be resolved or after a
if (m_type == NotificationClick) {
executionContext()->allowWindowInteraction();
- m_consumeWindowInteractionTimer.startOneShot(ServiceWorkerGlobalScope::kWindowInteractionTimeout, FROM_HERE);
+ m_consumeWindowInteractionTimer.startOneShot(windowInteractionTimeout(), FROM_HERE);
}
incrementPendingActivity();
@@ -159,11 +170,18 @@ void WaitUntilObserver::decrementPendingActivity()
void WaitUntilObserver::consumeWindowInteraction(Timer<WaitUntilObserver>*)
{
+ fprintf(stderr, "%s\n", "consumeWindowInteraction");
dominicc (has gone to gerrit) 2015/02/05 18:58:13 Remove the logging.
mlamouri (slow - plz ping) 2015/02/05 20:23:12 Removed in patch #2.
if (!executionContext())
return;
executionContext()->consumeWindowInteraction();
}
+// static
+void WaitUntilObserver::overrideWindowInteractionTimeoutForTest(unsigned timeout)
+{
+ windowInteractionTimeout() = timeout;
+}
+
void WaitUntilObserver::trace(Visitor* visitor)
{
ContextLifecycleObserver::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698