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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220071
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
bindings/js/JSReadableStreamPrivateConstructors.cpp
bindings/js/JSReadableStreamSourceCustom.cpp
bindings/js/JSSVGPathSegCustom.cpp
- bindings/js/JSStorageCustom.cpp
bindings/js/JSStyleSheetCustom.cpp
bindings/js/JSSubtleCryptoCustom.cpp
bindings/js/JSTextCustom.cpp
+2017-07-31 Sam Weinig <sam@webkit.org>
+
+ Remove unnecessary exceptions from storage code
+ https://bugs.webkit.org/show_bug.cgi?id=174572
+
+ Reviewed by Chris Dumez.
+
+ 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].
+
2017-07-31 Matt Lewis <jlewis3@apple.com>
Unreviewed, rolling out r220060.
51C81B890C4422F70019ECE3 /* FTPDirectoryParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */; };
51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */; };
51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */; };
51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */; };
51D1248D1E7364AA002B2820 /* CookieCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248C1E736456002B2820 /* CookieCocoa.mm */; };
51D7236C1BB6174900478CA3 /* IDBResultData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D7236A1BB60BFE00478CA3 /* IDBResultData.cpp */; };
51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryParser.cpp; sourceTree = "<group>"; };
51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryParser.h; sourceTree = "<group>"; };
51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFramePlatformData.h; sourceTree = "<group>"; };
- 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStorageCustom.cpp; sourceTree = "<group>"; };
51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStorageSessionCocoa.mm; sourceTree = "<group>"; };
51D1248C1E736456002B2820 /* CookieCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieCocoa.mm; sourceTree = "<group>"; };
51D7196C181106DF0016DC51 /* DOMWindowIndexedDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowIndexedDatabase.cpp; sourceTree = "<group>"; };
C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */,
A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
- 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */,
57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
B59DD6A211902A52007E9684 /* JSSQLTransactionErrorCallback.cpp in Sources */,
A86629D409DA2B48009633A7 /* JSStaticRange.cpp in Sources */,
51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */,
- 51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */,
51E0BAEA0DA55D4A00A9E417 /* JSStorageEvent.cpp in Sources */,
0FF50269102BA9430066F39A /* JSStyleMedia.cpp in Sources */,
BCE0139A0C0BEF180043860A /* JSStyleSheet.cpp in Sources */,
#include "JSPopStateEventCustom.cpp"
#include "JSReadableStreamPrivateConstructors.cpp"
#include "JSSVGPathSegCustom.cpp"
-#include "JSStorageCustom.cpp"
#include "JSStyleSheetCustom.cpp"
#include "JSTextCustom.cpp"
#include "JSTextTrackCueCustom.cpp"
+++ /dev/null
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSStorage.h"
-
-#include "JSDOMConvertStrings.h"
-#include "JSDOMExceptionHandling.h"
-#include <runtime/JSCInlines.h>
-#include <runtime/PropertyNameArray.h>
-#include <wtf/text/WTFString.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
-{
- VM& vm = state->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- auto& thisObject = *jsCast<JSStorage*>(object);
- auto lengthResult = thisObject.wrapped().length();
- if (lengthResult.hasException()) {
- propagateException(*state, scope, lengthResult.releaseException());
- return;
- }
- unsigned length = lengthResult.releaseReturnValue();
- for (unsigned i = 0; i < length; ++i) {
- auto keyResult = thisObject.wrapped().key(i);
- if (keyResult.hasException()) {
- propagateException(*state, scope, lengthResult.releaseException());
- return;
- }
- propertyNames.add(Identifier::fromString(state, keyResult.releaseReturnValue()));
- }
-
- Base::getOwnPropertyNames(&thisObject, state, propertyNames, mode);
-}
-
-} // namespace WebCore
void removeItem(Frame*, const String&) final { }
void clear(Frame*) final { }
bool contains(const String&) final { return false; }
- bool canAccessStorage(Frame*) final { return false; }
StorageType storageType() const final { return StorageType::Local; }
size_t memoryBytesUsedByCache() final { return 0; }
SecurityOriginData securityOrigin() const final { return { }; }
if (!document->securityOrigin().canAccessSessionStorage(document->topOrigin()))
return Exception { SecurityError };
- if (m_sessionStorage) {
- if (!m_sessionStorage->area().canAccessStorage(m_frame))
- return Exception { SecurityError };
+ if (m_sessionStorage)
return m_sessionStorage.get();
- }
auto* page = document->page();
if (!page)
return nullptr;
auto storageArea = page->sessionStorage()->storageArea(SecurityOriginData::fromSecurityOrigin(document->securityOrigin()));
- if (!storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
m_sessionStorage = Storage::create(m_frame, WTFMove(storageArea));
return m_sessionStorage.get();
}
// FIXME: We should consider supporting access/modification to local storage
// after calling window.close(). See <https://bugs.webkit.org/show_bug.cgi?id=135330>.
if (!page || !page->isClosing()) {
- if (m_localStorage) {
- if (!m_localStorage->area().canAccessStorage(m_frame))
- return Exception { SecurityError };
+ if (m_localStorage)
return m_localStorage.get();
- }
}
if (!page)
return nullptr;
auto storageArea = page->storageNamespaceProvider().localStorageArea(*document);
-
- if (!storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
m_localStorage = Storage::create(m_frame, WTFMove(storageArea));
return m_localStorage.get();
}
m_storageArea->decrementAccessCount();
}
-ExceptionOr<unsigned> Storage::length() const
+unsigned Storage::length() const
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
return m_storageArea->length();
}
-ExceptionOr<String> Storage::key(unsigned index) const
+String Storage::key(unsigned index) const
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
return m_storageArea->key(index);
}
-ExceptionOr<String> Storage::getItem(const String& key) const
+String Storage::getItem(const String& key) const
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
return m_storageArea->item(key);
}
ExceptionOr<void> Storage::setItem(const String& key, const String& value)
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
+ if (!m_frame)
+ return Exception { InvalidAccessError };
bool quotaException = false;
m_storageArea->setItem(m_frame, key, value, quotaException);
ExceptionOr<void> Storage::removeItem(const String& key)
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
+ if (!m_frame)
+ return Exception { InvalidAccessError };
m_storageArea->removeItem(m_frame, key);
return { };
ExceptionOr<void> Storage::clear()
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
+ if (!m_frame)
+ return Exception { InvalidAccessError };
m_storageArea->clear(m_frame);
return { };
}
-ExceptionOr<bool> Storage::contains(const String& key) const
+bool Storage::contains(const String& key) const
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return Exception { SecurityError };
-
return m_storageArea->contains(key);
}
bool Storage::isSupportedPropertyName(const String& propertyName) const
{
- if (!m_storageArea->canAccessStorage(m_frame))
- return false;
-
return m_storageArea->contains(propertyName);
}
+Vector<AtomicString> Storage::supportedPropertyNames() const
+{
+ unsigned length = m_storageArea->length();
+
+ Vector<AtomicString> result;
+ result.reserveInitialCapacity(length);
+
+ for (unsigned i = 0; i < length; ++i)
+ result.uncheckedAppend(m_storageArea->key(i));
+
+ return result;
+}
+
} // namespace WebCore
static Ref<Storage> create(Frame*, RefPtr<StorageArea>&&);
~Storage();
- ExceptionOr<unsigned> length() const;
- ExceptionOr<String> key(unsigned index) const;
- ExceptionOr<String> getItem(const String& key) const;
+ unsigned length() const;
+ String key(unsigned index) const;
+ String getItem(const String& key) const;
ExceptionOr<void> setItem(const String& key, const String& value);
ExceptionOr<void> removeItem(const String& key);
ExceptionOr<void> clear();
- ExceptionOr<bool> contains(const String& key) const;
+ bool contains(const String& key) const;
// Bindings support functions.
bool isSupportedPropertyName(const String&) const;
+ Vector<AtomicString> supportedPropertyNames() const;
StorageArea& area() const { return *m_storageArea; }
*/
[
- CustomGetOwnPropertyNames,
GenerateIsReachable=ImplFrame,
SkipVTableValidation,
] interface Storage {
- [GetterMayThrowException] readonly attribute unsigned long length;
- [MayThrowException] DOMString? key(unsigned long index);
- [MayThrowException] getter DOMString? getItem(DOMString key);
+ readonly attribute unsigned long length;
+ DOMString? key(unsigned long index);
+ getter DOMString? getItem(DOMString key);
[MayThrowException] setter void setItem(DOMString key, DOMString data);
[MayThrowException] deleter void removeItem(DOMString key);
[MayThrowException] void clear();
};
-
virtual void clear(Frame* sourceFrame) = 0;
virtual bool contains(const String& key) = 0;
- virtual bool canAccessStorage(Frame*) = 0;
virtual StorageType storageType() const = 0;
virtual size_t memoryBytesUsedByCache() = 0;
+2017-07-31 Sam Weinig <sam@webkit.org>
+
+ Remove unnecessary exceptions from storage code
+ https://bugs.webkit.org/show_bug.cgi?id=174572
+
+ Reviewed by Chris Dumez.
+
+ * WebProcess/Storage/StorageAreaImpl.cpp:
+ (WebKit::StorageAreaImpl::canAccessStorage): Deleted.
+ * WebProcess/Storage/StorageAreaImpl.h:
+ * WebProcess/Storage/StorageNamespaceImpl.cpp:
+ Remove canAccessStorage. It is no longer called.
+
2017-07-30 Brady Eidson <beidson@apple.com>
Add URLSchemeHandler API tests that verify the lack of URLSchemeTask object leaks.
return m_storageAreaMap->contains(key);
}
-bool StorageAreaImpl::canAccessStorage(Frame* frame)
-{
- return frame && frame->page();
-}
-
StorageType StorageAreaImpl::storageType() const
{
return m_storageAreaMap->storageType();
void removeItem(WebCore::Frame* sourceFrame, const String& key) override;
void clear(WebCore::Frame* sourceFrame) override;
bool contains(const String& key) override;
- bool canAccessStorage(WebCore::Frame*) override;
WebCore::StorageType storageType() const override;
size_t memoryBytesUsedByCache() override;
void incrementAccessCount() override;
return m_storageMap->contains(key);
}
- bool canAccessStorage(Frame* frame)
- {
- return frame && frame->page();
- }
-
StorageType storageType() const
{
return StorageType::EphemeralLocal;
+2017-07-31 Sam Weinig <sam@webkit.org>
+
+ Remove unnecessary exceptions from storage code
+ https://bugs.webkit.org/show_bug.cgi?id=174572
+
+ Reviewed by Chris Dumez.
+
+ * Storage/StorageAreaImpl.cpp:
+ (WebKit::StorageAreaImpl::canAccessStorage): Deleted.
+ * Storage/StorageAreaImpl.h:
+ Remove canAccessStorage. It is no longer called.
+
2017-07-14 Filip Pizlo <fpizlo@apple.com>
It should be easy to decide how WebKit yields
ASSERT(!m_isShutdown);
}
-bool StorageAreaImpl::canAccessStorage(Frame* frame)
-{
- return frame && frame->page();
-}
-
StorageType StorageAreaImpl::storageType() const
{
return m_storageType;
void clear(WebCore::Frame* sourceFrame) override;
bool contains(const String& key) override;
- bool canAccessStorage(WebCore::Frame* sourceFrame) override;
WebCore::StorageType storageType() const override;
size_t memoryBytesUsedByCache() override;