bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

In some js method new Option is created and some custom attribite is assigned to it, then this Option is added in some Select; if method is called from the same page where Select is located, custom attribute is always kept by Option, BUT in Mozilla if ...

NEW
Unassigned

Status

()

Core
DOM: Core & HTML
P5
normal
16 years ago
18 days ago

People

(Reporter: Eugene Gunichev, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments)

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212

Sketchy example of the main page (which contains js method, SELECT and IFRAME)
<html>
<head>
    <script language="JavaScript">
        function addOption(source) {
            var index = document.forms[0].select.options.length;
            var no = new Option();
            no.value = 'value' + index;
            no.text = 'text' + index + ' (from ' + source + ')';
            document.forms[0].select.options[index] = no;
            no.customAtt = index;
            alert('customAtt: ' + no.customAtt);
        }
        function showCustomAtt() {
            if(document.forms[0].select.selectedIndex != -1) {
                oo =
document.forms[0].select.options[document.forms[0].select.selectedIndex];
                alert('customAtt: ' + oo.customAtt);
            }
        }
    </script>
</head>
<body>
    <form>
        <table>
            <tr>
                <td>
                    <select name="select" size="10" style="width: 250px;">
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" value="Add from self"
onClick="addOption('self')">
                    <input type="button" value="Show Custom Att"
onClick="showCustomAtt()">
                </td>
            </tr>
            <tr>
                <td>
                    <iframe src="child.html" frameborder="1" height="100"
width="250"></iframe>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Sketchy example of the page loaded in the IFRAME.
<html>
<head></head>
<body>
    <form>
        <input type="button" value="Add from child"
onClick="parent.addOption('child')">
    </form>
</body>
</html>



Reproducible: Always

Steps to Reproduce:
1. Open main page (see its src in the Datails section) in Mozilla.
2. Click "Add from self" button on the main page and note the value of the
custom attribite in the alert.
3. Click "Add from child" button on the page in the IFRAME and note the value of
the custom attribite in the alert (just after adding it to newly created Option
it still "alive").
4. Select option created by call to js method from main page, click "Show Custom
Att" button and note the value of the custom attribite - it is the same as after
creating Option.
5. Select option created by call to js method from the page in IFRAME, click
"Show Custom Att" button and note the value of the custom attribite - it is
"undefined".

Actual Results:  
Value of any custom attribute in the Options created by the call to some js
method from page in the IFRAME is LOST. If Options is created by the call to
some js method from the same page where Select is, value of the Option's custom
attributes is KEPT.

Expected Results:  
Keep value of the custom attributes in any case.

Theme is Classic.

Comment 1

16 years ago
Created attachment 112159 [details]
Difference between setAttribute and className=""

I think it is setAttribute weirdness. If I use className="new" CSS style apply,
but in setAttribute('className','new') don't. I think I see same bug with
setAttribute recently.

Comment 2

16 years ago
Oops. I miss a bug
(Reporter)

Comment 3

16 years ago
Created attachment 112166 [details]
I'm not sure that this is because of setAttribute()
(Reporter)

Comment 4

16 years ago
Comment on attachment 112166 [details]
I'm not sure that this is because of setAttribute()

That's just the point - I don't use setAttribute(). And what is more, I'm
generally not sure that my script is correct from the DOM point of view. All
that I can say - this script works in IE, Opera and does not work in Mozilla IN
SOME CASE.
BTW, about using setAttribute() see http://www.xs4all.nl/~ppk/js/w3c_core.html

Comment 5

16 years ago
Sorry, it was attachment to other bug, and not to this one. But I could not
reproduce you one. I do AddFromSelf (return 0), AddFromChild (return 1), select
first line, press ShowCustom Att (get 0), select second line, press ShowCustom
Att (get 1).

Everything seems to be o'k. 

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030121
(Reporter)

Comment 6

16 years ago
It seems that I have too old version - Mozilla/5.0 (Windows; U; Windows NT 5.0;
en-US; rv:1.3a) Gecko/20021212, probably in the latest versions all work as you
have said.
Could someone attach a working testcase to this bug ("working" == "shows the
problem")?

If that requires multiple files (eg a frameset and a frame) attach the frame
first, then point the frameset to the bugzilla attachment url and attach it.
(Reporter)

Comment 8

16 years ago
Created attachment 112185 [details]
content for iframe
(Reporter)

Comment 9

16 years ago
Created attachment 112186 [details]
full test
Eugene, thanks.  Confirming on Linux current trunk as well.  Is the problem that
the JS wrapper (which is what the custom prop is set on) is attached to the
document and when we switch documents we get a different wrapper?
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 2000 → All
Hardware: PC → All
(Reporter)

Comment 11

16 years ago
Comment on attachment 112186 [details]
full test

really does not work in 1.1, 1.2a, 1.3a, NS 7.0, but most likely works in 1.3b
(i have not tested personally - this is from Ruslan Ismailov)

Comment 12

16 years ago
No, I say that I could not reproduce it on previous version of testcase.

Comment 13

16 years ago
Sorry, but could not this be a desired behaviour? 

I add a following button to iframe: 

<input type="button" value="Show Custom Att" onClick="parent.showCustomAtt()">

And found, that customAtt in thos case could be obtained from iframe, but not in
mainfraime -- so it is look like data protection.
There should be no data protection issues if both frames come from the same
site.  And no, this is not desired behavior, imo.
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
(Reporter)

Comment 16

12 years ago
The original summary for this bug was longer than 255 characters, and so it was truncated when Bugzilla was upgraded. The original summary was:

In some js method new Option is created and some custom attribite is assigned to it, then this Option is added in some Select; if method is called from the same page where Select is located, custom attribute is always kept by Option, BUT in Mozilla if method is called from the page in the IFRAME - custom attribute is lost irretrievably.
Assignee: general → nobody
QA Contact: desale → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.