Index: third_party/WebKit/Source/core/dom/Document.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp |
index a1cf59db7c956423f8e84681d2729ddb1ab74deb..fd33170772845c0d473d4491f85b908113027059 100644 |
--- a/third_party/WebKit/Source/core/dom/Document.cpp |
+++ b/third_party/WebKit/Source/core/dom/Document.cpp |
@@ -1366,6 +1366,11 @@ PageVisibilityState Document::pageVisibilityState() const |
// http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#dom-document-hidden |
if (!m_frame || !m_frame->page()) |
return PageVisibilityStateHidden; |
+ // While visibilitychange is being dispatched during unloading it is |
+ // expected that the visibility is hidden regardless of the page's |
+ // visibility. |
+ if (m_loadEventProgress == UnloadVisibilityChangeInProgress) |
+ return PageVisibilityStateHidden; |
dcheng
2016/03/10 22:46:33
I think we should update pageDismissalEventBeingDi
kinuko
2016/03/11 04:13:05
Oh yeah we should. Done.
|
return m_frame->page()->visibilityState(); |
} |
@@ -2779,6 +2784,17 @@ void Document::dispatchUnloadEvents() |
if (!m_frame) |
return; |
+ PageVisibilityState visibilityState = pageVisibilityState(); |
+ m_loadEventProgress = UnloadVisibilityChangeInProgress; |
+ if (visibilityState != PageVisibilityStateHidden && RuntimeEnabledFeatures::visibilityChangeOnUnloadEnabled()) { |
+ // Dispatch visibilitychange event, but don't bother doing |
+ // other notifications as we're about to be unloaded. |
+ dispatchEvent(Event::createBubble(EventTypeNames::visibilitychange)); |
+ dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibilitychange)); |
+ } |
+ if (!m_frame) |
+ return; |
+ |
// The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed |
// while dispatching the event, so protect it to prevent writing the end |
// time into freed memory. |