-fixed rdar://problem/4170960
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2005 02:00:18 +0000 (02:00 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2005 02:00:18 +0000 (02:00 +0000)
http://bugzilla.opendarwin.org/show_bug.cgi?id=3952
iFrame name and id information incorrectly returned

Reviewed by mjs.

        Test cases added: (NONE)
        * layout-tests/fast/frames/iframe-name-and-id-expected.txt: Added.
        * layout-tests/fast/frames/iframe-name-and-id.html: Added.

        * ChangeLog:
        * khtml/html/html_baseimpl.cpp:
        (HTMLFrameElementImpl::attach): removed misleading comment
        (HTMLIFrameElementImpl::attach): copied FrameElementImpl behavior
for initializing m_name

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9665 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/fast/frames/iframe-name-and-id-expected.txt [new file with mode: 0644]
LayoutTests/fast/frames/iframe-name-and-id.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23
WebCore/khtml/html/html_baseimpl.cpp

diff --git a/LayoutTests/fast/frames/iframe-name-and-id-expected.txt b/LayoutTests/fast/frames/iframe-name-and-id-expected.txt
new file mode 100644 (file)
index 0000000..20bde94
--- /dev/null
@@ -0,0 +1,13 @@
+Tests: getting and setting frames[x].name on an iFrame
+
+Related bug: rdar://problem/4170960 http://bugzilla.opendarwin.org/show_bug.cgi?id=3952 iFrame name and id information incorrectly returned
+
+
+frames[0].name (should be frame0_name): frame0_name
+
+frames[0].id (should be undefined): undefined
+
+
+frames[0].name (should be frame0_newname): frame0_newname
+
+frames[0].id (should be frame0_newid): frame0_newid
diff --git a/LayoutTests/fast/frames/iframe-name-and-id.html b/LayoutTests/fast/frames/iframe-name-and-id.html
new file mode 100644 (file)
index 0000000..c866d64
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script>
+function print(message) {
+       var paragraph = document.createElement("p");
+       paragraph.appendChild(document.createTextNode(message));
+       document.getElementById("console").appendChild(paragraph);
+}
+
+function test() {
+       if (window.layoutTestController) {
+               window.layoutTestController.dumpAsText();
+       }
+       
+       print("frames[0].name (should be frame0_name): " + frames[0].name);
+       print("frames[0].id (should be undefined): " + frames[0].id);
+       print("");
+
+       frames[0].name = "frame0_newname"
+       frames[0].id = "frame0_newid";
+       print("frames[0].name (should be frame0_newname): " + frames[0].name);
+       print("frames[0].id (should be frame0_newid): " + frames[0].id);
+}
+</script>
+</head>
+<body onload="test()">
+<p>Tests: getting and setting frames[x].name on an iFrame</p>
+<p>Related bug: <i>rdar://problem/4170960 http://bugzilla.opendarwin.org/show_bug.cgi?id=3952 <a href=http://bugzilla.opendarwin.org/show_bug.cgi?id=3952>iFrame name and id information incorrectly returned</a></i></p>
+<hr>
+<div id='console'/>
+<iframe name="frame0_name" id="frame0_id"></iframe>
+</body>
+</html>
index 7047d3756f593f35b0884fc1f552c5c3e5bab4b8..898b2d7366489e600f9b28368438d430d13c3d62 100644 (file)
@@ -1,3 +1,31 @@
+2005-07-11  Geoffrey Garen  <ggaren@apple.com>
+
+       -fixed rdar://problem/4170960 
+       http://bugzilla.opendarwin.org/show_bug.cgi?id=3952 
+       iFrame name and id information incorrectly returned
+        
+       Reviewed by mjs.
+
+        Test cases added: (NONE)
+        * layout-tests/fast/frames/iframe-name-and-id-expected.txt: Added.
+        * layout-tests/fast/frames/iframe-name-and-id.html: Added.
+
+        * ChangeLog:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLFrameElementImpl::attach): removed misleading comment
+        (HTMLIFrameElementImpl::attach): copied FrameElementImpl behavior
+       for initializing m_name
+
+2005-07-11  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by NOBODY (OOPS!).
+
+        Test cases added: (NONE)
+
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLFrameElementImpl::attach):
+        (HTMLIFrameElementImpl::attach):
+
 2005-07-11  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Richard
index 8dd3b96fd408efb0cf4618ff69768ad14e542568..5c7a01f00bb4986961e103b8e86941f66fb4c7bd 100644 (file)
@@ -475,8 +475,6 @@ RenderObject *HTMLFrameElementImpl::createRenderer(RenderArena *arena, RenderSty
 
 void HTMLFrameElementImpl::attach()
 {
-    // we should first look up via id, then via name.
-    // this shortterm hack fixes the ugly case. ### rewrite needed for next release
     m_name = getAttribute(ATTR_NAME);
     if (m_name.isNull())
         m_name = getAttribute(ATTR_ID);
@@ -936,12 +934,16 @@ RenderObject *HTMLIFrameElementImpl::createRenderer(RenderArena *arena, RenderSt
 
 void HTMLIFrameElementImpl::attach()
 {
+    m_name = getAttribute(ATTR_NAME);
+    if (m_name.isNull())
+        m_name = getAttribute(ATTR_ID);
+    
     HTMLElementImpl::attach();
 
     KHTMLPart *part = getDocument()->part();
     if (m_render && part) {
         // we need a unique name for every frame in the frameset. Hope that's unique enough.
-       part->incrementFrameCount();
+        part->incrementFrameCount();
         if (m_name.isEmpty() || part->frameExists(m_name.string()))
             m_name = AtomicString(part->requestFrameName());