Closed Bug 825836 Opened 12 years ago Closed 12 years ago

Support Blob in JS components

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21
blocking-b2g leo+
Tracking Status
firefox20 --- wontfix
firefox21 --- fixed
b2g18 --- fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- wontfix

People

(Reporter: ctai, Assigned: ctai)

References

Details

(Keywords: dev-doc-needed)

Attachments

(2 files, 2 obsolete files)

Hook Blob constructor in JSComponentsLoader, then we can use blob in JS component like MmsService.js.
Assignee: nobody → ctai
Attachment #697797 - Flags: feedback?(vyang)
Comment on attachment 697797 [details] [diff] [review]
Support Blob in JS component

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

r=me with the below fixed.

Thanks for writing this!

::: js/xpconnect/loader/mozJSComponentLoader.cpp
@@ +288,5 @@
> +    nsresult rv;
> +
> +    if (!argc) {
> +        XPCThrower::Throw(NS_ERROR_UNEXPECTED, cx);
> +        return false;

I don't think you need to add this. The call to Initialize will ensure that we throw appropriately if no arguments are passed.

::: js/xpconnect/tests/unit/component-blob.js
@@ +30,5 @@
> +    var f2 = new Blob([testContent], {"type" : "text/xml"});
> +
> +    // do some tests
> +    do_check_true(f1 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");
> +    do_check_true(f2 instanceof Ci.nsIDOMBlob, "Should be a DOM Blob");

Please also add

do_check_true(!(f1 instanceof Ci.nsIDOMFile), "Should not be a DOM File");
do_check_true(!(f2 instanceof Ci.nsIDOMFile), "Should not be a DOM File");
Attachment #697797 - Flags: review+
Attached patch Support Blob in JS component (obsolete) — Splinter Review
Attachment #697797 - Attachment is obsolete: true
Attachment #697797 - Flags: feedback?(vyang)
I try to remove below codes, but it will cause do_check_true(threw, "No ctor arguments should throw"); fail.
So I don't remove below codes(!argc check).

::: js/xpconnect/loader/mozJSComponentLoader.cpp
@@ +288,5 @@
> +    nsresult rv;
> +
> +    if (!argc) {
> +        XPCThrower::Throw(NS_ERROR_UNEXPECTED, cx);
> +        return false;
Status: NEW → ASSIGNED
Ah, indeed, per spec |new Blob()| is totally valid. It should *not* throw.

So change the test to check that |new Blob()| doesn't throw and that it returns a blob with .length set to 0.

See spec here: http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
Thanks for reviewing.
You are right. I change the test. 
And make sure the type is empty string.
    do_check_true(f3.type == "", "Wrong type");
Attachment #697815 - Attachment is obsolete: true
Component: DOM: Device Interfaces → XPCOM
Keywords: dev-doc-needed
OS: Gonk (Firefox OS) → All
Hardware: ARM → All
Would you mind filing a followup to remove this and replace with an initialization of the WebIDL Blob constructor in components once Blob is converted to WebIDL?
I file a bug 827723 for WebIDL Blob constructor in JS components.
https://hg.mozilla.org/mozilla-central/rev/924d2be32b13
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
For mms merge to b2g18.
blocking-b2g: --- → leo?
blocking-b2g: leo? → leo+
The entire set of clian's pushes was backed out for multiple reasons.
https://tbpl.mozilla.org/?tree=Mozilla-B2g18&rev=a0b06192f882

1.) The tree rules are clear that you are not to land on top of bustage. At the time you pushed, both B2G Mn and B2G xpcshell had bustage from prior commits that hadn't been backed out yet.
2.) The tree rules are also clear that you are to watch your pushes for any bustage and handle them accordingly. mozilla-inbound is the ONLY tree where this rule does not apply.
3.) Even after the earlier bustage was backed out, something in one of your many pushes was causing further B2G Mn failures as shown in the log below.
https://tbpl.mozilla.org/php/getParsedLog.php?id=20424173&tree=Mozilla-B2g18
4.) This isn't cause for backout by itself, but it is also strongly preferred to not push each commit individually as our build and testing resources are limited and doing so stretches them even thinner. Please limit your number of pushes as much as possible unless you have good reason for keeping them separate.
Flags: in-moztrap-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: