Closed Bug 985472 Opened 10 years ago Closed 10 years ago

Adding Cu.cloneInto to the exportHelpers toolset for sandboxes

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31
Tracking Status
firefox30 --- fixed
firefox31 --- fixed
b2g-v1.4 --- fixed
b2g-v2.0 --- fixed

People

(Reporter: gkrizsanits, Assigned: gkrizsanits)

Details

Attachments

(2 files)

I think this would be useful for content-scripts too.
Assignee: nobody → gkrizsanits
Sigh... I still found some leftover...
Attachment #8396285 - Flags: review?(bobbyholley)
Attachment #8396287 - Flags: review?(bobbyholley)
Attachment #8396285 - Flags: review?(bobbyholley) → review+
Comment on attachment 8396287 [details] [diff] [review]
part2: cloneInto for sandbox. v1

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

r=me with the fixes below.

::: js/xpconnect/src/Sandbox.cpp
@@ +1144,5 @@
>          if (options.wantExportHelpers &&
>              (!JS_DefineFunction(cx, sandbox, "exportFunction", ExportFunction, 3, 0) ||
>               !JS_DefineFunction(cx, sandbox, "evalInWindow", EvalInWindow, 2, 0) ||
>               !JS_DefineFunction(cx, sandbox, "createObjectIn", CreateObjectIn, 2, 0) ||
> +             !JS_DefineFunction(cx, sandbox, "cloneInto", CloneInto, 3, 0) ||

I _think_ that nargs should probably be the minimum number of args, not including the options object. At least that's what the others do here, so we might as well be consistent.

::: js/xpconnect/src/XPCComponents.cpp
@@ +3627,5 @@
> +        return false;
> +
> +    RootedObject scope(aCx, &aScope.toObject());
> +    scope = js::CheckedUnwrap(scope);
> +    NS_ENSURE_TRUE(scope, false);

Given that this can fail now, we need an explicit JS_ReportError here, otherwise this will be misinterpretted as OOM.

Please add a test to make sure we throw something that passes /denied|insecure/.test(exn).
Attachment #8396287 - Flags: review?(bobbyholley) → review+
(In reply to Bobby Holley (:bholley) from comment #4)
> I _think_ that nargs should probably be the minimum number of args, not
> including the options object. At least that's what the others do here, so we
> might as well be consistent.

The others are including the options object too if they have any. So either all are consistently good or bad. Where can I double check that?
(In reply to Gabor Krizsanits [:krizsa :gabor] from comment #5)
> The others are including the options object too if they have any. So either
> all are consistently good or bad. Where can I double check that?

Oh you're right. In that case just leave it for now. :-)
Comment on attachment 8396287 [details] [diff] [review]
part2: cloneInto for sandbox. v1

[Approval Request Comment]
Bug caused by (feature/regressing bug #): It's a new feature. Add-on developers have a new set of API to overcome the difficulties that comes with running content-scripts with nsExpandedPrincipal. I was supposed to land this one on ff30 but it seems like it made into 31 only, which I overlooked...

User impact if declined: Add-on developers will have a missing API which make their life harder while migrating to the new world (content-scripts running with nsExpandedPrincipal)

Testing completed (on m-c, etc.): it's on mc and aurora
Risk to taking this patch (and alternatives if risky): it's not risky
String or IDL/UUID changes made by this patch: none
Attachment #8396287 - Flags: approval-mozilla-beta?
Attachment #8396287 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: