Closed Bug 1107882 Opened 6 years ago Closed 6 years ago

Bug with Function.apply() method inside addons

Categories

(Core :: XPConnect, defect)

35 Branch
x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox34 --- unaffected

People

(Reporter: bugzilla, Unassigned)

References

()

Details

(Keywords: addon-compat, regression, testcase)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:34.0) Gecko/20100101 Firefox/34.0
Build ID: 20141125180439

Steps to reproduce:

Bug reproduced in Addon with background page, I've created testcase: https://github.com/norlin/ff-apply-bug

Description:
Inside background page:
  window.any_function = function(){ console.log(arguments); };

Insode Addon main.js script:
  bg_page_frame.contentWindow.wrappedJSObject.any_function.apply(null, [123, 456]);

Appears only in FF 35 and newer (in FF 34 all fine)


Actual results:

console.log outputs empty arguments


Expected results:

console.log should output arguments list
OS: Mac OS X → All
Version: 35 Branch → Trunk
p.s. Appears on any OS (tested in Mac OS X 10.10, Ubuntu 14 & Windows 7), on any Firefox version since FF 35 (including Nightly build)
Keywords: addon-compat
Summary: Bug with apply method inside addons → Bug with Function.apply() method inside addons
Could you provide a self contained testcase (like .xpi add-on), please, it would be easier to find a regression range.
Flags: needinfo?(bugzilla)
Sure, here it is: https://github.com/norlin/ff-apply-bug/raw/master/test-addon.xpi

I added icons, so now button looks like "?" (questionmark), and when you click it – if it transforms into green 'v' – all ok (no bug), if red 'x' – bug exists.
Flags: needinfo?(bugzilla)
Thanks. I tested in FF35, it's red, but in FF37 (latest Nightly), I'm not able to make it work, clicking on the "?" doesn't do anything ("v" or "x"). Anyway, I'll try to find a regression range as the add-on works in FF35.
Keywords: testcase
regression range:
good=2014-10-03
bad=2014-10-04
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=b85c260821ab&tochange=229801d17f7e
Keywords: regression
Version: Trunk → 35 Branch
Pushlog:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=42614739736d&tochange=58012f4bb5f7

Triggered by Bug 1065185
Blocks: 1065185
Status: UNCONFIRMED → NEW
Component: Untriaged → XPConnect
Ever confirmed: true
Flags: needinfo?(bobbyholley)
Product: Firefox → Core
>  bg_page_frame.contentWindow.wrappedJSObject.any_function.apply(null, [123, 456]);

This is calling a content function but passing it a chrome array.  The ability to do that was turned off in bug 1065185.

The right way to do this is probably more like:

  bg_page_frame.contentWindow.wrappedJSObject.any_function
               .apply(null, new contentWindow.Array(123, 456));
If you have a larger chrome array, you can do Cu.cloneInto(myArray, content)
Flags: needinfo?(bobbyholley)
So, this is by design.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
It looks strange, but thanks, anyway!
You need to log in before you can comment on or make changes to this bug.