Title: [101606] trunk
Revision
101606
Author
[email protected]
Date
2011-11-30 21:44:30 -0800 (Wed, 30 Nov 2011)

Log Message

[FileSystem API] DirectoryEntry.getFile path argument is required
https://bugs.webkit.org/show_bug.cgi?id=69642

Patch by Mark Pilgrim <[email protected]> on 2011-11-30
Reviewed by Adam Barth.

Source/WebCore:

Test: fast/filesystem/simple-required-arguments-getfile.html

* bindings/js/JSDirectoryEntryCustom.cpp:
(WebCore::JSDirectoryEntry::getFile): check args length and throw TypeError if not enough arguments
* bindings/v8/custom/V8DirectoryEntryCustom.cpp:
(WebCore::V8DirectoryEntry::getFileCallback): check args length and throw TypeError if not enough arguments

LayoutTests:

* fast/filesystem/resources/simple-required-arguments-getfile.js: Added.
(errorCallback):
(successCallback):
* fast/filesystem/simple-required-arguments-getfile-expected.txt: Added.
* fast/filesystem/simple-required-arguments-getfile.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101605 => 101606)


--- trunk/LayoutTests/ChangeLog	2011-12-01 05:42:29 UTC (rev 101605)
+++ trunk/LayoutTests/ChangeLog	2011-12-01 05:44:30 UTC (rev 101606)
@@ -1,3 +1,16 @@
+2011-11-30  Mark Pilgrim  <[email protected]>
+
+        [FileSystem API] DirectoryEntry.getFile path argument is required
+        https://bugs.webkit.org/show_bug.cgi?id=69642
+
+        Reviewed by Adam Barth.
+
+        * fast/filesystem/resources/simple-required-arguments-getfile.js: Added.
+        (errorCallback):
+        (successCallback):
+        * fast/filesystem/simple-required-arguments-getfile-expected.txt: Added.
+        * fast/filesystem/simple-required-arguments-getfile.html: Added.
+
 2011-11-30  Rafael Weinstein  <[email protected]>
 
         [MutationObservers] Need layout tests asserting that non-event async callbacks deliver mutations after completion

Added: trunk/LayoutTests/fast/filesystem/resources/simple-required-arguments-getfile.js (0 => 101606)


--- trunk/LayoutTests/fast/filesystem/resources/simple-required-arguments-getfile.js	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/resources/simple-required-arguments-getfile.js	2011-12-01 05:44:30 UTC (rev 101606)
@@ -0,0 +1,25 @@
+if (this.importScripts) {
+    importScripts('../resources/fs-worker-common.js');
+    importScripts('../resources/fs-test-util.js');
+}
+
+description("DirectoryEntry required arguments test.");
+
+var fileSystem = null;
+
+function errorCallback(error) {
+    debug("Error occured while requesting a TEMPORARY file system:" + error.code);
+    finishJSTest();
+}
+
+function successCallback(fs) {
+    fileSystem = fs;
+    debug("Successfully obtained TEMPORARY FileSystem:" + fileSystem.name);
+    root = evalAndLog("root = fileSystem.root");
+    shouldThrow("root.getFile()");
+    finishJSTest();
+}
+
+var jsTestIsAsync = true;
+evalAndLog("webkitRequestFileSystem(TEMPORARY, 100, successCallback, errorCallback);");
+var successfullyParsed = true;

Added: trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile-expected.txt (0 => 101606)


--- trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile-expected.txt	2011-12-01 05:44:30 UTC (rev 101606)
@@ -0,0 +1,13 @@
+DirectoryEntry required arguments test.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitRequestFileSystem(TEMPORARY, 100, successCallback, errorCallback);
+Successfully obtained TEMPORARY FileSystem:file__0:Temporary
+root = fileSystem.root
+PASS root.getFile() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile.html (0 => 101606)


--- trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile.html	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/simple-required-arguments-getfile.html	2011-12-01 05:44:30 UTC (rev 101606)
@@ -0,0 +1,12 @@
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (101605 => 101606)


--- trunk/Source/WebCore/ChangeLog	2011-12-01 05:42:29 UTC (rev 101605)
+++ trunk/Source/WebCore/ChangeLog	2011-12-01 05:44:30 UTC (rev 101606)
@@ -1,3 +1,17 @@
+2011-11-30  Mark Pilgrim  <[email protected]>
+
+        [FileSystem API] DirectoryEntry.getFile path argument is required
+        https://bugs.webkit.org/show_bug.cgi?id=69642
+
+        Reviewed by Adam Barth.
+
+        Test: fast/filesystem/simple-required-arguments-getfile.html
+
+        * bindings/js/JSDirectoryEntryCustom.cpp:
+        (WebCore::JSDirectoryEntry::getFile): check args length and throw TypeError if not enough arguments
+        * bindings/v8/custom/V8DirectoryEntryCustom.cpp:
+        (WebCore::V8DirectoryEntry::getFileCallback): check args length and throw TypeError if not enough arguments
+
 2011-11-30  Joshua Bell  <[email protected]>
 
         IndexedDB: Implement IDBIndex multientry feature

Modified: trunk/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp (101605 => 101606)


--- trunk/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp	2011-12-01 05:42:29 UTC (rev 101605)
+++ trunk/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp	2011-12-01 05:44:30 UTC (rev 101606)
@@ -47,6 +47,9 @@
 
 JSValue JSDirectoryEntry::getFile(ExecState* exec)
 {
+    if (exec->argumentCount() < 1)
+        return throwError(exec, createTypeError(exec, "Not enough arguments"));
+
     DirectoryEntry* imp = static_cast<DirectoryEntry*>(impl());
     const String& path = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0));
     if (exec->hadException())

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp (101605 => 101606)


--- trunk/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp	2011-12-01 05:42:29 UTC (rev 101605)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp	2011-12-01 05:44:30 UTC (rev 101606)
@@ -93,6 +93,10 @@
 {
     INC_STATS("DOM.DirectoryEntry.getFile");
     DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder());
+
+    if (args.Length() < 1)
+        return throwError("Not enough arguments", V8Proxy::TypeError);
+
     STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]);
     if (args.Length() <= 1) {
         imp->getFile(path);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to