Closed Bug 31516 Opened 25 years ago Closed 25 years ago

Unable to create offscreen window OR unmapped XUL window

Categories

(Core :: XUL, defect, P3)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: rhp, Assigned: danm.moz)

References

Details

(Keywords: helpwanted, polish, Whiteboard: [nsbeta2-][nsbeta3+])

I have a need to create a window for rendering mail messages before printing. We need to do this because we display messages as a XUL document which can't be printed directly. I was created an offscreen window, but that is no longer allowed and I don't think I can create an unmapped window from JS? Help! - rhp
Why is it not allowed? Don't we still create an offscreen window on startup, at least on Mac? reassigning to danm, cc saari
Assignee: trudelle → danm
I prevent you from moving a window offscreen. What you really want is a window that isn't visible... which should work just fine for printing, correct?
Correct. An invisible XUL window that I can create from JS would be AWSOME!!!! - rhp
Oh bloody hell, this is probably a JS compliance issue <sigh> Maybe I need to put my sanity checks at a higher level.
There's never been an interface for creating an invisible window from JavaScript. We could conceivably add one (available only from signed or chrome JS, of course), but that feels bad. Of course, allowing placement of windows offscreen is the exact same security issue. Chris, you plugged in coordinate sanity checks at a pretty high level, didn't you? I'm still trying to figure out what to do about this one.
Navigator has always disallowed offscreen windows created from unsigned JS. We need to do the same thing, and consequently allow offscreen windows from signed JS. This implies applying saari's sanity checks to only size and position derived from the local store; that is, as window tag attribute values. Currently, I believe that code is in widget -- at a level too basic. This is all somewhat straightforward, but not critical. Adding "helpwanted" flag.
Status: NEW → ASSIGNED
Keywords: helpwanted
Target Milestone: --- → M17
I still need to move that sanity check code higher. It is slowly creeping higher on my priority list.
This is more critical than you might expect. For printing email messages, I need to render them in a webshell and then print after they are done loading. Well, this webshell needs to be offscreen or not mapped or the user sees it on the desktop. Is there anyway to do either one of these? - rhp
*** Bug 37430 has been marked as a duplicate of this bug. ***
nominating for nsbeta2, since rhp says it is needed for printing.
Keywords: nsbeta2
[nsbeta2-], assuming you can actually print.
Whiteboard: [nsbeta2-]
moving from architecture to browser product
Component: XPFE → XP Toolkit/Widgets
Product: Architecture → Browser
QA Contact: nobody → jrgm
Version: 5.0 → other
Mass-moving all nsbeta2- bugs to M20
Target Milestone: M17 → M20
*** Bug 46324 has been marked as a duplicate of this bug. ***
nominate nsbeta3, polish.
Keywords: nsbeta3, polish
Blocks: 19188
nsbeta3+
Whiteboard: [nsbeta2-] → [nsbeta2-][nsbeta3+]
Target Milestone: M20 → M18
You can move windows offscreen now, and create them there as well. To do it in JS you must have UniversalBrowserWrite privileges. Test case follows: <?xml version="1.0"?> <?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" orient="vertical" autostretch="never"> <script language="JavaScript"> <![CDATA[ var win; function createOnscreen() { win = window.open("http://www.mozilla.org", "_blank", "left=10,top=10"); } function createOffscreen() { var left = screen.width + 10; var top = screen.height + 10; //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); win = window.open("http://www.mozilla.org", "_blank", "left="+left+",top="+top+")"); } function moveOffscreen() { var left = screen.width + 10; var top = screen.height + 10; //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); win.moveTo(left, top); } function moveOnscreen() { win.moveTo(10, 10); } ]]> </script> <button value="Create Window Onscreen" onclick="createOnscreen()"/> <button value="Create Window Offscreen" onclick="createOffscreen()"/> <button value="Move Window Onscreen" onclick="moveOnscreen()"/> <button value="Move Window Offscreen" onclick="moveOffscreen()"/> </window> (Note the commented out lines aren't necessary if this window is loaded from a chrome URL, which automatically has those privileges. (And actually, something's broken in moveTo() at the moment. This sample code doesn't even try to work when loaded from outside chrome.)) I'm not sure this will give you what you wanted. The act of making an offscreen window isn't seamless or pretty -- for one thing the current topmost window is inactivated. (Which you can fix with a focus(), but doubtless the titlebar will flash.) And Enlightenment, for one, disconcertingly switches desktops in the above sample when you execute createOffscreen(). We may have to -- ugh -- add some way to create invisible windows from JS (security protected, of course) if it comes to that. Meanwhile, enjoy your offscreen windows. I'm hoping, rather ineffectually, they'll be enough.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Testing/confirmation note: the above XUL sample doesn't quite work: moveTo fails security checks in our new, more restrictive world. Change the patch to load about:blank (rather than http://www.mozilla.org) and it will work as expected.
You need to log in before you can comment on or make changes to this bug.