Closed Bug 1246077 Opened 8 years ago Closed 4 years ago

aProgress.DOMWindow causes an error "unsafe CPOW usage forbidden"

Categories

(Developer Documentation Graveyard :: Mozilla Platform, defect, P5)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: alice0775, Unassigned)

References

Details

(Keywords: addon-compat, regression, Whiteboard: dom-triaged)

Attachments

(1 file)

2.98 KB, application/x-javascript
Details
Attached file scratchpad.js
Build Identifier:
https://hg.mozilla.org/mozilla-central/rev/03297f8c28a08d2b39a252c7b368524d9e69da69
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0 ID:20160204030229

Steps to Reproduce:
1. Open web pages in several tabs
2. Set devtools.chrome.enabled = true
3. Open ScratchPad and enable browser privilege
4. Paste the sample code
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgressListener#Example
   And Insert the following code after |onLocationChange: function(aProgress, aRequest, aURI, aFlag) {|
  Cu.reportError(aProgress.DOMWindow);

  OR load attachment.

5. Run
6. Switches tabs
   ---- observe Browser Console   

Actual Results:
error "unsafe CPOW usage forbidden

Expected Results:
aProgress.DOMWindow should return the [object Window] which triggered the change
Flags: needinfo?(mconley)
Why should this work? Isn't this exactly the kind of this we explicitly turned off?
Component: XPCOM → DOM: Content Processes
Flags: needinfo?(alice0775)
So, the sample code describes a wrong code, MDN...
Flags: needinfo?(alice0775)
Yes - I think the bug here is that the MDN article needs to be updated.

Hey Will, is the DOMWindow on nsIWebProgressListener a pattern that you've altered before in our documentation? If not, maybe we can pull over and talk with billm to figure out what the alternative is for this use case (I'll put good money on it being a frame script).
Flags: needinfo?(mconley) → needinfo?(wbamberg)
Whiteboard: dom-triaged
ni'ing myself for creating a new example for this documentation.
Flags: needinfo?(mconley)
There's a bit on this here: https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts#nsIWebProgressListener. This used to be shimmed, and I guess the shim described here is one of the ones that was recently switched off.

Having just talked with mconley about this, we think this is what we should do:

1) Update https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgress and https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebProgressListener to mention that these interfaces, when using remote browsers, should be used in a frame script in the content process. There is a "compatibility layer" that makes nsIWebProgress available to the parent for remote browsers, but it has no direct access to the DOMWindow.

2) Update the example to use frame scripts.

mconley has generously agreed to help with the example.

So I'll convert this into a docs bug, to cover that work.

We also need to update some of the other docs (notably https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts, which talks a lot about shims) to say that these shims are no longer available for browser code, only for add-ons. But let's do that in bug 1233497.
Flags: needinfo?(wbamberg)
Component: DOM: Content Processes → Mozilla Platform
Product: Core → Developer Documentation
Version: 47 Branch → unspecified
See Also: → 1246349
See Also: → 1118880

The MDN team is no longer actively working on Mozilla Platform docs. Volunteer contributions are welcome.

Priority: -- → P5
MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: