Add WebKit2 SPI to create a DOM File object
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 00:42:26 +0000 (00:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 00:42:26 +0000 (00:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142109

Patch by Sam Weinig <sam@webkit.org> on 2015-02-27
Reviewed by Tim Horton.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
Make <WebCore/File.h> (and associated files) available to WebKit2.

Source/WebKit2:

Add a new handle type for exposing a DOM File object to script. Follow
the pattern of WKBundleNodeHandleRef and WKBundleRangeHandleRef with the
new class WKBundleFileHandleRef. It can be created for a specific path,
and then the JS wrapper can be obtained via WKBundleFrameGetJavaScriptWrapperForFileForWorld.

* Shared/API/APIObject.h:
* Shared/API/c/WKBase.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp: Added.
(WKBundleFileHandleGetTypeID):
(WKBundleFileHandleCreateWithPath):
* WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h: Added.
* WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameGetJavaScriptWrapperForFileForWorld):
* WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp: Added.
(WebKit::domHandleCache):
(WebKit::InjectedBundleFileHandle::create):
(WebKit::InjectedBundleFileHandle::getOrCreate):
(WebKit::InjectedBundleFileHandle::InjectedBundleFileHandle):
(WebKit::InjectedBundleFileHandle::~InjectedBundleFileHandle):
(WebKit::InjectedBundleFileHandle::coreFile):
* WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h: Added.
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::jsWrapperForWorld):
* WebProcess/WebPage/WebFrame.h:

Tools:

Add a test for WKBundleFileHandleRef.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle.cpp: Added.
(TestWebKitAPI::didReceiveMessageFromInjectedBundle):
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle_Bundle.cpp: Added.
(TestWebKitAPI::WKBundleFileHandleTest::WKBundleFileHandleTest):
* TestWebKitAPI/Tests/WebKit2/bundle-file.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180798 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/APIObject.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle_Bundle.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/bundle-file.html [new file with mode: 0644]

index cb34117..4b7b76d 100644 (file)
@@ -1,3 +1,13 @@
+2015-02-27  Sam Weinig  <sam@webkit.org>
+
+        Add WebKit2 SPI to create a DOM File object
+        https://bugs.webkit.org/show_bug.cgi?id=142109
+
+        Reviewed by Tim Horton.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Make <WebCore/File.h> (and associated files) available to WebKit2.
+
 2015-02-27  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Subpixel] Subpixelize RenderListMarker
index 9315617..c0ed16b 100644 (file)
                2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; };
                2E0888E6114884E200AF4265 /* JSDOMFormDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888E5114884E200AF4265 /* JSDOMFormDataCustom.cpp */; };
                2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */; };
-               2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99CC10E2BBDA00496337 /* JSBlob.h */; };
+               2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99CC10E2BBDA00496337 /* JSBlob.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E2D99E710E2BC1C00496337 /* DOMBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E510E2BC1C00496337 /* DOMBlob.h */; };
                2E2D99E810E2BC1C00496337 /* DOMBlob.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E2D99E610E2BC1C00496337 /* DOMBlob.mm */; };
                2E2D99EA10E2BC3800496337 /* DOMBlobInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E910E2BC3800496337 /* DOMBlobInternal.h */; };
                7C74D43C1882400400E5ED57 /* UTextProviderUTF16.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C74D43A1882400400E5ED57 /* UTextProviderUTF16.h */; };
                7C9DBFED1A9C49B1000D6B25 /* JSHTMLAttachmentElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C9DBFEB1A9C49B1000D6B25 /* JSHTMLAttachmentElement.cpp */; };
                7C9DBFEE1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */; };
+               7CC289DF1AA0FE5D009A9CE3 /* URLRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEE393817974274001D7580 /* URLRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CC564B818BABEA6001B9652 /* TelephoneNumberDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC564B618BABEA6001B9652 /* TelephoneNumberDetector.h */; };
                7CC564BA18BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */; };
                7CC69940191EC5F500AF2270 /* JSWebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */; };
                9767CE0B145ABC13005E64DB /* ExceptionHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 9767CE09145ABC12005E64DB /* ExceptionHeaders.h */; };
                9767CE0C145ABC13005E64DB /* ExceptionInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 9767CE0A145ABC13005E64DB /* ExceptionInterfaces.h */; };
                976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C59122B8A3D001FD1F7 /* Blob.cpp */; };
-               976D6C79122B8A3D001FD1F7 /* Blob.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5A122B8A3D001FD1F7 /* Blob.h */; };
+               976D6C79122B8A3D001FD1F7 /* Blob.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5A122B8A3D001FD1F7 /* Blob.h */; settings = {ATTRIBUTES = (Private, ); }; };
                976D6C7B122B8A3D001FD1F7 /* WebKitBlobBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C5C122B8A3D001FD1F7 /* WebKitBlobBuilder.cpp */; };
                976D6C7C122B8A3D001FD1F7 /* WebKitBlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5D122B8A3D001FD1F7 /* WebKitBlobBuilder.h */; };
                976D6C7E122B8A3D001FD1F7 /* BlobURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C5F122B8A3D001FD1F7 /* BlobURL.cpp */; };
                976D6C7F122B8A3D001FD1F7 /* BlobURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C60122B8A3D001FD1F7 /* BlobURL.h */; };
                976D6C80122B8A3D001FD1F7 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C61122B8A3D001FD1F7 /* File.cpp */; };
-               976D6C81122B8A3D001FD1F7 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C62122B8A3D001FD1F7 /* File.h */; };
+               976D6C81122B8A3D001FD1F7 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C62122B8A3D001FD1F7 /* File.h */; settings = {ATTRIBUTES = (Private, ); }; };
                976D6C83122B8A3D001FD1F7 /* FileError.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C64122B8A3D001FD1F7 /* FileError.h */; };
                976D6C85122B8A3D001FD1F7 /* FileList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C66122B8A3D001FD1F7 /* FileList.cpp */; };
                976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C67122B8A3D001FD1F7 /* FileList.h */; };
                BC00F0080E0A185500FD04E3 /* DOMFileList.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00F0020E0A185500FD04E3 /* DOMFileList.mm */; };
                BC00F0090E0A185500FD04E3 /* DOMFileListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0030E0A185500FD04E3 /* DOMFileListInternal.h */; };
                BC00F0140E0A189500FD04E3 /* JSFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC00F0100E0A189500FD04E3 /* JSFile.cpp */; };
-               BC00F0150E0A189500FD04E3 /* JSFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0110E0A189500FD04E3 /* JSFile.h */; };
+               BC00F0150E0A189500FD04E3 /* JSFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0110E0A189500FD04E3 /* JSFile.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC00F0160E0A189500FD04E3 /* JSFileList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC00F0120E0A189500FD04E3 /* JSFileList.cpp */; };
                BC00F0170E0A189500FD04E3 /* JSFileList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0130E0A189500FD04E3 /* JSFileList.h */; };
                BC00F0360E0A19DB00FD04E3 /* DOMFile.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; };
                                2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */,
                                0F54DCE01880F901003EEDBB /* DOMGestureEvent.h in Headers */,
                                0F54DCE21880F901003EEDBB /* DOMGestureEventInternal.h in Headers */,
+                               7CC289DF1AA0FE5D009A9CE3 /* URLRegistry.h in Headers */,
                                BC1A37B6097C715F0019F3D8 /* DOMHTML.h in Headers */,
                                319848081A1E6CB500A13318 /* DOMAnimationEvent.h in Headers */,
                                85DF81270AA7787200486AD7 /* DOMHTMLAnchorElement.h in Headers */,
index 43a32e0..b9d1b5b 100644 (file)
@@ -1,3 +1,38 @@
+2015-02-27  Sam Weinig  <sam@webkit.org>
+
+        Add WebKit2 SPI to create a DOM File object
+        https://bugs.webkit.org/show_bug.cgi?id=142109
+
+        Reviewed by Tim Horton.
+
+        Add a new handle type for exposing a DOM File object to script. Follow
+        the pattern of WKBundleNodeHandleRef and WKBundleRangeHandleRef with the
+        new class WKBundleFileHandleRef. It can be created for a specific path,
+        and then the JS wrapper can be obtained via WKBundleFrameGetJavaScriptWrapperForFileForWorld.
+
+        * Shared/API/APIObject.h:
+        * Shared/API/c/WKBase.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
+        * WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp: Added.
+        (WKBundleFileHandleGetTypeID):
+        (WKBundleFileHandleCreateWithPath):
+        * WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h: Added.
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
+        (WKBundleFrameGetJavaScriptWrapperForFileForWorld):
+        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp: Added.
+        (WebKit::domHandleCache):
+        (WebKit::InjectedBundleFileHandle::create):
+        (WebKit::InjectedBundleFileHandle::getOrCreate):
+        (WebKit::InjectedBundleFileHandle::InjectedBundleFileHandle):
+        (WebKit::InjectedBundleFileHandle::~InjectedBundleFileHandle):
+        (WebKit::InjectedBundleFileHandle::coreFile):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h: Added.
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::jsWrapperForWorld):
+        * WebProcess/WebPage/WebFrame.h:
+
 2015-02-27  Beth Dakin  <bdakin@apple.com>
 
         Lookup panel dismisses when pages are loading in other tabs/windows
index 97be261..6e1dc9f 100644 (file)
@@ -154,6 +154,7 @@ public:
         BundleBackForwardListItem,
         BundleCSSStyleDeclarationHandle,
         BundleDOMWindowExtension,
+        BundleFileHandle,
         BundleFrame,
         BundleHitTestResult,
         BundleInspector,
index 13af154..8613319 100644 (file)
@@ -146,6 +146,7 @@ typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
 typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
 typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
 typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensionRef;
+typedef const struct OpaqueWKBundleFileHandle* WKBundleFileHandleRef;
 typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
 typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
 typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
index e10c61f..bcee118 100644 (file)
                7CB16FF21724BA28007A0A95 /* com.macromedia.Flash Player.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7CB16FE51724B9B5007A0A95 /* com.macromedia.Flash Player.plugin.sb */; };
                7CB16FF31724BA2F007A0A95 /* com.microsoft.SilverlightPlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7CB16FE61724B9B5007A0A95 /* com.microsoft.SilverlightPlugin.sb */; };
                7CB16FF41724BA30007A0A95 /* com.oracle.java.JavaAppletPlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7CB16FE71724B9B5007A0A95 /* com.oracle.java.JavaAppletPlugin.sb */; };
+               7CBB811C1AA0F8B1006B1942 /* InjectedBundleFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBB811A1AA0F8B1006B1942 /* InjectedBundleFileHandle.cpp */; };
+               7CBB811D1AA0F8B1006B1942 /* InjectedBundleFileHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBB811B1AA0F8B1006B1942 /* InjectedBundleFileHandle.h */; };
+               7CBB81201AA0F970006B1942 /* WKBundleFileHandleRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBB811E1AA0F970006B1942 /* WKBundleFileHandleRef.cpp */; };
+               7CBB81211AA0F970006B1942 /* WKBundleFileHandleRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBB811F1AA0F970006B1942 /* WKBundleFileHandleRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CC99A3618EF7CBC0048C8B4 /* WKScriptMessageInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC99A3518EF7CBC0048C8B4 /* WKScriptMessageInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CCCC8FA1A5F50FD008FB0DA /* WebNavigationState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCCC8F81A5F50FD008FB0DA /* WebNavigationState.cpp */; };
                7CCCC8FB1A5F50FD008FB0DA /* WebNavigationState.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CCCC8F91A5F50FD008FB0DA /* WebNavigationState.h */; };
                7CB16FE51724B9B5007A0A95 /* com.macromedia.Flash Player.plugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "com.macromedia.Flash Player.plugin.sb"; sourceTree = "<group>"; };
                7CB16FE61724B9B5007A0A95 /* com.microsoft.SilverlightPlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.microsoft.SilverlightPlugin.sb; sourceTree = "<group>"; };
                7CB16FE71724B9B5007A0A95 /* com.oracle.java.JavaAppletPlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.oracle.java.JavaAppletPlugin.sb; sourceTree = "<group>"; };
+               7CBB811A1AA0F8B1006B1942 /* InjectedBundleFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFileHandle.cpp; sourceTree = "<group>"; };
+               7CBB811B1AA0F8B1006B1942 /* InjectedBundleFileHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleFileHandle.h; sourceTree = "<group>"; };
+               7CBB811E1AA0F970006B1942 /* WKBundleFileHandleRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandleRef.cpp; sourceTree = "<group>"; };
+               7CBB811F1AA0F970006B1942 /* WKBundleFileHandleRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleFileHandleRef.h; sourceTree = "<group>"; };
                7CC99A3518EF7CBC0048C8B4 /* WKScriptMessageInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKScriptMessageInternal.h; sourceTree = "<group>"; };
                7CCCC8F81A5F50FD008FB0DA /* WebNavigationState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNavigationState.cpp; sourceTree = "<group>"; };
                7CCCC8F91A5F50FD008FB0DA /* WebNavigationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNavigationState.h; sourceTree = "<group>"; };
                                935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */,
                                51FA2D7515212E1E00C1BA0B /* WKBundleDOMWindowExtension.cpp */,
                                51FA2D541521118600C1BA0B /* WKBundleDOMWindowExtension.h */,
+                               7CBB811E1AA0F970006B1942 /* WKBundleFileHandleRef.cpp */,
+                               7CBB811F1AA0F970006B1942 /* WKBundleFileHandleRef.h */,
                                BCD25F1611D6BDE100169B0E /* WKBundleFrame.cpp */,
                                BCD25F1511D6BDE100169B0E /* WKBundleFrame.h */,
                                BCF049E411FE20F600F86A58 /* WKBundleFramePrivate.h */,
                        children = (
                                7C4ED3261A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.cpp */,
                                7C4ED3271A3119D90079BD49 /* InjectedBundleCSSStyleDeclarationHandle.h */,
+                               7CBB811A1AA0F8B1006B1942 /* InjectedBundleFileHandle.cpp */,
+                               7CBB811B1AA0F8B1006B1942 /* InjectedBundleFileHandle.h */,
                                BC4BEEAA120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp */,
                                BC4BEEA9120A0A5E00FBA0C7 /* InjectedBundleNodeHandle.h */,
                                BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */,
                                2DF9EEEC1A7836EE00B6CFBE /* APINavigationAction.h in Headers */,
                                BC54CACB12D64291005C67B0 /* WebGeolocationManagerProxy.h in Headers */,
                                BC0E618312D6CB1D0012A72A /* WebGeolocationManagerProxyMessages.h in Headers */,
+                               7CBB811D1AA0F8B1006B1942 /* InjectedBundleFileHandle.h in Headers */,
                                BC0E607312D6BC200012A72A /* WebGeolocationPosition.h in Headers */,
                                BC1BE1F212D54DBD0004A228 /* WebGeolocationProvider.h in Headers */,
                                7801C09A142290C400FAF9AF /* WebHitTestResult.h in Headers */,
                                BC40760E124FF0270068F20A /* WKURLResponse.h in Headers */,
                                BC40762B124FF0400068F20A /* WKURLResponseNS.h in Headers */,
                                1AFA3AC918E61C61003CCBAE /* WKUserContentController.h in Headers */,
+                               7CBB81211AA0F970006B1942 /* WKBundleFileHandleRef.h in Headers */,
                                1AAF08A4192682DA00B6390C /* WKUserContentControllerInternal.h in Headers */,
                                377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */,
                                F6113E29126CE19B0057D0A7 /* WKUserContentURLPattern.h in Headers */,
                                1C8E28351275D73800BC7BD0 /* WebInspectorProxy.cpp in Sources */,
                                1CA8B936127C774E00576C2B /* WebInspectorProxyMac.mm in Sources */,
                                1CA8B945127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp in Sources */,
+                               7CBB811C1AA0F8B1006B1942 /* InjectedBundleFileHandle.cpp in Sources */,
                                1C891D6519B124FF00BA79DD /* WebInspectorUI.cpp in Sources */,
                                1CA8B954127C891500576C2B /* WebInspectorUIMac.mm in Sources */,
                                1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */,
                                C0337DD8127A51B6008FF4F4 /* WebTouchEvent.cpp in Sources */,
                                2DA944A31884E4F000ED86DB /* WebTouchEventIOS.cpp in Sources */,
                                BCA0EF8012331E78007D3CFB /* WebUndoStep.cpp in Sources */,
+                               7CBB81201AA0F970006B1942 /* WKBundleFileHandleRef.cpp in Sources */,
                                1AAF08AD1926936700B6390C /* WebUserContentController.cpp in Sources */,
                                1AAF08B719269E6D00B6390C /* WebUserContentControllerMessageReceiver.cpp in Sources */,
                                1AAF08A1192681D100B6390C /* WebUserContentControllerProxy.cpp in Sources */,
index 47e6e53..9ed8885 100644 (file)
@@ -40,6 +40,7 @@ class InjectedBundleBackForwardList;
 class InjectedBundleBackForwardListItem;
 class InjectedBundleCSSStyleDeclarationHandle;
 class InjectedBundleDOMWindowExtension;
+class InjectedBundleFileHandle;
 class InjectedBundleHitTestResult;
 class InjectedBundleNavigationAction;
 class InjectedBundleNodeHandle;
@@ -56,6 +57,7 @@ WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardList
 WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
 WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclarationHandle)
 WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension)
+WK_ADD_API_MAPPING(WKBundleFileHandleRef, InjectedBundleFileHandle)
 WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
 WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
 WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.cpp
new file mode 100644 (file)
index 0000000..da8cae8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WKBundleFileHandleRef.h"
+
+#include "InjectedBundleFileHandle.h"
+#include "WKAPICast.h"
+#include "WKBundleAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKBundleFileHandleGetTypeID()
+{
+    return toAPI(InjectedBundleFileHandle::APIType);
+}
+
+WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef pathRef)
+{
+    return toAPI(InjectedBundleFileHandle::create(toWTFString(pathRef)).leakRef());
+}
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFileHandleRef.h
new file mode 100644 (file)
index 0000000..e1a16fb
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#ifndef WKBundleFileHandleRef_h
+#define WKBundleFileHandleRef_h
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBundleFileHandleGetTypeID();
+
+WK_EXPORT WKBundleFileHandleRef WKBundleFileHandleCreateWithPath(WKStringRef path);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* WKBundleFileHandleRef_h */
index b781407..a0f624e 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "APIArray.h"
 #include "APISecurityOrigin.h"
+#include "InjectedBundleFileHandle.h"
 #include "InjectedBundleHitTestResult.h"
 #include "InjectedBundleNodeHandle.h"
 #include "InjectedBundleRangeHandle.h"
@@ -122,6 +123,11 @@ JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef fr
     return toImpl(frameRef)->jsWrapperForWorld(toImpl(rangeHandleRef), toImpl(worldRef));
 }
 
+JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frameRef, WKBundleFileHandleRef fileHandleRef, WKBundleScriptWorldRef worldRef)
+{
+    return toImpl(frameRef)->jsWrapperForWorld(toImpl(fileHandleRef), toImpl(worldRef));
+}
+
 WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef)
 {
     return toCopiedAPI(toImpl(frameRef)->name());
index 70cc164..84ddfc0 100644 (file)
@@ -55,6 +55,7 @@ WK_EXPORT WKBundleFrameRef WKBundleFrameForJavaScriptContext(JSContextRef contex
 
 WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world);
 WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForRangeForWorld(WKBundleFrameRef frame, WKBundleRangeHandleRef rangeHandle, WKBundleScriptWorldRef world);
+WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForFileForWorld(WKBundleFrameRef frame, WKBundleFileHandleRef fileHandle, WKBundleScriptWorldRef world);
 
 WK_EXPORT WKBundlePageRef WKBundleFrameGetPage(WKBundleFrameRef frame);
 
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.cpp
new file mode 100644 (file)
index 0000000..193403a
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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 "InjectedBundleFileHandle.h"
+
+#include <WebCore/File.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef HashMap<File*, InjectedBundleFileHandle*> DOMHandleCache;
+
+static DOMHandleCache& domHandleCache()
+{
+    static NeverDestroyed<DOMHandleCache> cache;
+    return cache;
+}
+
+RefPtr<InjectedBundleFileHandle> InjectedBundleFileHandle::create(const String& path)
+{
+    auto file = File::create(path);
+    return adoptRef(new InjectedBundleFileHandle(file.get()));
+}
+
+RefPtr<InjectedBundleFileHandle> InjectedBundleFileHandle::getOrCreate(File* file)
+{
+    if (!file)
+        return nullptr;
+
+    DOMHandleCache::AddResult result = domHandleCache().add(file, nullptr);
+    if (!result.isNewEntry)
+        return RefPtr<InjectedBundleFileHandle>(result.iterator->value);
+
+    RefPtr<InjectedBundleFileHandle> fileHandle = adoptRef(new InjectedBundleFileHandle(*file));
+    result.iterator->value = fileHandle.get();
+    return fileHandle;
+}
+
+InjectedBundleFileHandle::InjectedBundleFileHandle(File& file)
+    : m_file(file)
+{
+}
+
+InjectedBundleFileHandle::~InjectedBundleFileHandle()
+{
+    domHandleCache().remove(m_file.ptr());
+}
+
+File* InjectedBundleFileHandle::coreFile()
+{
+    return m_file.ptr();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h b/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleFileHandle.h
new file mode 100644 (file)
index 0000000..27fd2cb
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#ifndef InjectedBundleFileHandle_h
+#define InjectedBundleFileHandle_h
+
+#include "APIObject.h"
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+class File;
+}
+
+namespace WebKit {
+
+class InjectedBundleFileHandle : public API::ObjectImpl<API::Object::Type::BundleFileHandle> {
+public:
+    static RefPtr<InjectedBundleFileHandle> create(const WTF::String&);
+    static RefPtr<InjectedBundleFileHandle> getOrCreate(WebCore::File*);
+
+    virtual ~InjectedBundleFileHandle();
+
+    WebCore::File* coreFile();
+
+private:
+    InjectedBundleFileHandle(WebCore::File&);
+
+    Ref<WebCore::File> m_file;
+};
+
+} // namespace WebKit
+
+#endif // InjectedBundleFileHandle_h
index 1513b88..85d8337 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "APIArray.h"
 #include "DownloadManager.h"
+#include "InjectedBundleFileHandle.h"
 #include "InjectedBundleHitTestResult.h"
 #include "InjectedBundleNodeHandle.h"
 #include "InjectedBundleRangeHandle.h"
@@ -49,6 +50,7 @@
 #include <WebCore/Chrome.h>
 #include <WebCore/DocumentLoader.h>
 #include <WebCore/EventHandler.h>
+#include <WebCore/File.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameSnapshotting.h>
 #include <WebCore/FrameView.h>
@@ -60,6 +62,7 @@
 #include <WebCore/ImageBuffer.h>
 #include <WebCore/JSCSSStyleDeclaration.h>
 #include <WebCore/JSElement.h>
+#include <WebCore/JSFile.h>
 #include <WebCore/JSRange.h>
 #include <WebCore/MainFrame.h>
 #include <WebCore/NetworkingContext.h>
@@ -685,6 +688,18 @@ JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, I
     return toRef(exec, toJS(exec, globalObject, rangeHandle->coreRange()));
 }
 
+JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleFileHandle* fileHandle, InjectedBundleScriptWorld* world)
+{
+    if (!m_coreFrame)
+        return nullptr;
+
+    JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
+    ExecState* exec = globalObject->globalExec();
+
+    JSLockHolder lock(exec);
+    return toRef(exec, toJS(exec, globalObject, fileHandle->coreFile()));
+}
+
 String WebFrame::counterValue(JSObjectRef element)
 {
     if (!toJS(element)->inherits(JSElement::info()))
index 3a573e0..7195d6a 100644 (file)
@@ -54,6 +54,7 @@ class URL;
 
 namespace WebKit {
 
+class InjectedBundleFileHandle;
 class InjectedBundleHitTestResult;
 class InjectedBundleNodeHandle;
 class InjectedBundleRangeHandle;
@@ -117,6 +118,7 @@ public:
 
     JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*);
     JSValueRef jsWrapperForWorld(InjectedBundleRangeHandle*, InjectedBundleScriptWorld*);
+    JSValueRef jsWrapperForWorld(InjectedBundleFileHandle*, InjectedBundleScriptWorld*);
 
     static String counterValue(JSObjectRef element);
 
index 46f8dd0..a6bbe25 100644 (file)
@@ -1,3 +1,21 @@
+2015-02-27  Sam Weinig  <sam@webkit.org>
+
+        Add WebKit2 SPI to create a DOM File object
+        https://bugs.webkit.org/show_bug.cgi?id=142109
+
+        Reviewed by Tim Horton.
+
+        Add a test for WKBundleFileHandleRef.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle.cpp: Added.
+        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
+        (TestWebKitAPI::didFinishLoadForFrame):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle_Bundle.cpp: Added.
+        (TestWebKitAPI::WKBundleFileHandleTest::WKBundleFileHandleTest):
+        * TestWebKitAPI/Tests/WebKit2/bundle-file.html: Added.
+
 2015-02-27  Michael Saboff  <msaboff@apple.com>
 
         Add ability for run-jsc-benchmarks to set library path from test binary when run on a build bot
index fb50337..99588a8 100644 (file)
@@ -56,6 +56,9 @@
                7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */; };
                76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
                76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 76E182DE15475A8300F1FADD /* auto-submitting-form.html */; };
+               7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C486BA01AA1254B003F6F9B /* bundle-file.html */; };
+               7C54A4BE1AA11CCA00380F78 /* WKBundleFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */; };
+               7C54A4C11AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */; };
                7C89D2AC1A69B80D003A5FDE /* WKPageConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2AA1A69B80D003A5FDE /* WKPageConfiguration.cpp */; };
                7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */; };
                7CCE7EA41A4119F300447C4C /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = C08587FF13FEC3A6001EF4E5 /* InstanceMethodSwizzler.mm */; };
                        dstPath = TestWebKitAPI.resources;
                        dstSubfolderSpec = 7;
                        files = (
+                               7C486BA11AA12567003F6F9B /* bundle-file.html in Copy Resources */,
                                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
                                379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
                                2D950FC01A230C3A00012434 /* action-menu-targets.html in Copy Resources */,
                76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent.cpp; sourceTree = "<group>"; };
                76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent_Bundle.cpp; sourceTree = "<group>"; };
                76E182DE15475A8300F1FADD /* auto-submitting-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "auto-submitting-form.html"; sourceTree = "<group>"; };
+               7C486BA01AA1254B003F6F9B /* bundle-file.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "bundle-file.html"; sourceTree = "<group>"; };
+               7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle.cpp; sourceTree = "<group>"; };
+               7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleFileHandle_Bundle.cpp; sourceTree = "<group>"; };
                7C6BBD8A19CEA54300C1F5E0 /* Counters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Counters.h; sourceTree = "<group>"; };
                7C6BBD8B19CEA63000C1F5E0 /* Counters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Counters.cpp; sourceTree = "<group>"; };
                7C74D42D188228F300E5ED57 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
                                7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */,
                                76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */,
                                76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */,
+                               7C54A4BC1AA11CCA00380F78 /* WKBundleFileHandle.cpp */,
+                               7C54A4BF1AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp */,
                                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */,
                                7C89D2AA1A69B80D003A5FDE /* WKPageConfiguration.cpp */,
                                51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */,
                                93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */,
                                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
                                76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
+                               7C486BA01AA1254B003F6F9B /* bundle-file.html */,
                                1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
                                290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
                                C5E1AFFD16B22179006CC1F2 /* execCopy.html */,
                                7CCE7EC31A411A7E00447C4C /* InspectorBar.mm in Sources */,
                                7CCE7EA41A4119F300447C4C /* InstanceMethodSwizzler.mm in Sources */,
                                7CCE7EDA1A411A8700447C4C /* InstanceMethodSwizzler.mm in Sources */,
+                               7C54A4BE1AA11CCA00380F78 /* WKBundleFileHandle.cpp in Sources */,
                                7CCE7F371A411B8E00447C4C /* IntegerToStringConversion.cpp in Sources */,
                                7CCE7EAD1A411A3400447C4C /* JavaScriptTest.cpp in Sources */,
                                7CCE7EA51A411A0800447C4C /* JavaScriptTestMac.mm in Sources */,
                                F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */,
                                4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */,
                                BC575AB0126E83C8006F0F12 /* InjectedBundleBasic_Bundle.cpp in Sources */,
+                               7C54A4C11AA11CE400380F78 /* WKBundleFileHandle_Bundle.cpp in Sources */,
                                BC575AA2126E7660006F0F12 /* InjectedBundleController.cpp in Sources */,
                                1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */,
                                378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle.cpp
new file mode 100644 (file)
index 0000000..b9a84ff
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+
+namespace TestWebKitAPI {
+
+static bool done;
+static bool loadDone;
+
+static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef body, const void*)
+{
+    if (!WKStringIsEqualToUTF8CString(messageName, "SUCCESS"))
+        FAIL();
+    else
+        SUCCEED();
+
+    done = true;
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void*)
+{
+    loadDone = true;
+}
+
+TEST(WebKit2, WKBundleFileHandle)
+{
+    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WKBundleFileHandleTest"));
+
+    WKContextInjectedBundleClientV0 injectedBundleClient;
+    memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
+    injectedBundleClient.base.version = 0;
+    injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
+    WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base);
+
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClientV0 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    loaderClient.base.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
+
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("bundle-file", "html")).get());
+    Util::run(&loadDone);
+    
+    // Get path to a file.
+    auto urlToFile = adoptWK(Util::createURLForResource("simple", "html"));
+    auto pathToFile = adoptWK(WKURLCopyPath(urlToFile.get()));
+
+    WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("TestFile").get(), pathToFile.get());
+
+    Util::run(&done);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle_Bundle.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/WKBundleFileHandle_Bundle.cpp
new file mode 100644 (file)
index 0000000..27d359b
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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"
+
+#if WK_HAVE_C_SPI
+
+#include "InjectedBundleTest.h"
+
+#include "PlatformUtilities.h"
+#include <WebKit/WKBundlePage.h>
+#include <WebKit/WKBundleFileHandleRef.h>
+#include <WebKit/WKBundleFrame.h>
+#include <WebKit/WKBundleScriptWorld.h>
+
+namespace TestWebKitAPI {
+
+static WKBundlePageRef loadedPage;
+
+class WKBundleFileHandleTest : public InjectedBundleTest {
+public:
+    WKBundleFileHandleTest(const std::string& identifier)
+        : InjectedBundleTest(identifier)
+    {
+    }
+
+private:
+    virtual void didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody) override
+    {
+        if (!WKStringIsEqualToUTF8CString(messageName, "TestFile")) {
+            WKBundlePostMessage(bundle, Util::toWK("FAIL").get(), Util::toWK("Recieved invalid message").get());
+            return;
+        }
+
+        if (!loadedPage) {
+            WKBundlePostMessage(bundle, Util::toWK("FAIL").get(), Util::toWK("No loaded page").get());
+            return;
+        }
+
+        if (WKGetTypeID(messageBody) != WKStringGetTypeID()) {
+            WKBundlePostMessage(bundle, Util::toWK("FAIL").get(), Util::toWK("Message body has invalid type").get());
+            return;
+        }
+
+        WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(loadedPage);
+        WKBundleScriptWorldRef world = WKBundleScriptWorldNormalWorld();
+        
+        JSGlobalContextRef globalContext = WKBundleFrameGetJavaScriptContextForWorld(mainFrame, world);
+
+        auto fileHandle = adoptWK(WKBundleFileHandleCreateWithPath((WKStringRef)messageBody));
+        JSValueRef jsFileHandle = WKBundleFrameGetJavaScriptWrapperForFileForWorld(mainFrame, fileHandle.get(), world);
+
+        JSObjectRef globalObject = JSContextGetGlobalObject(globalContext);
+
+        JSStringRef jsString = JSStringCreateWithUTF8CString("testFile");
+        JSValueRef function = JSObjectGetProperty(globalContext, globalObject, jsString, nullptr);
+        JSStringRelease(jsString);
+        
+        JSValueRef result = JSObjectCallAsFunction(globalContext, (JSObjectRef)function, globalObject, 1, &jsFileHandle, nullptr);
+
+        if (JSValueToBoolean(globalContext, result))
+            WKBundlePostMessage(bundle, Util::toWK("SUCCESS").get(), nullptr);
+        else
+            WKBundlePostMessage(bundle, Util::toWK("FAIL").get(), Util::toWK("Script failed").get());
+    }
+
+    virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page) override
+    {
+        loadedPage = page;
+    }
+};
+
+static InjectedBundleTest::Register<WKBundleFileHandleTest> registrar("WKBundleFileHandleTest");
+
+} // namespace TestWebKitAPI
+
+#endif
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/bundle-file.html b/Tools/TestWebKitAPI/Tests/WebKit2/bundle-file.html
new file mode 100644 (file)
index 0000000..f426ebd
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+    <script>
+        function testFile(file)
+        {
+            if (!(file instanceof File))
+                return false;
+        
+            return true;
+        }
+    </script>
+</head>
+<body>
+    File test.
+</body>
+</html>