The javascript for select a user and add it into a group of the webmin package doesn't work




DOM: Core & HTML
15 years ago
15 years ago


(Reporter: fabrizio morbini, Assigned: jst)



Firefox Tracking Flags

(Not tracked)



(2 attachments, 2 obsolete attachments)



15 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130

The javascript that pick up a user from a list and put it into the input box of
the father windows (the window that open the user select subwindow) doesn't work.
This can be test with a recent Webmin installation. The problem DOES NOT exist
into Mozilla 1.0.1 but only into the news Mozilla releases (1.2.1 and 1.3.x).

Reproducible: Always

Steps to Reproduce:
1.connect to https://some_webmin_server:10000/ the module for user and group management a group and try to add a user to it

Actual Results:  
the user doesn't by added and a javascript error is putted into the javascript

Expected Results:  
the user must be added

Comment 1

15 years ago
Browser, not engine; reassigning to Browser-General until we can
get further information. 


1. You mentioned an error in the JavaScript Console. Can you post 
   the exact message here? Thanks -

2. I notice your build ID is from November 2002. Does this problem
   still occur with a February 2003 build?

3. If so, try launching Mozilla from a console window like this:
          [(path to Mozilla)]./mozilla -profilemanager

   When the Profile Manager comes up, click on "Create Profile".
   Do you still see the bug when running under a new profile?

4. If so, would it be possible to attach a reduced testcase to
   this bug via the "Create a New Attachment" link above? 

   You may have to attach two: one for the parent window and 
   one for the child. Each one should be as small as possible
   to show the bug (i.e. no extraneous HTML or JavaScript)

Thanks -
Assignee: rogerl → asa
Component: JavaScript Engine → Browser-General
QA Contact: pschwartau → asa

Comment 2

15 years ago
Created attachment 114229 [details]
This is the page that call my_user_chooser.cgi

This is a summary of the edit_group.cgi of webmin (module useradmin)
The problem is whit the my_user_chooser.cgi of the useradmin module that can't
set the value of top.ifield.

N.B.: all run's fine in Mozilla 1.0.2 (Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.0.2) Gecko/20021216) the problem is on newer browser: Mozilla 1.2.1
(Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130) and also
Mozilla 1.3.x (the alpha release)

I attach also the my_user_chooser.cgi...

Comment 3

15 years ago
Created attachment 114231 [details]
my_user_chooser.cgi of the webmin package

This is the user chooser... pressing the OK button the windows is closed and
the user choosed are added into the members textarea of the edit_group windows.

Into newer Mozilla this doesn't work: so the my:user_chooser window doesn't
close when I press the OK button and the user aren't added into the members
textarea of the edit_group windows.

Comment 4

15 years ago
The errors happens also with a fresh profile

Comment 5

15 years ago
The bug is present also in the latest Mozilla's build: Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.3b) Gecko/20030210


15 years ago
Attachment #114231 - Attachment mime type: application/octet-stream → text/html


15 years ago
Attachment #114231 - Attachment mime type: text/html → application/octet-stream

Comment 6

15 years ago
Fabrizio: thank you for providing these files. You mentioned getting
errors in the JavaScript Console. Could you paste the exact messages
here; that will help a lot -

When I try the files you attached, what order should I follow?
I am opening edit_group.cgi.html first, and then clicking on the
button labelled with "...". Is that the right thing to do?

I am getting this error in the JavaScript Console:

Error: syntax error
Source Code:
ifield = document.forms[0].members; chooser =

I checked the source, and that line reads:

chooser ="my_user_chooser.cgi?multi=1&user=" + escape(ifield.value), etc.

So after loading edit_group.cgi.html, I tried this javascript:URL:


That produced the following error in the JavaScript Console:

Error: [Exception... "Component returned failure code: 0x80004005 
(NS_ERROR_FAILURE) [nsIURI.hostPort]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  
location: "JS frame :: chrome://navigator/content/nsBrowserStatusHandler.js :: 
anonymous :: line 350"  data: no]
Source File: chrome://navigator/content/nsBrowserStatusHandler.js
Line: 350

But we'll need to see the error messages you are getting to make
progress; thanks -

Comment 7

15 years ago
Created attachment 114331 [details]
New test case (and better, the first isn't a good example) part 1 of 2

This is the part 1 of a new test case.

Open this file and press the button "..."
Attachment #114229 - Attachment is obsolete: true
Attachment #114231 - Attachment is obsolete: true

Comment 8

15 years ago
Created attachment 114332 [details]
part 2 of the new test case

when you press the ... button of the part_1 then this file is opened. Some unix
group is displaied and when you click on one of this group the window is closed
and the group choosed is added to the input field "gid" of the part_1 file.

This example run on Mozilla 1.0.2 but if you try this on a recent Mozilla the
error is:
Error: ifield is not defined
Source File: file:///home/io/my_group_chooser.cgi.html Line: 8

Comment 9

15 years ago
Fabrizio: thank you, the new testcase is excellent!

Confirming what Fabrizio has reported, following the steps
given in Comment #8. The key function in the child window is

function select(f)
  ifield.value = f;
  return false;

This is trying to set the value of a JavaScript variable |ifield|
in the child window. This variable is declared in the onClick handler
of the button in the parent page that brings up the child window
(named "chooser") to begin with:

<input type="button" onclick="ifield = document.forms[0].gid;
chooser ='my_group_chooser.cgi.html', 'chooser', 
chooser.ifield = ifield" value="..."></td>

Notice the object reference created between parent and child:

                chooser.ifield = ifield

In IE6, and indeed in Mozilla 1.1a+, this works. But in 1.1b and
afterwards, it doesn't. We get the error Fabrizio has reported in
Comment #8 above.

I have some old builds on my machine:

Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1a+) Gecko/20020701  WORKS
Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1b)  Gecko/20020805  DOESN'T WORK

I used the JavaScript Debugger in each build, setting a breakpoint 
in the select() function:

---- Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1a+) Gecko/20020701 ----
$[3] = [string] "chooser"
'ifield' in this
$[4] = [boolean] true
$[5] = [HTMLInputElement] [class: HTMLInputElement] {0}

---- Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1b)  Gecko/20020805 ----
$[0] = [string] "chooser"
0001: 'ifield' in this
$[1] = [boolean] false
0001: ifield
Caught exception: ``ReferenceError: ifield is not defined''

This shows that in the newer versions of Mozilla, the parent window
is not able to create a global variable |ifield| in the child window.

Reassigning to the DOM folks. I remember work was done on this,
and I will try to find the bug numbers.

In the meantime, a workaround is to modify the select() function
so that it uses |opener| syntax:

function select(f)
  opener.ifield.value = f;
  return false;

The addition of |opener| changes the reference to that of the parent
window's |ifield| variable, allowing the child window to set it directly.
Assignee: asa → jst
Component: Browser-General → DOM Level 0
Ever confirmed: true
QA Contact: asa → ashishbhatt

Comment 10

15 years ago
Wow, this is a duplicate of a bug filed on 2002-07-25:
bug 159424, "Objects cannot be passed between windows.
             Scope for objects seems to be changed."

Also see bug 165861, marked as a duplicate:
"Setting a child window property from opener window
not reflected in child window"

I will dupe this bug, too. Fabrizio, you'll be cc'ed on bug 159424
so you can follow progress on this issue -

*** This bug has been marked as a duplicate of 159424 ***
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.