Closed Bug 674436 Opened 14 years ago Closed 14 years ago

NS_ENSURE_TRUE(JS_GetProperty(ctx, object, "receiveMessage", &funval) with message manager and sandboxes

Categories

(Core :: IPC, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: Felipe, Assigned: jdm)

References

Details

Attachments

(1 file, 1 obsolete file)

I've been trying to add mm listeners using the Scratchpad, but whenever a message is received, I get the following error and the listener is not called: WARNING: NS_ENSURE_TRUE(JS_GetProperty(ctx, object, "receiveMessage", &funval) && JSVAL_IS_OBJECT(funval) && !JSVAL_IS_NULL(funval)) failed: file c:/moz/mozilla -central/ff-debug/content/base/src/../../../../mozilla/content/base/src/nsFrameMessageManager.cpp, line 436 How to reproduce: ----------------- set the pref devtools.chrome.enabled = true Open Scratchpad (Shift + F4) and set Environment -> Browser type this code in the text area, select all the text and choose Execute -> Run: /***** begin *****/ gBrowser.selectedBrowser.messageManager.addMessageListener("z", function(o) { alert(o.json.q); }); gBrowser.selectedBrowser.messageManager.loadFrameScript('data:,sendAsyncMessage("z", {q: "bar"})', false); /***** end *****/ ########### What causes it is that the Scratchpad runs the code through a sandbox prototyped with the browser window. The actual code boils down to: /*** begin ***/ var mm = gBrowser.selectedBrowser.messageManager; var win = Services.wm.getMostRecentWindow("navigator:browser"); var sand = new Cu.Sandbox(win, {sandboxPrototype:win}); var sandboxscript = "gBrowser.selectedBrowser.messageManager.addMessageListener('z', function(o) { alert(o.json.q);});" Cu.evalInSandbox(sandboxscript, sand); mm.loadFrameScript('data:,sendAsyncMessage("z", {q: "bar"})', false); /*** end ***/
Blocks: 667259
Attachment #548678 - Flags: review?(Olli.Pettay)
Assignee: nobody → josh
Comment on attachment 548678 [details] [diff] [review] Relax message listener restrictions to allow callable proxies. There's nothing wrong with this patch, but I just noticed the other call to JS_IsObjectFunction in the other branch. We should probably nix that too, because I suspect that the current testcase with an object that has receiveMessage would probably fail similarly.
Attachment #548678 - Attachment is obsolete: true
Attachment #548678 - Flags: review?(Olli.Pettay)
Attachment #548880 - Flags: review?(Olli.Pettay) → review+
backed out for android reftest failures
Whiteboard: [inbound]
I think it has nothing to do with those failures, my suspect is that the Android ndk changes are causing them (mozilla central has same failures)
This was backed out from inbound...
Whiteboard: [inbound]
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: