Commit ab0e7dcb authored by beidson's avatar beidson

LayoutTests:

        Reviewed by Geoose

        <rdar://problem/4664154> and http://bugs.webkit.org/show_bug.cgi?id=3546

        Layout test that covers opening an empty new window, then starting to navigate around in it

        * history/new-window-redirect-history-expected.txt: Added.
        * history/new-window-redirect-history.html: Added.
        * history/resources/redirect-1.html: Added.
        * history/resources/redirect-2.html: Added.

WebCore:

        Reviewed by Black Sheep

        <rdar://problem/4664154> and http://bugs.webkit.org/show_bug.cgi?id=3546

        When you click on a link that opens in a new window from within gmail, they first create a new window 
        with an empty URL, then immediately document.write() into the window to schedule a redirect.

        Since the initial page doesn't have a URL associated with it, a history item never gets created.  The 
        reasonable solution?  To actually create the history item after the redirect (in updateHistoryForInternalLoad)

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::addHistoryForCurrentLocation): Updates global and B/F history with a new history item
        (WebCore::FrameLoader::updateHistoryForStandardLoad): Call addHistoryForCurrentLocation
        (WebCore::FrameLoader::updateHistoryForInternalLoad): Call addHistoryForCurrentLocation if there is not already
          a current history item
        * loader/FrameLoader.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bf0af0be
2007-04-12 Brady Eidson <beidson@apple.com>
Reviewed by Geoose
<rdar://problem/4664154> and http://bugs.webkit.org/show_bug.cgi?id=3546
Layout test that covers opening an empty new window, then starting to navigate around in it
* history/new-window-redirect-history-expected.txt: Added.
* history/new-window-redirect-history.html: Added.
* history/resources/redirect-1.html: Added.
* history/resources/redirect-2.html: Added.
2007-04-13 Anders Carlsson <andersca@apple.com>
Reviewed by Brady.
This test will open a new window to an empty url and fill its contents with a document.write()
That document will then redirect to another url called redirect-1.html.
That document will redirect to yet another url called redirect-2.html
The back/forward history of the new window should contain both redirect-1.html and redirect-2.html
The test will run automatically with popup blocking disabled, or you can click the button.
============== Back Forward List ==============
curr-> file:///Volumes/Data/Users/bradeeoh/dev_svn/OpenSource/LayoutTests/history/new-window-redirect-history.html **nav target**
===============================================
============== Back Forward List ==============
file:///Volumes/Data/Users/bradeeoh/dev_svn/OpenSource/LayoutTests/history/resources/redirect-1.html **nav target**
curr-> file:///Volumes/Data/Users/bradeeoh/dev_svn/OpenSource/LayoutTests/history/resources/redirect-2.html **nav target**
===============================================
<html>
<script>
if (window.layoutTestController) {
layoutTestController.setCanOpenWindows();
layoutTestController.dumpBackForwardList();
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function createNewWindow() {
var newWindow = window.open('');
newWindow.focus();
newWindow.document.write('<html><meta http-equiv="refresh" content="0;url=resources/redirect-1.html"></html>');
newWindow.document.close();
}
</script>
<body onload="createNewWindow();">
This test will open a new window to an empty url and fill its contents with a document.write()<br>
That document will then redirect to another url called redirect-1.html.<br>
That document will redirect to yet another url called redirect-2.html<br>
The back/forward history of the new window should contain both redirect-1.html and redirect-2.html<br><br>
The test will run automatically with popup blocking disabled, or you can click the button.<br><br>
<input type="button" value="Run Test" onclick="createNewWindow();">
</body>
</html>
<html>
<meta http-equiv="refresh" content="2;url=redirect-2.html">
<body>
This document should redirect to redirect-2.html.<br>
After that redirect, this window should have both redirect-1.html and redirect-2.html in its back/forward list.
</body>
</html>
<html>
<script>
function loaded() {
if (window.layoutTestController) {
layoutTestController.notifyDone();
}
}
</script>
<body onload="loaded();">
This window should now have both redirect-1.html and redirect-2.html in its back/forward list.
</body>
</html>
2007-04-12 Brady Eidson <beidson@apple.com>
Reviewed by Black Sheep
<rdar://problem/4664154> and http://bugs.webkit.org/show_bug.cgi?id=3546
When you click on a link that opens in a new window from within gmail, they first create a new window
with an empty URL, then immediately document.write() into the window to schedule a redirect.
Since the initial page doesn't have a URL associated with it, a history item never gets created. The
reasonable solution? To actually create the history item after the redirect (in updateHistoryForInternalLoad)
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addHistoryForCurrentLocation): Updates global and B/F history with a new history item
(WebCore::FrameLoader::updateHistoryForStandardLoad): Call addHistoryForCurrentLocation
(WebCore::FrameLoader::updateHistoryForInternalLoad): Call addHistoryForCurrentLocation if there is not already
a current history item
* loader/FrameLoader.h:
2007-04-12 Oliver Hunt <oliver@apple.com>
Reviewed by Adam.
......@@ -3954,19 +3954,22 @@ bool FrameLoader::childFramesMatchItem(HistoryItem* item) const
return true;
}
void FrameLoader::addHistoryForCurrentLocation()
{
if (!privateBrowsingEnabled()) {
// FIXME: <rdar://problem/4880065> - This will be a hook into the WebCore global history, and this loader/client call will be removed
updateGlobalHistoryForStandardLoad(documentLoader()->urlForHistory());
}
addBackForwardItemClippedAtTarget(true);
}
void FrameLoader::updateHistoryForStandardLoad()
{
LOG(History, "WebCoreHistory: Updating History for Standard Load in frame %s", documentLoader()->URL().url().ascii());
if (!documentLoader()->isClientRedirect()) {
KURL url = documentLoader()->urlForHistory();
if (!url.isEmpty()) {
if (!privateBrowsingEnabled()) {
// FIXME: <rdar://problem/4880065> - This will be a hook into the WebCore global history, and this loader/client call will be removed
updateGlobalHistoryForStandardLoad(url);
}
addBackForwardItemClippedAtTarget(true);
}
if (!documentLoader()->urlForHistory().isEmpty())
addHistoryForCurrentLocation();
} else if (documentLoader()->unreachableURL().isEmpty() && m_currentHistoryItem) {
m_currentHistoryItem->setURL(documentLoader()->URL());
m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
......@@ -4030,10 +4033,11 @@ void FrameLoader::updateHistoryForInternalLoad()
#endif
if (documentLoader()->isClientRedirect()) {
if (m_currentHistoryItem) {
m_currentHistoryItem->setURL(documentLoader()->URL());
m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
}
if (!m_currentHistoryItem)
addHistoryForCurrentLocation();
m_currentHistoryItem->setURL(documentLoader()->URL());
m_currentHistoryItem->setFormInfoFromRequest(documentLoader()->request());
} else {
// Add an item to the item tree for this frame
Frame* parentFrame = m_frame->tree()->parent();
......
......@@ -429,6 +429,7 @@ namespace WebCore {
void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
bool childFramesMatchItem(HistoryItem*) const;
void addHistoryForCurrentLocation();
void updateHistoryForBackForwardNavigation();
void updateHistoryForReload();
void updateHistoryForStandardLoad();
......
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