window opened with window.open does not have SpecialPowers object

REOPENED
Unassigned

Status

defect
REOPENED
8 years ago
5 years ago

People

(Reporter: arno, Unassigned)

Tracking

(Blocks 2 bugs)

unspecified
mozilla9
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 3 obsolete attachments)

Hi, when a mochitest opens a window with window.open, newly opened window does not have SpecialPowers object.
So, many tests in docshell/test/chrome prints an exception about that (but for some reason, do not appear to fail; or at least, fail silently). Here are some extracts from a random log on try server:

2954 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug293235.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js:12
2966 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug298622.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochitests/content/chrome/docshell/test/chrome/docshell_helpers.js:403
2969 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug301397.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochitests/content/chrome/docshell/test/chrome/docshell_helpers.js:403
2993 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug321671.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochitests/content/chrome/docshell/test/chrome/docshell_helpers.js:403
3574 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug396649.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochitests/content/chrome/docshell/test/chrome/docshell_helpers.js:403
3614 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug582176.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochitests/content/chrome/docshell/test/chrome/docshell_helpers.js:403
3667 INFO TEST-INFO | chrome://mochitests/content/chrome/docshell/test/chrome/test_bug89419.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js:12
10838 INFO TEST-INFO | chrome://mochitests/content/chrome/layout/generic/test/test_bug514732-2.xul | [SimpleTest/SimpleTest.js, window.onerror] An error occurred: SpecialPowers is not defined at chrome://mochikit/content/tests/SimpleTest/docshell_helpers.js:403
I'm quite sure Joel hit this, but I don't know that we ever figured out why.
I'm looking in to this.
Assignee: nobody → josh
Depends on: 671101
I tested your patch, and it fails on my machine
TEST_PATH=docshell/test/chrome/ make -C $OBJDIR mochitest-chrome
opens http://mochi.test:8888/redirect.html and fails with following error:
Error: docshell is not defined
Source File: chrome://specialpowers/content/specialpowers.js
Line: 445

By the way, would this solution ever work ?
In those docshell tests, top level window is used for testing. Ie: they have no browser or iframe. So, will this._messageManager.loadFrameScript reach them ?
You're right that this patch doesn't appear to help with your situation. I'm going to need to talk with Joel about what you're seeing, because all of the existing SpecialPowers-in-mochitest-chrome goop doesn't appear to help there. And you are absolutely right about this patch being broken - it just happened to work because the error thrown caused the early return to be skipped.
Attachment #556010 - Flags: review?(ted.mielczarek)
Attachment #555175 - Attachment is obsolete: true
Attachment #555175 - Flags: review?(ted.mielczarek)
Just an extra change to ensure we don't leak docshells.
Attachment #556011 - Flags: review?(ted.mielczarek)
Attachment #556010 - Attachment is obsolete: true
Attachment #556010 - Flags: review?(ted.mielczarek)
Blocks: 681397
While this patch is almost correct (I inversed the shouldAttach condition D:), I think we might be able to get away with just removing the shouldAttach logic entirely. I did a try run of a patch that did just that and it came back super green. http://tbpl.allizom.org/?tree=Try&usebuildbot=1&rev=84710cbbd23a
Duplicate of this bug: 684690
Blocks: 652494
If that works let's just do that. I don't really know why that logic is there in the first place.
Attachment #556011 - Attachment is obsolete: true
Attachment #556011 - Flags: review?(ted.mielczarek)
Comment on attachment 558470 [details] [diff] [review]
Remove about: exclusion from SpecialPowers creation.

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

I don't really know why this was here in the first place. I think it got copy/pasted from something else.
Attachment #558470 - Flags: review?(ted.mielczarek) → review+
http://hg.mozilla.org/mozilla-central/rev/e7525561c309
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
It looks the patch didn't fix the issue: window opened in docshell tests throw an exception when trying to access SpecialPowers.

For example, this log is the one associated with inbound commit for this patch. Errors reported in comment 1 are still present.

http://tinderbox.mozilla.org/showlog.cgi?log=Mozilla-Inbound/1315423077.1315424363.14717.gz
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
When running |TEST_PATH=docshell/test/chrome/test_bug293235.xul make -C objdir mochitest-chrome|, I have discovered strange things. Printing out the location.href of the window to which SpecialPowers is being attached shows the same URL as the failing window in WindowSnapshot.js. However, logging the actual objects shows this:

[object Window @ 0x1268be280 (native @ 0x1268bfae8)], when SpecialPowers is attaching to the window
[object ChromeWindow @ 0x1268df430 (native @ 0x1268de558)], when snapshotWindow is being called.

I have no idea what's going on!
(In reply to Josh Matthews [:jdm] from comment #15)
> When running |TEST_PATH=docshell/test/chrome/test_bug293235.xul make -C
> objdir mochitest-chrome|, I have discovered strange things. Printing out the
> location.href of the window to which SpecialPowers is being attached shows
> the same URL as the failing window in WindowSnapshot.js. 

I don't get the same result.
SpecialPowers is attached to:
http://mochi.test:8888/chrome/docshell/test/chrome/bug293235.html
and window.location is, in snapshotWindow execution:
chrome://mochitests/content/chrome/docshell/test/chrome/bug293235_window.xul

If I understand correctly, the underlying problem is:
call to 
this._messageManager.loadFrameScript(CHILD_SCRIPT);
(in SpecialPowersObserver.js), will execute CHILD_SCRIPT in the context of any document loaded inside a <browser/>. But bug293235_window.xul is not within a browser. It's a top level window. I think that's the reason why SpecialPowers is not attached to bug293235_window.xul.
This is only the case with mochitest-chrome, right? I don't see this problem with mochitest-plain, except on b2g, I just filed bug 918842 for that.
Not actively looking into this.
Assignee: josh → nobody
Arno, are you still seeing this?
You need to log in before you can comment on or make changes to this bug.