Closed Bug 100703 Opened 23 years ago Closed 23 years ago

Web-Site not working (problem with js dom indexing)

Categories

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

x86
Windows NT
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla0.9.8

People

(Reporter: frank.schaefer, Assigned: jst)

References

()

Details

(Keywords: testcase, Whiteboard: [HAVE FIX])

Attachments

(3 files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20010913
BuildID:    2001091303

in the site http://www.mlp.de - when clicking on one of the hyperlinks - there
is no forwarding to the approriate subsites - compared to Netscape 4.7 and M$IE
5.x where it all works fine.

I don't know if is a problem of Mozilla or the web-site, but it is the last
remaining website i'm using frequently i have to use other browsers for

Reproducible: Always
Steps to Reproduce:
1.www.mlp.de
2.clicking on one of the hyperlinks
3. no forwarding

Actual Results:  nothing

Expected Results:  should forward to a subsite (compare to Nertscape 4.7x or msIE)
Confirming that the hyperlinks aren't working (build 2001091903, Win98) but does
work in NS 4.x.  Since they use Javascript, maybe a JS problem?
no, the JS seems to be working fine... at a guess, this is a cookie problem.
Assignee: pchen → morse
Component: XP Apps → Cookies
QA Contact: sairuh → tever
Confirming.  But I don't think it's a cookie problem.  I'll investigate further 
and determine what component is at fault.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Target Milestone: --- → mozilla0.9.5
Sorry, Boris, you were wrong -- the JS is not working fine.

After carefully investigating it and even creating a local copy of the website, 
I was able to determine that it is a javascript dom problem.

I'm attaching the local copy of the website.  It consists of two files: bug.htm 
which is the site itself and XPFramework.js.  Note that I've added some "dump" 
statements to the JS file so I could see what is going on.

The values that are supposed to be dumped out are as follows:

   formObj.elements[0]:  name="portal"     value="7"
   formObj.elements[1]:  name="~login"     value="DEF_STD"
   formObj.elements[2]:  name="~template"  value="start"
   formObj.elements[3]:  name="baseurl"    value="http://...."
   formObj.elements[4]:  name="language"   value="DE"

But instead I am getting:

   formObj.elements[0]:  name="portal"     value="7"
   formObj.elements[1]:  name="~template"  value="DEF_STD"
   formObj.elements[2]:  name="baseurl"    value="http://...."
   formObj.elements[3]:  name="language"   value="DE"
   formObj.elements[4]:  name="~login"     value=""

What's happening is that the numeric indexing of the elements in the form are 
not correct.  The form has "~login" as the second element (see the attached html 
file) but it is being indexed as the last one.  And the javascript at the site 
is trying to set a value for it with:

   formObj.elements[1].value=roleName[portalIndex];

so it is setting "~template" instead of "~login".  If you change the index of 
[1] to [4] in the local copy of the website(see the attached js file), 
everything works fine.
Reassigning to javascript
Assignee: morse → rogerl
Status: ASSIGNED → NEW
Component: Cookies → Javascript Engine
QA Contact: tever → pschwartau
Summary: Web-Site not working → Web-Site not working (problem with js dom indexing)
Just to clarify.  When I said:

   If you change the index of [1] to [4] in the local copy of the website

I was referring to the index in the statement shown immediately before that 
sentence.
Over to DOM0.  ccing jkeiser because he's working on this sorta stuff... :)
Assignee: rogerl → jst
Component: Javascript Engine → DOM Level 0
QA Contact: pschwartau → desale
It would help a *lot* in debugging this if you could reduce the testcase. 
Basically what this means is, isolate the problem down to just the
essentials--in this case, I think it would be:
- a simple <SCRIPT>function openPortal() ...</SCRIPT> at the top (external js is
OK if you must, but try and make the URL to the JS file be the bugzilla
attachment so that we can test straight from the bug).
- the form
- one clickable HREF
- possibly the dump statement

This is my guess based on discussion.

On another note, I can tell that clicking on these hyperlinks goes back to the
main page, but I don't see any kind of dump happening here ... ?

Thanks!
Sure, go ahead and reduce the test case.  It's your bug now so you can do 
whatever you want with it.

Here's some more information.  The indexing gets destroyed if you rename one of 
the elements.  And that is exactly what the website was doing.

The following simplified excerpt from the original site will display "one" both 
time on both Nav 4 and IE whereas it will display "one" and then "two" on N6.

<html>
  <head>
    <script>
      function ShowIt() {
        alert('element[1]='+ document.portalInput.elements[1].name);
        document.portalInput.elements[1].name="one";
        alert('element[1]='+ document.portalInput.elements[1].name);
      }
    </script>
  </head>
  <body>
    <form name="portalInput" >
      <input type="hidden" name="zero">       
      <input type="hidden" name="one">  
      <input type="hidden" name="two">
      <input type="hidden" name="three">
      <input type="hidden" name="four">
      <input type="button" value="press me" onclick="ShowIt()">
    </form>
  </body>
</html>
This is due to us not properly sorting items in form.elements, I'm not sure if
jkeiser is planning on fixing this yet or not.
I reduced the testcase too :)  Attaching.

The problem specifically is, we add the element to the end of the elements array
whenever we set the name.
Attached file Reduced testcase
I doubt this fix is going in as part of bug 34297--it's not relevant enough. 
The major problem is that there is no way to insert a control into a specific
index in form.elements[].  form.insertChild() should fail to work properly as well.
Keywords: testcase
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Pushing to mozilla0.9.7
Target Milestone: mozilla0.9.6 → mozilla0.9.7
I bet the patch in bug 109854 fixes this problem too.
Status: NEW → ASSIGNED
Whiteboard: [HAVE FIX]
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Looks like this is fixed now.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Verified with 2003-04-25-12-1.3.1 on winXP.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: