Commit 4bd01007 authored by aliceli1's avatar aliceli1

LayoutTests:

        Reviewed by Geoff.

       Added tests for <rdar://problem/4548537> Document.domain and other attributes are blank for an iframe created with document.write

        * http/tests/misc/iframe-domain-test-expected.txt: Added.
        * http/tests/misc/iframe-domain-test.html: Added.

WebCore:

        Reviewed by Geoff.

        Fixed <rdar://problem/4548537> Document.domain and other attributes are blank for an iframe created with document.write

        * dom/Document.cpp:
        (WebCore::Document::open):
        set the document's url to the parent's url and re-located the code that does this to occur before calling the frame's didExplicitOpen()
        * page/Frame.cpp:
        (WebCore::Frame::didExplicitOpen):
        set the frame's url to the document's url



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16081 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b0886a77
2006-08-28 Alice Liu <alice.liu@apple.com>
Reviewed by Geoff.
Added tests for <rdar://problem/4548537> Document.domain and other attributes are blank for an iframe created with document.write
* http/tests/misc/iframe-domain-test-expected.txt: Added.
* http/tests/misc/iframe-domain-test.html: Added.
2006-08-27 Rob Buis <buis@kde.org>
Reviewed by Eric.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org\tR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>iFrame Test</title>
<script>
function run()
{
window.frames['test1'].document.open("text/html","replace");
window.frames['test1'].document.close();
var src = "<html>\n<head>\n<script>\nfunction fill()\n{\n document.getElementById(\"domain\").innerHTML = document.domain;\n document.getElementById(\"URL\").innerHTML = document.URL;\n document.getElementById(\"wlh\").innerHTML = window.location.href;\n document.getElementById(\"plh\").innerHTML = parent.location.href;\n}\n<\/script>\n<\/head>\n<body onload=\"fill();\">\nThis iframe's src was set with document.write.\n<br><br>\ndocument.domain: <span id=\"domain\"><\/span>\n<br><br>\ndocument.URL: <span id=\"URL\"><\/span>\n<br><br>\nwindow.location.href: <span id=\"wlh\"><\/span>\n<br><br>\nparent.location.href: <span id=\"plh\"><\/span>\n<\/body>\n<\/html>\n";
window.frames['test2'].document.open("text/html","replace");
window.frames['test2'].document.write(src);
window.frames['test2'].document.close();
var oSpan1 = document.getElementById("result1");
var pass = true;
var str = "";
if (window.frames['test1'].document.domain != document.domain) {
pass = false;
str = "document.domain is " + window.frames['test1'].document.domain + " but should be " + document.domain + "<br>";
}
if (window.frames['test1'].document.URL != document.URL) {
pass = false;
str += "document.URL is " + window.frames['test1'].document.URL + " but should be " + document.URL + "<br>";
}
if (window.frames['test1'].window.location.href != window.location.href) {
pass = false;
str += "window.location.href is " + window.frames['test1'].window.location.href + " but should be " + window.location.href + "<br>";
}
if (window.frames['test1'].parent.location.href != parent.location.href) {
pass = false;
str += "parent.location.href is " + window.frames['test1'].parent.location.href + " but should be " + parent.location.href + "<br>";
}
if (pass)
{
oSpan1.setAttribute("style", "color: green;");
oSpan1.innerHTML = "PASS";
}
else
{
oSpan1.setAttribute("style", "color: red;");
oSpan1.innerHTML = "FAIL<br>" + str;
}
var oSpan2 = document.getElementById("result2");
pass = true;
str = "";
if (window.frames['test2'].document.domain != document.domain) {
pass = false;
str = "document.domain is " + window.frames['test2'].document.domain + " but should be " + document.domain + "<br>";
}
if (window.frames['test2'].document.URL != document.URL) {
pass = false;
str += "document.URL is " + window.frames['test2'].document.URL + " but should be " + document.URL + "<br>";
}
if (window.frames['test2'].window.location.href != window.location.href) {
pass = false;
str += "window.location.href is " + window.frames['test2'].window.location.href + " but should be " + window.location.href + "<br>";
}
if (window.frames['test2'].parent.location.href != parent.location.href) {
pass = false;
str += "parent.location.href is " + window.frames['test2'].parent.location.href + " but should be " + parent.location.href + "<br>";
}
if (pass)
{
oSpan2.setAttribute("style", "color: green;");
oSpan2.innerHTML = "PASS";
}
else
{
oSpan2.setAttribute("style", "color: red;");
oSpan2.innerHTML = "FAIL<br>" + str;
}
if (window.layoutTestController)
layoutTestController.dumpAsText();
}
</script>
</head>
<body onload="run();">
<iframe name="test1" style="border: 1px solid black;"></iframe><span id="result1"></span><br>
<iframe name="test2" style="width: 500px; height: 200px; border: 1px solid black;"></iframe><span id="result2"></span><br>
</body>
</html>
2006-08-28 Alice Liu <alice.liu@apple.com>
Reviewed by Geoff.
Fixed <rdar://problem/4548537> Document.domain and other attributes are blank for an iframe created with document.write
* dom/Document.cpp:
(WebCore::Document::open):
set the document's url to the parent's url and re-located the code that does this to occur before calling the frame's didExplicitOpen()
* page/Frame.cpp:
(WebCore::Frame::didExplicitOpen):
set the frame's url to the document's url
2006-08-28 Brady Eidson <beidson@apple.com>
Reviewed by Adele and Adam
......
......@@ -1108,6 +1108,16 @@ Tokenizer *Document::createTokenizer()
void Document::open()
{
// This is work that we should probably do in clear(), but we can't have it
// happen when implicitOpen() is called unless we reorganize Frame code.
if (Document *parent = parentDocument()) {
setURL(parent->baseURL());
setBaseURL(parent->baseURL());
}
else
setURL(DeprecatedString());
if ((frame() && frame()->isLoadingMainResource()) || (tokenizer() && tokenizer()->executingScript()))
return;
......@@ -1115,12 +1125,6 @@ void Document::open()
if (frame())
frame()->didExplicitOpen();
// This is work that we should probably do in clear(), but we can't have it
// happen when implicitOpen() is called unless we reorganize Frame code.
setURL(DeprecatedString());
if (Document *parent = parentDocument())
setBaseURL(parent->baseURL());
}
void Document::cancelParsing()
......
......@@ -271,6 +271,7 @@ void Frame::didExplicitOpen()
// Cancelling redirection here works for all cases because document.open
// implicitly precedes document.write.
cancelRedirection();
d->m_url = d->m_doc->URL();
}
void Frame::stopLoading(bool sendUnload)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment