Closed Bug 1067574 Opened 10 years ago Closed 10 years ago

Error in content script leads to "Error: Permission denied to access property 'toString'"

Categories

(Core :: XPConnect, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: billm, Unassigned)

References

Details

Attachments

(2 files)

Attached file stack (deleted) —
I'm attaching the stack when the exception is generated. The problem seems to be that nsJSUtils::ReportPendingException is entering some sandbox scope when trying to report the exception. Consequently, the exception is wrapped in a filtering wrapper. Could this be a problem similar to bug 1066340? Does nsFrameScriptExecutor::LoadFrameScriptInternal need to use AutoEntryScript?
Flags: needinfo?(bobbyholley)
Yes, that should fix this bug. Add a patch and flag me for review? Jimb - note that more of the AutoEntryScripts are being added, which will need fixing up in your patch in bug 971673.
Flags: needinfo?(bobbyholley)
Attached patch test-patch (deleted) — Splinter Review
Are you sure? I tried this patch and it doesn't work. Looking more closely, nsJSUtils::ReportPendingException is calling GetScriptContextFromJSContext, which is here: http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMJSUtils.h#16 That code is checking if the JSContext private is an nsISupports. Looking at JS_SetContextPrivate, it looks like we only set that for nsJSContext. And I'm guessing we just use the safe JS context here. So isn't this code bound to fail?
Flags: needinfo?(bobbyholley)
Oh I see. I'd been assuming that the JSObject we'd be using to init the AutoEntryScript was associated with a DOM window, but I guess that's not the case with frame scripts. Given that, the problem is more that nsJSUtils::ReportPendingException is broken. So we need to fix bug 981187 to make progress here. Setting the dep.
Depends on: 981187
Flags: needinfo?(bobbyholley)
Is there any way we can fix this sooner? Bug 981187 sounds like a pretty big task. I'd really like to have a fix for this in the next few days. In https://bugzilla.mozilla.org/show_bug.cgi?id=1048164#c14 the author of Greasemonkey is trying to convert his code to e10s using content scripts and is getting this message. If add-on authors can't convert their code, that's a really serious problem.
The current error reporting machinery is basically broken. There's not a great way to spot fix it. I've been hacking on this, and I think I can get us to where we need to be with a relatively defined amount of work. Give me a day or two.
Depends on: 1070049
No longer depends on: 981187
Depends on: 1070131
No longer depends on: 1070131
I think we might actually be able to spot-fix this after all. Let me investigate.
Oh, looks like there isn't actually a testcase in this bug. Bill, what happens if you take your existing patch and also replace the call to nsJSUtils::ReportPendingException with a direct call to JS_ReportPendingException?
Flags: needinfo?(wmccloskey)
Depends on: 1070842
No longer depends on: 1070049
The original testcase I had for this was something weird, and now I don't have it anymore. I haven't had much luck writing a new testcase.
Flags: needinfo?(wmccloskey)
Ok. Bug 1070842 is also not far from landing anyway.
Bill, can you verify that any issues here are now resolved?
Flags: needinfo?(wmccloskey)
Yeah, let's close this. I'll file something if anything else pops up. Thanks.
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(wmccloskey)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: