⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 220071 in webkit


Ignore:
Timestamp:
Jul 31, 2017, 11:05:09 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Remove unnecessary exceptions from storage code
​https://bugs.webkit.org/show_bug.cgi?id=174572

Patch by Sam Weinig <​sam@webkit.org> on 2017-07-31
Reviewed by Chris Dumez.

Source/WebCore:

Remove checks for canAccessStorage() and the exceptions they would cause.
These were used for Storage in ephemeral sessions, but they are now supported.
Add checks for a null frame to functions that can mutate the storage, as the
frame is needed for that, and it retains our existing behavior for disconnected
frames. By removing these checks / exceptions, we can fully generate Storage.idl.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSStorageCustom.cpp: Removed.

Remove JSStorageCustom.cpp

  • loader/EmptyClients.cpp:
  • page/DOMWindow.cpp:

(WebCore::DOMWindow::sessionStorage):
(WebCore::DOMWindow::localStorage):

  • storage/StorageArea.h:

Remove canAccessStorage.

  • storage/Storage.cpp:

(WebCore::Storage::length):
(WebCore::Storage::key):
(WebCore::Storage::getItem):
(WebCore::Storage::setItem):
(WebCore::Storage::removeItem):
(WebCore::Storage::clear):
(WebCore::Storage::contains):
(WebCore::Storage::isSupportedPropertyName):
(WebCore::Storage::supportedPropertyNames):

  • storage/Storage.h:
  • storage/Storage.idl:

Remove canAccessStorage checks and corresponding exceptions. Add supportedPropertyNames
to allow the removal of the [CustomGetOwnPropertyNames].

Source/WebKit:

  • WebProcess/Storage/StorageAreaImpl.cpp:

(WebKit::StorageAreaImpl::canAccessStorage): Deleted.

  • WebProcess/Storage/StorageAreaImpl.h:
  • WebProcess/Storage/StorageNamespaceImpl.cpp:

Remove canAccessStorage. It is no longer called.

Source/WebKitLegacy:

  • Storage/StorageAreaImpl.cpp:

(WebKit::StorageAreaImpl::canAccessStorage): Deleted.

  • Storage/StorageAreaImpl.h:

Remove canAccessStorage. It is no longer called.

Location:
trunk/Source
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r220050 r220071  
    12231223    bindings/js/JSReadableStreamSourceCustom.cpp
    12241224    bindings/js/JSSVGPathSegCustom.cpp
    1225     bindings/js/JSStorageCustom.cpp
    12261225    bindings/js/JSStyleSheetCustom.cpp
    12271226    bindings/js/JSSubtleCryptoCustom.cpp
  • trunk/Source/WebCore/ChangeLog

    r220069 r220071  
     12017-07-31  Sam Weinig  <sam@webkit.org>
     2
     3        Remove unnecessary exceptions from storage code
     4        https://bugs.webkit.org/show_bug.cgi?id=174572
     5
     6        Reviewed by Chris Dumez.
     7
     8        Remove checks for canAccessStorage() and the exceptions they would cause.
     9        These were used for Storage in ephemeral sessions, but they are now supported.
     10        Add checks for a null frame to functions that can mutate the storage, as the
     11        frame is needed for that, and it retains our existing behavior for disconnected
     12        frames. By removing these checks / exceptions, we can fully generate Storage.idl.
     13
     14        * CMakeLists.txt:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * bindings/js/JSBindingsAllInOne.cpp:
     17        * bindings/js/JSStorageCustom.cpp: Removed.
     18        Remove JSStorageCustom.cpp
     19
     20        * loader/EmptyClients.cpp:
     21        * page/DOMWindow.cpp:
     22        (WebCore::DOMWindow::sessionStorage):
     23        (WebCore::DOMWindow::localStorage):
     24        * storage/StorageArea.h:
     25        Remove canAccessStorage.
     26
     27        * storage/Storage.cpp:
     28        (WebCore::Storage::length):
     29        (WebCore::Storage::key):
     30        (WebCore::Storage::getItem):
     31        (WebCore::Storage::setItem):
     32        (WebCore::Storage::removeItem):
     33        (WebCore::Storage::clear):
     34        (WebCore::Storage::contains):
     35        (WebCore::Storage::isSupportedPropertyName):
     36        (WebCore::Storage::supportedPropertyNames):
     37        * storage/Storage.h:
     38        * storage/Storage.idl:
     39        Remove canAccessStorage checks and corresponding exceptions. Add supportedPropertyNames
     40        to allow the removal of the [CustomGetOwnPropertyNames].
     41
    1422017-07-31  Matt Lewis  <jlewis3@apple.com>
    243
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r220050 r220071  
    24202420                51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */; };
    24212421                51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2422                 51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */; };
    24232422                51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */; };
    24242423                51D1248D1E7364AA002B2820 /* CookieCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248C1E736456002B2820 /* CookieCocoa.mm */; };
    … …  
    1012610125                51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryParser.h; sourceTree = "<group>"; };
    1012710126                51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFramePlatformData.h; sourceTree = "<group>"; };
    10128                 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStorageCustom.cpp; sourceTree = "<group>"; };
    1012910127                51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStorageSessionCocoa.mm; sourceTree = "<group>"; };
    1013010128                51D1248C1E736456002B2820 /* CookieCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieCocoa.mm; sourceTree = "<group>"; };
    … …  
    2358023578                                A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
    2358123579                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
    23582                                 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */,
    2358323580                                57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
    2358423581                                E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
    … …  
    3218332180                                A86629D409DA2B48009633A7 /* JSStaticRange.cpp in Sources */,
    3218432181                                51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
    32185                                 51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */,
    3218632182                                51E0BAEA0DA55D4A00A9E417 /* JSStorageEvent.cpp in Sources */,
    3218732183                                0FF50269102BA9430066F39A /* JSStyleMedia.cpp in Sources */,
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r220008 r220071  
    8686#include "JSReadableStreamPrivateConstructors.cpp"
    8787#include "JSSVGPathSegCustom.cpp"
    88 #include "JSStorageCustom.cpp"
    8988#include "JSStyleSheetCustom.cpp"
    9089#include "JSTextCustom.cpp"
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r219595 r220071  
    550550        void clear(Frame*) final { }
    551551        bool contains(const String&) final { return false; }
    552         bool canAccessStorage(Frame*) final { return false; }
    553552        StorageType storageType() const final { return StorageType::Local; }
    554553        size_t memoryBytesUsedByCache() final { return 0; }
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r219954 r220071  
    865865        return Exception { SecurityError };
    866866
    867     if (m_sessionStorage) {
    868         if (!m_sessionStorage->area().canAccessStorage(m_frame))
    869             return Exception { SecurityError };
     867    if (m_sessionStorage)
    870868        return m_sessionStorage.get();
    871     }
    872869
    873870    auto* page = document->page();
    … …  
    876873
    877874    auto storageArea = page->sessionStorage()->storageArea(SecurityOriginData::fromSecurityOrigin(document->securityOrigin()));
    878     if (!storageArea->canAccessStorage(m_frame))
    879         return Exception { SecurityError };
    880 
    881875    m_sessionStorage = Storage::create(m_frame, WTFMove(storageArea));
    882876    return m_sessionStorage.get();
    … …  
    899893    // after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
    900894    if (!page || !page->isClosing()) {
    901         if (m_localStorage) {
    902             if (!m_localStorage->area().canAccessStorage(m_frame))
    903                 return Exception { SecurityError };
     895        if (m_localStorage)
    904896            return m_localStorage.get();
    905         }
    906897    }
    907898
    … …  
    916907
    917908    auto storageArea = page->storageNamespaceProvider().localStorageArea(*document);
    918 
    919     if (!storageArea->canAccessStorage(m_frame))
    920         return Exception { SecurityError };
    921 
    922909    m_localStorage = Storage::create(m_frame, WTFMove(storageArea));
    923910    return m_localStorage.get();
  • trunk/Source/WebCore/storage/Storage.cpp

    r219856 r220071  
    5858}
    5959
    60 ExceptionOr<unsigned> Storage::length() const
     60unsigned Storage::length() const
    6161{
    62     if (!m_storageArea->canAccessStorage(m_frame))
    63         return Exception { SecurityError };
    64 
    6562    return m_storageArea->length();
    6663}
    6764
    68 ExceptionOr<String> Storage::key(unsigned index) const
     65String Storage::key(unsigned index) const
    6966{
    70     if (!m_storageArea->canAccessStorage(m_frame))
    71         return Exception { SecurityError };
    72 
    7367    return m_storageArea->key(index);
    7468}
    7569
    76 ExceptionOr<String> Storage::getItem(const String& key) const
     70String Storage::getItem(const String& key) const
    7771{
    78     if (!m_storageArea->canAccessStorage(m_frame))
    79         return Exception { SecurityError };
    80 
    8172    return m_storageArea->item(key);
    8273}
    … …  
    8475ExceptionOr<void> Storage::setItem(const String& key, const String& value)
    8576{
    86     if (!m_storageArea->canAccessStorage(m_frame))
    87         return Exception { SecurityError };
     77    if (!m_frame)
     78        return Exception { InvalidAccessError };
    8879
    8980    bool quotaException = false;
    … …  
    9687ExceptionOr<void> Storage::removeItem(const String& key)
    9788{
    98     if (!m_storageArea->canAccessStorage(m_frame))
    99         return Exception { SecurityError };
     89    if (!m_frame)
     90        return Exception { InvalidAccessError };
    10091
    10192    m_storageArea->removeItem(m_frame, key);
    … …  
    10596ExceptionOr<void> Storage::clear()
    10697{
    107     if (!m_storageArea->canAccessStorage(m_frame))
    108         return Exception { SecurityError };
     98    if (!m_frame)
     99        return Exception { InvalidAccessError };
    109100
    110101    m_storageArea->clear(m_frame);
    … …  
    112103}
    113104
    114 ExceptionOr<bool> Storage::contains(const String& key) const
     105bool Storage::contains(const String& key) const
    115106{
    116     if (!m_storageArea->canAccessStorage(m_frame))
    117         return Exception { SecurityError };
    118 
    119107    return m_storageArea->contains(key);
    120108}
    … …  
    122110bool Storage::isSupportedPropertyName(const String& propertyName) const
    123111{
    124     if (!m_storageArea->canAccessStorage(m_frame))
    125         return false;
    126 
    127112    return m_storageArea->contains(propertyName);
    128113}
    129114
     115Vector<AtomicString> Storage::supportedPropertyNames() const
     116{
     117    unsigned length = m_storageArea->length();
     118
     119    Vector<AtomicString> result;
     120    result.reserveInitialCapacity(length);
     121
     122    for (unsigned i = 0; i < length; ++i)
     123        result.uncheckedAppend(m_storageArea->key(i));
     124
     125    return result;
     126}
     127
    130128} // namespace WebCore
  • trunk/Source/WebCore/storage/Storage.h

    r217585 r220071  
    4040    ~Storage();
    4141
    42     ExceptionOr<unsigned> length() const;
    43     ExceptionOr<String> key(unsigned index) const;
    44     ExceptionOr<String> getItem(const String& key) const;
     42    unsigned length() const;
     43    String key(unsigned index) const;
     44    String getItem(const String& key) const;
    4545    ExceptionOr<void> setItem(const String& key, const String& value);
    4646    ExceptionOr<void> removeItem(const String& key);
    4747    ExceptionOr<void> clear();
    48     ExceptionOr<bool> contains(const String& key) const;
     48    bool contains(const String& key) const;
    4949
    5050    // Bindings support functions.
    5151    bool isSupportedPropertyName(const String&) const;
     52    Vector<AtomicString> supportedPropertyNames() const;
    5253
    5354    StorageArea& area() const { return *m_storageArea; }
  • trunk/Source/WebCore/storage/Storage.idl

    r219302 r220071  
    2525
    2626[
    27     CustomGetOwnPropertyNames,
    2827    GenerateIsReachable=ImplFrame,
    2928    SkipVTableValidation,
    3029] interface Storage {
    31     [GetterMayThrowException] readonly attribute unsigned long length;
    32     [MayThrowException] DOMString? key(unsigned long index);
    33     [MayThrowException] getter DOMString? getItem(DOMString key);
     30    readonly attribute unsigned long length;
     31    DOMString? key(unsigned long index);
     32    getter DOMString? getItem(DOMString key);
    3433    [MayThrowException] setter void setItem(DOMString key, DOMString data);
    3534    [MayThrowException] deleter void removeItem(DOMString key);
    3635    [MayThrowException] void clear();
    3736};
    38 
  • trunk/Source/WebCore/storage/StorageArea.h

    r214680 r220071  
    5252    virtual bool contains(const String& key) = 0;
    5353
    54     virtual bool canAccessStorage(Frame*) = 0;
    5554    virtual StorageType storageType() const = 0;
    5655
  • trunk/Source/WebKit/ChangeLog

    r220049 r220071  
     12017-07-31  Sam Weinig  <sam@webkit.org>
     2
     3        Remove unnecessary exceptions from storage code
     4        https://bugs.webkit.org/show_bug.cgi?id=174572
     5
     6        Reviewed by Chris Dumez.
     7
     8        * WebProcess/Storage/StorageAreaImpl.cpp:
     9        (WebKit::StorageAreaImpl::canAccessStorage): Deleted.
     10        * WebProcess/Storage/StorageAreaImpl.h:
     11        * WebProcess/Storage/StorageNamespaceImpl.cpp:
     12        Remove canAccessStorage. It is no longer called.
     13
    1142017-07-30  Brady Eidson  <beidson@apple.com>
    215
  • trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.cpp

    r219966 r220071  
    9797}
    9898
    99 bool StorageAreaImpl::canAccessStorage(Frame* frame)
    100 {
    101     return frame && frame->page();
    102 }
    103 
    10499StorageType StorageAreaImpl::storageType() const
    105100{
  • trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.h

    r219966 r220071  
    5757    void clear(WebCore::Frame* sourceFrame) override;
    5858    bool contains(const String& key) override;
    59     bool canAccessStorage(WebCore::Frame*) override;
    6059    WebCore::StorageType storageType() const override;
    6160    size_t memoryBytesUsedByCache() override;
  • trunk/Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp

    r219966 r220071  
    164164    }
    165165
    166     bool canAccessStorage(Frame* frame)
    167     {
    168         return frame && frame->page();
    169     }
    170 
    171166    StorageType storageType() const
    172167    {
  • trunk/Source/WebKitLegacy/ChangeLog

    r219763 r220071  
     12017-07-31  Sam Weinig  <sam@webkit.org>
     2
     3        Remove unnecessary exceptions from storage code
     4        https://bugs.webkit.org/show_bug.cgi?id=174572
     5
     6        Reviewed by Chris Dumez.
     7
     8        * Storage/StorageAreaImpl.cpp:
     9        (WebKit::StorageAreaImpl::canAccessStorage): Deleted.
     10        * Storage/StorageAreaImpl.h:
     11        Remove canAccessStorage. It is no longer called.
     12
    1132017-07-14  Filip Pizlo  <fpizlo@apple.com>
    214
  • trunk/Source/WebKitLegacy/Storage/StorageAreaImpl.cpp

    r214680 r220071  
    9999}
    100100
    101 bool StorageAreaImpl::canAccessStorage(Frame* frame)
    102 {
    103     return frame && frame->page();
    104 }
    105 
    106101StorageType StorageAreaImpl::storageType() const
    107102{
  • trunk/Source/WebKitLegacy/Storage/StorageAreaImpl.h

    r208727 r220071  
    5454    bool contains(const String& key) override;
    5555
    56     bool canAccessStorage(WebCore::Frame* sourceFrame) override;
    5756    WebCore::StorageType storageType() const override;
    5857
Note: See TracChangeset for help on using the changeset viewer.