Closed Bug 270098 Opened 20 years ago Closed 20 years ago

In <navigator.js>, "Error: browser.popupUrls has no properties"; and fix the "separator" behaviour.

Categories

(SeaMonkey :: UI Design, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.8alpha6

People

(Reporter: sgautherie, Assigned: iannbugzilla)

References

()

Details

Attachments

(1 file, 4 obsolete files)

[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8a4) Gecko/20040927] (release) (W98SE)

{{
Error: browser.popupUrls has no properties
Source File: chrome://navigator/content/navigator.js
Line: 2318
}}

Steps:
1. Open 'Tools > Popup Manager > (right sub-menu)' !
Code is
{{{
2332 function createShowPopupsMenu(parent) {
2333   while (parent.lastChild && parent.lastChild.hasAttribute("uri"))
2334     parent.removeChild(parent.lastChild);
2335 
2336   var browser = getBrowser().selectedBrowser;      
2337 
2338   for (var i = 0; i < browser.popupUrls.length; i++) {   // <-- Was line 2318 !
2339     var menuitem = document.createElement("menuitem");
2340     menuitem.setAttribute("label",
gNavigatorBundle.getFormattedString('popupMenuShow', [browser.popupUrls[i].spec]));
2341     menuitem.setAttribute("uri", browser.popupUrls[i].spec);
2342     menuitem.setAttribute("features", browser.popupFeatures[i]);
2343     parent.appendChild(menuitem);
2344   }
2345 
2346   return true;
2347 }
}}}
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8a5) Gecko/20041116] (nightly) (W98SE)

Same:
{{
Error: browser.popupUrls has no properties
Source File: chrome://navigator/content/navigator.js
Line: 2338
}}
I don't understand the steps to reproduce. As far as I can see that code is only
referenced by the popup icon's context menu which is therefore only available
after a popup has been blocked and you have some urls to unblock.
(In reply to comment #3)
> I don't understand the steps to reproduce. As far as I can see that code is only

Let's try and reproduce it first...

0. From Browser
1. Press (and release): Alt, then T, then o
2. Go to and see the JS.C. !
Product: Browser → Seamonkey
(In reply to comment #4)
I didn't spot the call to popupBlockerMenuShowing in cookieNavigatorOverlay :-/
(In reply to comment #6)
> I didn't spot the call to popupBlockerMenuShowing in cookieNavigatorOverlay :-/

Then what do we need ?
{{
2339   var browser = getBrowser().selectedBrowser;      
2340   if (!browser.popupUrls)  return true;  // <-- To add this code line there !?
2341   for (var i = 0; i < browser.popupUrls.length; i++) {
}}
Component: General → XP Apps: GUI Features
Depends on: 198846
Flags: blocking1.8a6?
OS: Windows 98 → All
Hardware: PC → All
Target Milestone: --- → mozilla1.8alpha6
Attached file this works for me (obsolete) —
I don't have CVS at the moment so I can't add a cvs diff -u patch but it works,
including a small fix for the separator (not hidden when it should).
I'm not sure that does the right thing either.

We have a popup icon which is currently correctly shown and hidden. One approach
would be to use a broadcaster to show and hide both the icon and the separator
simultaneously. However the submenu still needs to be updated correctly (it
should be cleared when the icon is hidden) so you always need to call
createShowPopupsMenu and that needs to check that the popupDomain is set.
(In reply to comment #9)
> I'm not sure that does the right thing either.

That might be, but it works;)

> We have a popup icon which is currently correctly shown and hidden. One approach
> would be to use a broadcaster to show and hide both the icon and the separator

I don't think a broadcaster is not the right this either, because of
"privacy.popups.statusbar_icon_enabled" or do you want to wack that pref also?

> simultaneously. However the submenu still needs to be updated correctly (it
> should be cleared when the icon is hidden) so you always need to call
> createShowPopupsMenu and that needs to check that the popupDomain is set.

popupDomain is |null| so function createShowPopupsMenu will always be called, right?
"I don't think a broadcaster is not the right this either,"

Yeah, I want that strong hot coffee now, but make that:

"I don't think that we should use a broadcaster because of 
"privacy.popups.statusbar_icon_enabled", or do you want to wack this pref?



My point about the popupDomain is that a new tab won't have a popupDomain, will
it? In which case the popup manager menu will still show the old blocked list.
(In reply to comment #12)
> My point about the popupDomain is that a new tab won't have a popupDomain, will
> it? In which case the popup manager menu will still show the old blocked list.

All new tabs (browsers) have a popupDomain set to null. Only the first tab
(browser) has no popupDomain, but only when you startup with about:blank. All
other pages i.e. your home page triggers the onLocationChange in
nsBrowserStatusHandler.js so popupDomain gets set to null.
OK, so you default to a blank page; you then open a bookmark in a new tab; that
page tries to open a popup; you look at the popups menu; you switch to the blank
tab and find that the popups menu still has the old popup...

I suppose this would work if you ensured that the appropriate properties were
defined on all browsers even the initial blank browser. However in that case it
might be more reasonable to clear popupUrls to [] instead of null.
This patch adds a check for popupUrls being either null or an empty array
before trying to enter createShowPopupsMenu. The alternative is to do these
checks within createShowPopupsMenu and return false for these conditions.
Assignee: general → bugzilla
Attachment #169779 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #169959 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 169959 [details] [diff] [review]
Checks for null and empty array patch v0.1

When you change to a tab with no popups you still need to remove the old
menuitems as well as hiding the separator.
Attachment #169959 - Flags: review?(neil.parkwaycc.co.uk) → review-
Changes since v0.1 as per Neil's suggestion
* Moved null and empty array check into createShowPopupsMenu function
* Check is just after old menuitems are removed
* Check returns false so the separator is hidden
Attachment #169959 - Attachment is obsolete: true
Attachment #170022 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #170022 - Attachment description: separator and null/empty array check v0.1 → separator and null/empty array check v0.1a
Comment on attachment 170022 [details] [diff] [review]
separator and null/empty array check v0.1a

Although this works I'd still prefer a solution that ensures popupDomain always
exists, thus simplifying the code to if (separator) separator.hidden =
!createShowPopupsMenu(parent);
Attachment #170022 - Flags: review?(neil.parkwaycc.co.uk) → review+
"Although this works I'd still prefer a solution that ensures popupDomain always
exists"

I fully agree. Why not use something simple like this:

+  var hideSeparator = !createShowPopupsMenu(parent);
+
+  if (separator)
+    separator.hidden = hideSeparator;

and fix lines 333+ in nsBrowserStatusHandler.js (replacing null with [])
Except that as per your own comment 13 that won't work for a new blank window.
Attachment #170022 - Attachment is obsolete: true
Attachment #170047 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 170047 [details] [diff] [review]
popupDomain and separator patch v0.1b

Did as HJ suggested and added code to Startup which sets popupDomain for blank
pages
Comment on attachment 170047 [details] [diff] [review]
popupDomain and separator patch v0.1b

r+ from me because this looks fine. Thanks.

Neil, can you sr+ this?
Attachment #170047 - Flags: superreview?(neil.parkwaycc.co.uk)
Attachment #170047 - Flags: review?(neil.parkwaycc.co.uk)
Attachment #170047 - Flags: review?(bugs4hj)
Attachment #170047 - Flags: review?(bugs4hj) → review+
Comment on attachment 170047 [details] [diff] [review]
popupDomain and separator patch v0.1b

>+  if  (!browser.popupUrls || browser.popupUrls.length == 0)

Is |!browser.popupUrls| needed, since you initialize it to |[]| ?
Comment on attachment 170047 [details] [diff] [review]
popupDomain and separator patch v0.1b

I just noticed you have to reset popupFeatures to [] because onPopupBlocked
only checks if popupUrls is null (you can then remove that check too). I also
think you might be safer always setting the properties in Startup in case the
page takes time to load. And please fix Serge's nit too.
Attachment #170047 - Flags: superreview?(neil.parkwaycc.co.uk) → superreview-
Suggested changes made
Attachment #170047 - Attachment is obsolete: true
Attachment #170058 - Flags: superreview?(neil.parkwaycc.co.uk)
Attachment #170058 - Flags: review?(bugs4hj)
Comment on attachment 170058 [details] [diff] [review]
popupDomain/Urls/Features and Separator patch v0.1c

This one should make everyone happy I guess, r+ HJ
Attachment #170058 - Flags: review?(bugs4hj) → review+
Do we really need all this code to initialize the array? What is wrong with a
simple null-check?
And is there currently (without any of those patches) an actual problem, or is
it only an error on the console?
Attachment #170058 - Flags: superreview?(neil.parkwaycc.co.uk) → superreview+
Comment on attachment 170058 [details] [diff] [review]
popupDomain/Urls/Features and Separator patch v0.1c

Checking in navigator.js;
/cvsroot/mozilla/xpfe/browser/resources/content/navigator.js,v	<-- 
navigator.js
new revision: 1.556; previous revision: 1.555
done
Checking in nsBrowserStatusHandler.js;
/cvsroot/mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js,v 
<--  nsBrowserStatusHandler.js
new revision: 1.62; previous revision: 1.61
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Can somebody answer my question in comment 28? (because i really don't like this
huge amount of code for just a nullcheck)
(In reply to comment #30)
> Can somebody answer my question in comment 28? (because i really don't like this
> huge amount of code for just a nullcheck)

What huge amount of code are ou talking about? Please check the patch and count
the plus/minus lines, thank you.
The patch could have just added a null check and not touch the other areas. A
one line fix. (plus a few lines to fix the seperator issue, which stricly isn't
this bug)
(In reply to comment #28)
> Do we really need all this code to initialize the array? What is wrong with a
> simple null-check?

The fix(es) seems fine to me as it is, dealing with true and potential issues;
while I understand your concern about a minimal patch,
I wonder what drawback(s) you find in the resulting code ?

> And is there currently (without any of those patches) an actual problem, or is
> it only an error on the console?

As the reporter, I found the error,
but I did not try and see if it had any associated issue (I'm not truely using
this feature);
then I'll leave it to the (super-)reviewers, and other commenters, to discuss
this matter with you.
Flags: blocking1.8a6?
Summary: In <navigator.js>, "Error: browser.popupUrls has no properties" → In <navigator.js>, "Error: browser.popupUrls has no properties"; and fix the "separator" behaviour.
Component: XP Apps: GUI Features → UI Design
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: