Closed Bug 656647 Opened 13 years ago Closed 13 years ago

File constructor should take nsIFile

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla6

People

(Reporter: khuey, Assigned: khuey)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

      No description provided.
Attached patch PatchSplinter Review
Assignee: nobody → khuey
Status: NEW → ASSIGNED
Attachment #531960 - Flags: review?(jonas)
Please declare rv closer to its use, and note that you shadow it in the string case.
Comment on attachment 531960 [details] [diff] [review]
Patch

Review of attachment 531960 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/base/src/nsDOMFile.cpp
@@ +682,5 @@
>  
> +    // If it's not a JSObject, give up
> +    JSObject* obj = JSVAL_TO_OBJECT(aArgv[0]);
> +    if (!obj)
> +      return NS_ERROR_UNEXPECTED;

This doesn't actually work. If you hand JS_TO_OBJECT something that isn't an object it'll assert and perform an invalid cast.

But I believe the JSVAL_IS_PRIMITIVE is enough to ensure that you have an object. So just remove the if-check.

@@ +701,5 @@
> +      return NS_ERROR_XPC_BAD_CONVERT_JS;
> +    }
> +
> +    nsCOMPtr<nsILocalFile> localFile;
> +    nsresult rv = NS_NewLocalFile(xpcomStr,

Remove the 'nsresult' here, as Ms2ger pointed out.

@@ +706,5 @@
> +                                  PR_FALSE, getter_AddRefs(localFile));
> +    NS_ENSURE_SUCCESS(rv, rv);
> +
> +    file = do_QueryInterface(localFile, &rv);
> +    NS_ENSURE_SUCCESS(rv, rv);

Generally speaking, don't use nsresults together with do_QIs, simply nullcheck the result instead.

Though in this case an assert should be enough.
Attachment #531960 - Flags: review?(jonas) → review+
I changed the JSVAL_IS_PRIMITIVE guard to JSVAL_IS_OBJECT.

Other comments addressed.

http://hg.mozilla.org/mozilla-central/rev/190b0bff3507
http://hg.mozilla.org/mozilla-central/rev/0b84815ad48e
Severity: normal → enhancement
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Flags: in-testsuite+
OS: Windows 7 → All
Hardware: x86 → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Version: unspecified → Trunk
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: