Changeset 262058 in webkit


Ignore:
Timestamp:
May 22, 2020 8:17:10 AM (4 years ago)
Author:
Chris Dumez
Message:

Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
https://bugs.webkit.org/show_bug.cgi?id=211503
<rdar://problem/62983284>

Reviewed by Maciej Stachowiak.

Source/WebKit:

r254859 refactored StorageAreaMap's dispatchSessionStorageEvent() &
dispatchLocalStorageEvent() to share more code by moving that code to
a new framesForEventDispatching() static function. However,
framesForEventDispatching() was always using the session storage no
matter the call site. It should be using the local storage when called
from dispatchLocalStorageEvent().

Test: storage/domstorage/events/storage-event-not-in-originator.html

  • WebProcess/WebStorage/StorageAreaMap.cpp:

(WebKit::framesForEventDispatching):
(WebKit::StorageAreaMap::dispatchSessionStorageEvent):
(WebKit::StorageAreaMap::dispatchLocalStorageEvent):

LayoutTests:

Add layout test coverage.

  • storage/domstorage/events/resources/storage-event-not-in-originator-frame.html: Added.
  • storage/domstorage/events/storage-event-not-in-originator-expected.txt: Added.
  • storage/domstorage/events/storage-event-not-in-originator.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r262056 r262058  
     12020-05-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
     4        https://bugs.webkit.org/show_bug.cgi?id=211503
     5        <rdar://problem/62983284>
     6
     7        Reviewed by Maciej Stachowiak.
     8
     9        Add layout test coverage.
     10
     11        * storage/domstorage/events/resources/storage-event-not-in-originator-frame.html: Added.
     12        * storage/domstorage/events/storage-event-not-in-originator-expected.txt: Added.
     13        * storage/domstorage/events/storage-event-not-in-originator.html: Added.
     14
    1152020-05-22  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    216
  • trunk/Source/WebKit/ChangeLog

    r262055 r262058  
     12020-05-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
     4        https://bugs.webkit.org/show_bug.cgi?id=211503
     5        <rdar://problem/62983284>
     6
     7        Reviewed by Maciej Stachowiak.
     8
     9        r254859 refactored StorageAreaMap's dispatchSessionStorageEvent() &
     10        dispatchLocalStorageEvent() to share more code by moving that code to
     11        a new framesForEventDispatching() static function. However,
     12        framesForEventDispatching() was always using the session storage no
     13        matter the call site. It should be using the local storage when called
     14        from dispatchLocalStorageEvent().
     15
     16        Test: storage/domstorage/events/storage-event-not-in-originator.html
     17
     18        * WebProcess/WebStorage/StorageAreaMap.cpp:
     19        (WebKit::framesForEventDispatching):
     20        (WebKit::StorageAreaMap::dispatchSessionStorageEvent):
     21        (WebKit::StorageAreaMap::dispatchLocalStorageEvent):
     22
    1232020-05-22  Tim Horton  <timothy_horton@apple.com>
    224
  • trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp

    r260709 r262058  
    277277}
    278278
    279 static Vector<RefPtr<Frame>> framesForEventDispatching(Page& page, SecurityOrigin& origin, const Optional<StorageAreaImplIdentifier>& storageAreaImplID)
     279static Vector<RefPtr<Frame>> framesForEventDispatching(Page& page, SecurityOrigin& origin, StorageType storageType, const Optional<StorageAreaImplIdentifier>& storageAreaImplID)
    280280{
    281281    Vector<RefPtr<Frame>> frames;
     
    283283        if (!document.securityOrigin().equal(&origin))
    284284            return;
     285
     286        auto* window = document.domWindow();
     287        if (!window)
     288            return;
    285289       
    286         auto* storage = document.domWindow() ? document.domWindow()->optionalSessionStorage() : nullptr;
     290        Storage* storage = nullptr;
     291        switch (storageType) {
     292        case StorageType::Session:
     293            storage = window->optionalSessionStorage();
     294            break;
     295        case StorageType::Local:
     296        case StorageType::TransientLocal:
     297            storage = window->optionalLocalStorage();
     298            break;
     299        }
     300
    287301        if (!storage)
    288302            return;
     
    312326        return;
    313327
    314     auto frames = framesForEventDispatching(*page, m_securityOrigin, storageAreaImplID);
     328    auto frames = framesForEventDispatching(*page, m_securityOrigin, StorageType::Session, storageAreaImplID);
    315329    StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
    316330}
     
    325339    auto& pageGroup = *WebProcess::singleton().webPageGroup(m_namespace.pageGroupID())->corePageGroup();
    326340    for (auto* page : pageGroup.pages())
    327         frames.appendVector(framesForEventDispatching(*page, m_securityOrigin, storageAreaImplID));
     341        frames.appendVector(framesForEventDispatching(*page, m_securityOrigin, StorageType::Local, storageAreaImplID));
    328342
    329343    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
Note: See TracChangeset for help on using the changeset viewer.