[WebIDL] Remove custom bindings for File and Blob constructors
https://bugs.webkit.org/show_bug.cgi?id=165218

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/basic/request-headers-expected.txt:
* web-platform-tests/fetch/api/basic/request-headers-worker-expected.txt:
Update results (still failing) to account for stricter rules about dictionary default values.

Source/WebCore:

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
Add/remove new files.

* bindings/js/JSBlobCustom.cpp:
(WebCore::constructJSBlob): Deleted.
* bindings/js/JSFileCustom.cpp: Removed.
Remove custom constructors.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDefaultValue):
(GenerateDictionaryImplementationContent):
(GenerateParametersCheck):
Add support for optional sequences without default values. Move string default value
optimizations into GenerateDefaultValue.

* fileapi/Blob.cpp:
(WebCore::Blob::Blob):
* fileapi/Blob.h:
(WebCore::Blob::create):
* fileapi/Blob.idl:
* fileapi/File.cpp:
(WebCore::File::File):
* fileapi/File.h:
* fileapi/File.idl:
Add support for the generated constructors.

* fileapi/BlobBuilder.cpp: Copied from Source/WebCore/fileapi/WebKitBlobBuilder.cpp.
* fileapi/BlobBuilder.h: Copied from Source/WebCore/fileapi/WebKitBlobBuilder.h.
* fileapi/WebKitBlobBuilder.cpp: Removed.
* fileapi/WebKitBlobBuilder.h: Removed.
Rename WebKitBlobBuilder to BlobBuilder, and update to work with generated constructor.

* fileapi/BlobPropertyBag.h: Added.
* fileapi/BlobPropertyBag.idl: Added.
Added.

* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::registerBlobURL):
* fileapi/ThreadableBlobRegistry.h:
* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::registerBlobURL):
* platform/network/BlobRegistryImpl.h:
Avoid copies of the BlobPart Vector.

* platform/network/BlobPart.h:
Replace header-guards with #pragma once.

Source/WebKit2:

* NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
(WebKit::NetworkBlobRegistry::registerBlobURL):
* NetworkProcess/FileAPI/NetworkBlobRegistry.h:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::registerBlobURL):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::registerBlobURL):
* WebProcess/FileAPI/BlobRegistryProxy.h:
Avoid copies of the BlobPart Vector.

LayoutTests:

* fast/files/blob-constructor-expected.txt:
* fast/files/file-constructor-expected.txt:
* fast/files/file-constructor.html:
* fast/files/script-tests/blob-constructor.js:
Update for stricter parsing and changed error text. (The error text
is regressed, but consistent with all generated bindings. I will work
on making improvements on this soon.)

* http/tests/fetch/fetch-as-blob.js:
Update to account for stricter rules about dictionary default values.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@209184 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/files/file-constructor.html b/LayoutTests/fast/files/file-constructor.html
index f0fcf8f..0b59e00 100644
--- a/LayoutTests/fast/files/file-constructor.html
+++ b/LayoutTests/fast/files/file-constructor.html
@@ -16,8 +16,8 @@
 shouldBeTrue("(new File([], 'world.html')) instanceof window.File")
 
 // Verify that the file name argument is required.
-shouldThrow("(new File())", "'TypeError: Argument 1 (\\'fileBits\\') to the File constructor must be an instance of sequence'");
-shouldThrow("(new File([]))", "'TypeError: Argument 2 (\\'filename\\') to the File constructor must be an instance of DOMString'");
+shouldThrow("(new File())", "'TypeError: Not enough arguments'");
+shouldThrow("(new File([]))", "'TypeError: Not enough arguments'");
 
 // Test valid file names.
 shouldBeTrue("(new File([], null)) instanceof window.File");
@@ -28,7 +28,7 @@
 // Test invalid file parts.
 shouldThrow("new File('hello', 'world.html')", '"TypeError: Value is not a sequence"');
 shouldThrow("new File(0, 'world.html')", '"TypeError: Value is not a sequence"');
-shouldThrow("new File(null, 'world.html')", "'TypeError: Argument 1 (\\'fileBits\\') to the File constructor must be an instance of sequence'");
+shouldThrow("new File(null, 'world.html')", "'TypeError: Value is not a sequence'");
 
 // Test valid file parts.
 shouldBeTrue("(new File([], 'world.html')) instanceof window.File");
@@ -72,24 +72,24 @@
 shouldBeTrue("(new File([], 'world.html', {type:'hello\u00EE'})) instanceof window.File");
 shouldBe("(new File([], 'world.html', {type:'hello\u00EE'})).type", "''");
 
-// FilePropertyBag  substeps: Type with non-ascii characters should prevent lastModified from being extracted.
+// FilePropertyBag  substeps: Type with non-ascii characters should not prevent lastModified from being extracted.
 shouldBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye'})).lastModified", "555");
-shouldNotBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye\u00EE'})).lastModified", "555");
+shouldBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye\u00EE'})).lastModified", "555");
 
 // Test various non-object literals being used as property bags.
 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File");
 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File");
-shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
-shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
-shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
-shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
+shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeError: Type error'");
+shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'TypeError: Type error'");
+shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeError: Type error'");
+shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'TypeError: Type error'");
 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File");
-shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File");
+shouldThrow("(new File([], 'world.html', /abc/)) instanceof window.File", "'TypeError: Type error'");
 shouldBeTrue("(new File([], 'world.html', function () {})) instanceof window.File");
 
 // Test that the name/type/size are correctly added to the File.
 shouldBe("(new File([], 'world.html')).name", "'world.html'");
-shouldBe("(new File([], 'w/orld/ht/m.l')).name", "'w:orld:ht:m.l'");
+shouldBe("(new File([], 'w/orld/ht/m.l')).name", "'w/orld/ht/m.l'");
 shouldBe("(new File([], 'world.html', {type:'text/html'})).name", "'world.html'");
 shouldBe("(new File([], 'world.html', {type:'text/html'})).type", "'text/html'");
 shouldBe("(new File([], 'world.html', {type:'text/html'})).size", "0");
@@ -141,9 +141,4 @@
 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in files.
 shouldBe("new Blob([new Blob([new Int32Array(100)]), new File([new Uint16Array(100)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))]).size", "1200");
 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), new File([new Uint16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1200");
-
-// Test passing blob parts in objects with indexed properties.
-// (This depends on the bindings code handling of sequence<T>)
-shouldBe("new File({length: 0}, 'world.txt').size", "0");
-shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6");
 </script>