[iOS] QuickLook documents loaded from file: URLs should be allowed to perform same...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 00:24:27 +0000 (00:24 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Apr 2019 00:24:27 +0000 (00:24 +0000)
commitcb754451d4a476b69cb53c22cd09ec429630ac3a
tree0771abcf2296aa4a06a7961a6d91e2ccf750e96e
parent0835c68727a903daf44851e1925ec584b1b21b6b
[iOS] QuickLook documents loaded from file: URLs should be allowed to perform same-document navigations
https://bugs.webkit.org/show_bug.cgi?id=196749
<rdar://problem/35773454>

Reviewed by Daniel Bates.

Source/WebCore:

QuickLook previews are in a non-local origin defined by a unique x-apple-ql-id: URL, which
isolates the origin that hosted the document from the document preview itself. When a
QuickLook document is loaded as a file: URL, SecurityOrigin's protections against loading
local resources from non-local origins prevented navigations like location.reload() and
fragment navigations.

To allow reloads and same-document navigations in QuickLook documents loaded from file: URLs,
we should grant the QuickLook document's SecurityOrigin access to the file path that loaded
the preview.

Added a new API test.

* dom/Document.cpp:
(WebCore::Document::applyQuickLookSandbox):
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::createNonLocalWithAllowedFilePath):
(WebCore::SecurityOrigin::canDisplay const):
* page/SecurityOrigin.h:

Tools:

Added a new QuickLook API test and added new expectations to existing QuickLook tests.

* TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:
(-[QuickLookDelegate webView:didStartProvisionalNavigation:]):
(-[QuickLookDelegate webView:didFinishNavigation:]):
(-[QuickLookDelegate _webView:didFailNavigation:withError:userInfo:]):
(-[QuickLookDelegate webView:didFailProvisionalNavigation:withError:]):
(runTest):
(runTestDecideBeforeLoading):
(runTestDecideAfterLoading):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/SecurityOrigin.cpp
Source/WebCore/page/SecurityOrigin.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm