[Web App Manifest] Add SPI for fetching the manifest
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 22:26:32 +0000 (22:26 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 22:26:32 +0000 (22:26 +0000)
commit20b3c95b3b6dd8568f85bb0343233f8727b9e2c1
treef408d3d3e673f2569b48d10d934d11955282127c
parent0472af081249d995b93e4ec83e924cb6cbcef8ab
[Web App Manifest] Add SPI for fetching the manifest
https://bugs.webkit.org/show_bug.cgi?id=180294
rdar://problem/34747968

Patch by David Quesada <david_quesada@apple.com> on 2017-12-06
Reviewed by Geoffrey Garen.

Source/WebCore:

Test: applicationmanifest/developer-warnings.html

* Modules/applicationmanifest/ApplicationManifest.h:
(WebCore::ApplicationManifest::encode const):
(WebCore::ApplicationManifest::decode):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::logManifestPropertyNotAString):
(WebCore::ApplicationManifestParser::logManifestPropertyInvalidURL):
    Drive-by wording changes. Since the warning is prefixed with "parsing
    application manifest:", remove a redundant use of "application manifest".

Source/WebKit:

Add a new method -[WKWebView _getApplicationManifestWithCompletionHandler:] to request
the manifest associated with the current page.

* Shared/API/APIObject.h:
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* UIProcess/API/APIApplicationManifest.h: Copied from Source/WebCore/Modules/applicationmanifest/ApplicationManifest.h.
    Add a new API object type for application manifests.
* UIProcess/API/C/WKPage.cpp:
(WKPageGetApplicationManifest_b):
    Add a C version of this SPI for WebKitTestRunner.
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _getApplicationManifestWithCompletionHandler:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKApplicationManifest.h: Copied from Source/WebCore/Modules/applicationmanifest/ApplicationManifest.h.
* UIProcess/API/Cocoa/_WKApplicationManifest.mm: Added.
(-[_WKApplicationManifest initWithCoder:]):
(-[_WKApplicationManifest encodeWithCoder:]):
(+[_WKApplicationManifest applicationManifestFromJSON:manifestURL:documentURL:]):
(-[_WKApplicationManifest _apiObject]):
(nullableNSString):
(-[_WKApplicationManifest name]):
(-[_WKApplicationManifest shortName]):
(-[_WKApplicationManifest applicationDescription]):
(-[_WKApplicationManifest scope]):
(-[_WKApplicationManifest startURL]):
* UIProcess/API/Cocoa/_WKApplicationManifestInternal.h: Copied from Source/WebCore/Modules/applicationmanifest/ApplicationManifest.h.
(API::wrapper):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::applicationManifestCallback):
(WebKit::WebPageProxy::getApplicationManifest):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::finishedLoadingApplicationManifest):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getApplicationManifest):
(WebKit::WebPage::didFinishLoadingApplicationManifest):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm: Added.
    Added two API tests for _WKApplicationManifest:
    - Testing _WKApplicationManifest's conformance to NSCoding.
    - Testing -[WKWebView _getApplicationManifestWithCompletionHandler:], verifying the
      values of the resulting _WKApplicationManifest.
(TestWebKitAPI::TEST):

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
    Added a new testRunner method getApplicationManifestThen(), used by the LayoutTests
    to request the document load its associated manifest. The layout tests formerly called
    an unimplemented function getManifestThen(), but I added 'Application' to somewhat
    differentiate this from the app cache manifest.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::getApplicationManifestThen):
(WTR::TestRunner::didGetApplicationManifest):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* TestExpectations:
    Skip the app manifest-related layout tests for now while the feature is still disabled.
    Also moved the expectations disabling the manifest-src layout tests (which now pass
    when the feature is enabled) to the same location in the file.
* applicationmanifest/developer-warnings-expected.txt: Added.
* applicationmanifest/developer-warnings.html: Added.
* applicationmanifest/multiple-links-expected.txt: Added.
* applicationmanifest/multiple-links.html: Added.
    Add a layout test to verify only the first manifest link is loaded when there
    are multiple on the page.
* applicationmanifest/resources/developer-warnings.manifest: Added.
    Add a layout test to verify that warnings generated while parsing the manifest are
    logged to the console.
* http/tests/security/contentSecurityPolicy/manifest-src-allowed.html:
    Replaced calls to getManifestThen() with getApplicationManifestThen().
* http/tests/security/contentSecurityPolicy/manifest-src-blocked-expected.txt:
    Updated the expected console message to reflect the current wording for CSP violations.
* http/tests/security/contentSecurityPolicy/manifest-src-blocked.html:
    Replaced calls to getManifestThen() with getApplicationManifestThen().
* http/tests/security/contentSecurityPolicy/manifest.test/manifest.json:
    Removed a trailing newline that was causing JSON parsing to fail.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225598 268f45cc-cd09-0410-ab3c-d52691b4dbfc
42 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/applicationmanifest/developer-warnings-expected.txt [new file with mode: 0644]
LayoutTests/applicationmanifest/developer-warnings.html [new file with mode: 0644]
LayoutTests/applicationmanifest/multiple-links-expected.txt [new file with mode: 0644]
LayoutTests/applicationmanifest/multiple-links.html [new file with mode: 0644]
LayoutTests/applicationmanifest/resources/developer-warnings.manifest [new file with mode: 0644]
LayoutTests/http/tests/security/contentSecurityPolicy/manifest-src-allowed.html
LayoutTests/http/tests/security/contentSecurityPolicy/manifest-src-blocked-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/manifest-src-blocked.html
LayoutTests/http/tests/security/contentSecurityPolicy/manifest.test/manifest.json
Source/WebCore/ChangeLog
Source/WebCore/Modules/applicationmanifest/ApplicationManifest.h
Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/API/APIObject.h
Source/WebKit/Shared/Cocoa/APIObject.mm
Source/WebKit/UIProcess/API/APIApplicationManifest.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/C/WKPagePrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm [new file with mode: 0644]
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifestInternal.h [new file with mode: 0644]
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm [new file with mode: 0644]
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestInvocation.cpp