Changeset 267589 in webkit


Ignore:
Timestamp:
Sep 25, 2020 1:11:48 PM (4 years ago)
Author:
Chris Dumez
Message:

visibilitychange:hidden doesn't fire during page navigations
https://bugs.webkit.org/show_bug.cgi?id=151234
<rdar://problem/23688763>

Reviewed by Darin Adler and Ryosuke Niwa.

LayoutTests/imported/w3c:

Import page-visibility WPT tests from upstream.

  • resources/import-expectations.json:
  • web-platform-tests/page-visibility/*: Added.

Source/WebCore:

Fire a visibilitychange during document unload, as per the specification:

Tests: imported/w3c/web-platform-tests/page-visibility/idlharness.window.html

imported/w3c/web-platform-tests/page-visibility/iframe-unload.html
imported/w3c/web-platform-tests/page-visibility/onvisibilitychange.html
imported/w3c/web-platform-tests/page-visibility/test_attributes_exist.html
imported/w3c/web-platform-tests/page-visibility/test_child_document.html
imported/w3c/web-platform-tests/page-visibility/test_default_view.html
imported/w3c/web-platform-tests/page-visibility/test_read_only.html
imported/w3c/web-platform-tests/page-visibility/unload-bubbles.html
imported/w3c/web-platform-tests/page-visibility/unload.html

  • dom/Document.cpp:

(WebCore::Document::visibilityState const):

  • dom/Document.h:

(WebCore::Document::setIsUnloadingOrUnloaded):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::dispatchUnloadEvents):

Location:
trunk
Files:
30 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r267578 r267589  
     12020-09-25  Chris Dumez  <cdumez@apple.com>
     2
     3        visibilitychange:hidden doesn't fire during page navigations
     4        https://bugs.webkit.org/show_bug.cgi?id=151234
     5        <rdar://problem/23688763>
     6
     7        Reviewed by Darin Adler and Ryosuke Niwa.
     8
     9        Import page-visibility WPT tests from upstream.
     10
     11        * resources/import-expectations.json:
     12        * web-platform-tests/page-visibility/*: Added.
     13
    1142020-09-25  Frederic Wang  <fwang@igalia.com>
    215
  • trunk/LayoutTests/imported/w3c/resources/import-expectations.json

    r267531 r267589  
    337337    "web-platform-tests/orientation-event": "skip",
    338338    "web-platform-tests/orientation-sensor": "skip",
    339     "web-platform-tests/page-visibility": "skip",
     339    "web-platform-tests/page-visibility": "import",
    340340    "web-platform-tests/paint-timing": "skip",
    341341    "web-platform-tests/payment-handler": "skip",
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/no_window_open_when_term_nesting_level_nonzero.window-expected.txt

    r259900 r267589  
     1CONSOLE MESSAGE: Error: assert_equals: expected no popup during visibilitychange expected null but got object "[object Window]"
    12CONSOLE MESSAGE: Error: assert_equals: expected no popup during pagehide expected null but got object "[object Window]"
    23CONSOLE MESSAGE: Error: assert_equals: expected no popup during unload expected null but got object "[object Window]"
  • trunk/Source/WebCore/ChangeLog

    r267588 r267589  
     12020-09-25  Chris Dumez  <cdumez@apple.com>
     2
     3        visibilitychange:hidden doesn't fire during page navigations
     4        https://bugs.webkit.org/show_bug.cgi?id=151234
     5        <rdar://problem/23688763>
     6
     7        Reviewed by Darin Adler and Ryosuke Niwa.
     8
     9        Fire a visibilitychange during document unload, as per the specification:
     10        - https://www.w3.org/TR/page-visibility/#reacting-to-visibilitychange-changes
     11        - https://html.spec.whatwg.org/multipage/browsing-the-web.html#unloading-document-visibility-change-steps
     12
     13        Tests: imported/w3c/web-platform-tests/page-visibility/idlharness.window.html
     14               imported/w3c/web-platform-tests/page-visibility/iframe-unload.html
     15               imported/w3c/web-platform-tests/page-visibility/onvisibilitychange.html
     16               imported/w3c/web-platform-tests/page-visibility/test_attributes_exist.html
     17               imported/w3c/web-platform-tests/page-visibility/test_child_document.html
     18               imported/w3c/web-platform-tests/page-visibility/test_default_view.html
     19               imported/w3c/web-platform-tests/page-visibility/test_read_only.html
     20               imported/w3c/web-platform-tests/page-visibility/unload-bubbles.html
     21               imported/w3c/web-platform-tests/page-visibility/unload.html
     22
     23        * dom/Document.cpp:
     24        (WebCore::Document::visibilityState const):
     25        * dom/Document.h:
     26        (WebCore::Document::setIsUnloadingOrUnloaded):
     27        * loader/FrameLoader.cpp:
     28        (WebCore::FrameLoader::dispatchUnloadEvents):
     29
    1302020-09-25  Fujii Hironori  <Hironori.Fujii@sony.com>
    231
  • trunk/Source/WebCore/dom/Document.cpp

    r267550 r267589  
    17731773    // that the page is hidden, as specified by the spec:
    17741774    // https://w3c.github.io/page-visibility/#visibilitystate-attribute
    1775     if (!m_frame || !m_frame->page())
     1775    if (!m_frame || !m_frame->page() || m_isUnloadingOrUnloaded)
    17761776        return VisibilityState::Hidden;
    17771777    return m_frame->page()->visibilityState();
  • trunk/Source/WebCore/dom/Document.h

    r267220 r267589  
    492492    bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
    493493
     494    void markAsUnloadingOrUnloaded() { m_isUnloadingOrUnloaded = true; }
     495
    494496    WEBCORE_EXPORT ExceptionOr<Ref<Node>> adoptNode(Node& source);
    495497
     
    21282130#endif
    21292131    bool m_hasVisuallyNonEmptyCustomContent { false };
     2132    bool m_isUnloadingOrUnloaded { false };
    21302133
    21312134    Ref<UndoManager> m_undoManager;
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r267449 r267589  
    32763276            downcast<HTMLInputElement>(*currentFocusedElement).endEditing();
    32773277        if (m_pageDismissalEventBeingDispatched == PageDismissalType::None) {
     3278            m_frame.document()->markAsUnloadingOrUnloaded();
     3279
     3280            m_frame.document()->dispatchEvent(Event::create(eventNames().visibilitychangeEvent, Event::CanBubble::Yes, Event::IsCancelable::No));
     3281
    32783282            if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
    32793283                m_pageDismissalEventBeingDispatched = PageDismissalType::PageHide;
    32803284                m_frame.document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame.document()->backForwardCacheState() == Document::AboutToEnterBackForwardCache), m_frame.document());
    32813285            }
    3282 
    3283             // FIXME: update Page Visibility state here.
    3284             // https://bugs.webkit.org/show_bug.cgi?id=116770
    32853286
    32863287            if (m_frame.document()->backForwardCacheState() == Document::NotInBackForwardCache) {
Note: See TracChangeset for help on using the changeset viewer.