Closed Bug 125887 Opened 23 years ago Closed 23 years ago

Window.open yes/true attributes broken by trailing spaces

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: fabricio, Assigned: hwaara)

Details

Attachments

(3 files, 2 obsolete files)

Steps to reproduce: 1- create a html with this window.open: window.open ('http://www.mozilla.org','mozillawindow','width=500 , height=500 , resizable=yes , scrollbars=yes'); 2- open this html Expecting result: the window open with the resize handlers and with the maximize button, just like if you had coded without the spaces between the commas. Actual result: the window open but the resize handlers and the maximize button are disabled.
This way works fine.
This way doesnt work, the resizable=yes is ignored
I first thought that this was a bug with spaces in the features string of window.open. JavaScript: The Definitive Guide says "The features argument is a comma-separated list of features to appear in the window.... The string should not contain any spaces or other whitespace." I don't know if this is also documented in any DOM standard. Netscape 4.x definitely had problems with whitespace in the string. It appears that IE5.0 and 5.5 and Mozilla do support whitespace in the string. For example, this works: javascript:window.open("about:blank","test","width=200 , height=200 , resizable=1") The problem seems to be that "resizable=yes " with a trailing space is not working. If you change it to resizeable=1 or remove the space it works. Perhaps the string parser needs to trim trailling spaces before it tries a comparison? Confirming bug because I can't find a duplicate for it.
Status: UNCONFIRMED → NEW
Ever confirmed: true
A better summary might be "Window.open yes/true attributes broken by trailing spaces". This same problem affects the other attributes, such as toolbar=yes , scrollbars=yes , location=yes , etc. In case I wasn't clear, the workaround for this is to just use 1 for the value instead of yes or to remove the spaces. I suspect this is really DOM0 and not JS engine, so changing component. I confirmed this with 20020208 nightly on Win2K.
Component: JavaScript Engine → DOM Level 0
Setting default owner and QA -
Assignee: rogerl → jst
QA Contact: pschwartau → desale
Confirmed in 2002040303 win2k and changed the sumary for the one suggested in comment #4.
Summary: windows opened by javascript does not respect the resizable attribute if there are space between the commas → Window.open yes/true attributes broken by trailing spaces
Attached patch Patch (obsolete) — Splinter Review
Here's a patch to ignore whitespace in the "features" argument of window.open() and window.openDialog().
CC boris for r=.
CC caillon and sicking too. Seems like jst is busy. Maybe bz can sr= and you guys can r=? Thanks.
Comment on attachment 91964 [details] [diff] [review] Patch Please remove the code in nsWindowWatcher::WinHasOption that skips whitespace and add a debug-only check there that there is no whitespace in the string, with an assertion if there is. With that, sr=bzbarsky
Attachment #91964 - Flags: superreview+
Comment on attachment 91964 [details] [diff] [review] Patch Actually, use StripWhitespace() instead of StripChars()
Comment on attachment 91964 [details] [diff] [review] Patch So I guess this makes sense after talking to Boris, and I agree that we should remove the foo in nsWindowWatcher::WinHasOption() but to me it seems wrong to move the check out of the window watcher and into its callers. I'd rather you do StripWhitespace() somewhere either in nsWindowWatcher::OpenWindow() or nsWindowWatcher::OpenWindowJS()...
Attached patch Patch v2 (obsolete) — Splinter Review
Better patch, addressing caillon's and bzbarsky's suggestions.
Attachment #91964 - Attachment is obsolete: true
Comment on attachment 92061 [details] [diff] [review] Patch v2 >+#include "nsReadableUtils.h" Don't you actually want nsString.h? And only in debug builds? >+#if DEBUG #ifdef >+ nsCString options(aOptions); nsCAutoString
Attached patch Patch v3Splinter Review
Attachment #92061 - Attachment is obsolete: true
Comment on attachment 92064 [details] [diff] [review] Patch v3 sr=bzbarsky
Attachment #92064 - Flags: superreview+
Comment on attachment 92064 [details] [diff] [review] Patch v3 r=jkeiser
Attachment #92064 - Flags: review+
Comment on attachment 92064 [details] [diff] [review] Patch v3 a=brendan@mozilla.org for trunk checkin -- seems safe and right. /be
Attachment #92064 - Flags: approval+
->moi
Assignee: jst → hwaara
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
>+ NS_ASSERTION(options.FindCharInSet(" \n\r\t") == kNotFound, >+ "There should be no whitespace in this string!"); Nice indentation. ^^^^ r=caillon with that fixed. <yawn>
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: