Skip to content
Permalink
Browse files
2010-10-29 Daniel Bates <dbates@rim.com>
        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified Chromium-port to use FrameTree::uniqueName().

        * src/WebFrameImpl.cpp:
        (WebKit::WebFrameImpl::name):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified Qt-port to use FrameTree::uniqueName().

        * Api/qwebframe.cpp:
        (QWebFrame::frameName):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified GTK-port to use FrameTree::uniqueName().

        * webkit/webkitwebframe.cpp:
        (webkit_web_frame_get_name):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified Apple Windows-port to use FrameTree::uniqueName().

        * WebFrame.cpp:
        (WebFrame::name):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified Mac-port to use FrameTree::uniqueName().

        * WebView/WebFrame.mm:
        (-[WebFrame name]):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified EFL-port to use FrameTree::uniqueName().

        * ewk/ewk_frame.cpp:
        (ewk_frame_name_get):
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Fixes an issue where the window.name of an unnamed frame returns
        a unique generated name that is used internally to identify the
        frame. Instead, we should return an empty string as implied by
        section 5.1.6 of the HTML5 spec. (http://www.w3.org/TR/html5/browsers.html#browsing-context-names).
        This section describes that a browsing context can have no name or be
        the empty string.

        * html/HTMLFrameElementBase.cpp:
        (WebCore::HTMLFrameElementBase::openURL): Removed ASSERT for empty
        frame name since this is valid as per the HTML5 spec.
        (WebCore::HTMLFrameElementBase::setName): Removed the call to FrameTree::uniqueChildName()
        since the loader code no longer depends on the frame name being unique.
        * html/HTMLFrameElementBase.h:
        * loader/DocumentLoader.cpp:
        (WebCore::DocumentLoader::mainResource): Use FrameTree::uniqueName().
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::loadURLIntoChildFrame): Ditto.
        (WebCore::FrameLoader::commitProvisionalLoad): Ditto.
        * loader/HistoryController.cpp:
        (WebCore::HistoryController::saveDocumentState): Ditto.
        (WebCore::HistoryController::restoreDocumentState): Ditto.
        (WebCore::HistoryController::createItem):
        (WebCore::HistoryController::currentFramesMatchItem): Ditto.
        * loader/ProgressTracker.cpp:
        (WebCore::ProgressTracker::progressStarted): Ditto.
        (WebCore::ProgressTracker::progressCompleted): Ditto.
        * loader/archive/cf/LegacyWebArchive.cpp:
        (WebCore::LegacyWebArchive::create): Ditto.
        * page/FrameTree.cpp:
        (WebCore::FrameTree::setName): Modified to store the DOM-specified
        name of the frame.
        (WebCore::FrameTree::clearName):
        (WebCore::FrameTree::uniqueChildName): Use FrameTree::uniqueName().
        (WebCore::FrameTree::child): Ditto.
        (WebCore::FrameTree::find): Ditto.
        * page/FrameTree.h:
        (WebCore::FrameTree::uniqueName): Added.
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Updated test case fast/frames/frame-element-name.html to check
        the value of window.name.

        * fast/frames/frame-element-name-expected.txt: Updated result.
        * fast/frames/iframe-set-inner-html-expected.txt: Removed; This test ensured
        that the generated name for an unnamed frames was unique by looking at the
        value of window.name. However, the generated name should not be exposed to
        web developers. Instead, window.name should return the empty string for
        an unnamed frame as implied by section 5.1.6 of the HTML5 spec. We should
        consider exposing a DRT method for obtaining the internal frame name (which
        may be generated) and re-implementing this test to use it.
        * fast/frames/iframe-set-inner-html.html: Removed.
        * fast/frames/resources/frame-element-name-left.html: Added test for window.name.
        * fast/frames/resources/frame-element-name-right.html: Ditto.
2010-10-29  Daniel Bates  <dbates@rim.com>

        Reviewed by Adam Barth.

        For unnamed frames, window.name returns a generated name
        https://bugs.webkit.org/show_bug.cgi?id=6751

        Modified WebKit2 to use FrameTree::uniqueName().

        * WebProcess/WebPage/WebFrame.cpp:
        (WebKit::WebFrame::name):


Canonical link: https://commits.webkit.org/61473@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
dydz committed Oct 30, 2010
1 parent 23c10a0 commit 1ac47acfb919d133b6c7d4bcdd319fc1ab1ff1ed
@@ -1,3 +1,25 @@
2010-10-29 Daniel Bates <dbates@rim.com>

Reviewed by Adam Barth.

For unnamed frames, window.name returns a generated name
https://bugs.webkit.org/show_bug.cgi?id=6751

Updated test case fast/frames/frame-element-name.html to check
the value of window.name.

* fast/frames/frame-element-name-expected.txt: Updated result.
* fast/frames/iframe-set-inner-html-expected.txt: Removed; This test ensured
that the generated name for an unnamed frames was unique by looking at the
value of window.name. However, the generated name should not be exposed to
web developers. Instead, window.name should return the empty string for
an unnamed frame as implied by section 5.1.6 of the HTML5 spec. We should
consider exposing a DRT method for obtaining the internal frame name (which
may be generated) and re-implementing this test to use it.
* fast/frames/iframe-set-inner-html.html: Removed.
* fast/frames/resources/frame-element-name-left.html: Added test for window.name.
* fast/frames/resources/frame-element-name-right.html: Ditto.

2010-10-29 James Robinson <jamesr@chromium.org>

Update pixel expectations for Snow Leopard for tests in tables/mozilla/bugs.
@@ -4,10 +4,12 @@
Frame: 'left'
--------
PASS escape(window.frameElement.name) is "left"
PASS escape(window.name) is "left"


--------
Frame: '<!--framePath //<!--frame1-->-->'
--------
PASS escape(window.frameElement.name) is ""
PASS escape(window.name) is ""

This file was deleted.

This file was deleted.

@@ -7,5 +7,6 @@
<div id="console"></div>
<script>
shouldBeEqualToString("escape(window.frameElement.name)", "left");
shouldBeEqualToString("escape(window.name)", "left");
</script>
</body>
@@ -7,5 +7,6 @@
<div id="console"></div>
<script>
shouldBeEqualToString("escape(window.frameElement.name)", "");
shouldBeEqualToString("escape(window.name)", "");
</script>
</body>
@@ -1,3 +1,48 @@
2010-10-29 Daniel Bates <dbates@rim.com>

Reviewed by Adam Barth.

For unnamed frames, window.name returns a generated name
https://bugs.webkit.org/show_bug.cgi?id=6751

Fixes an issue where the window.name of an unnamed frame returns
a unique generated name that is used internally to identify the
frame. Instead, we should return an empty string as implied by
section 5.1.6 of the HTML5 spec. (http://www.w3.org/TR/html5/browsers.html#browsing-context-names).
This section describes that a browsing context can have no name or be
the empty string.

* html/HTMLFrameElementBase.cpp:
(WebCore::HTMLFrameElementBase::openURL): Removed ASSERT for empty
frame name since this is valid as per the HTML5 spec.
(WebCore::HTMLFrameElementBase::setName): Removed the call to FrameTree::uniqueChildName()
since the loader code no longer depends on the frame name being unique.
* html/HTMLFrameElementBase.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::mainResource): Use FrameTree::uniqueName().
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURLIntoChildFrame): Ditto.
(WebCore::FrameLoader::commitProvisionalLoad): Ditto.
* loader/HistoryController.cpp:
(WebCore::HistoryController::saveDocumentState): Ditto.
(WebCore::HistoryController::restoreDocumentState): Ditto.
(WebCore::HistoryController::createItem):
(WebCore::HistoryController::currentFramesMatchItem): Ditto.
* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::progressStarted): Ditto.
(WebCore::ProgressTracker::progressCompleted): Ditto.
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create): Ditto.
* page/FrameTree.cpp:
(WebCore::FrameTree::setName): Modified to store the DOM-specified
name of the frame.
(WebCore::FrameTree::clearName):
(WebCore::FrameTree::uniqueChildName): Use FrameTree::uniqueName().
(WebCore::FrameTree::child): Ditto.
(WebCore::FrameTree::find): Ditto.
* page/FrameTree.h:
(WebCore::FrameTree::uniqueName): Added.

2010-10-29 Darin Adler <darin@apple.com>

Try to fix build.
@@ -92,8 +92,6 @@ bool HTMLFrameElementBase::isURLAllowed() const

void HTMLFrameElementBase::openURL(bool lockHistory, bool lockBackForwardList)
{
ASSERT(!m_frameName.isEmpty());

if (!isURLAllowed())
return;

@@ -155,9 +153,6 @@ void HTMLFrameElementBase::setName()
m_frameName = getAttribute(nameAttr);
if (m_frameName.isNull())
m_frameName = getIdAttribute();

if (Frame* parentFrame = document()->frame())
m_frameName = parentFrame->tree()->uniqueChildName(m_frameName);
}

void HTMLFrameElementBase::setNameAndOpenURL()
@@ -71,7 +71,7 @@ class HTMLFrameElementBase : public HTMLFrameOwnerElement {
void openURL(bool lockHistory = true, bool lockBackForwardList = true);

AtomicString m_URL;
AtomicString m_frameName;
AtomicString m_frameName; // The actual frame name (may be empty).

ScrollbarMode m_scrolling;

@@ -491,7 +491,7 @@ PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const
if (!mainResourceBuffer)
mainResourceBuffer = SharedBuffer::create();

return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->name());
return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->uniqueName());
}

PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) const
@@ -928,7 +928,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
// If we're moving in the back/forward list, we might want to replace the content
// of this child frame with whatever was there at that point.
if (parentItem && parentItem->children().size() && isBackForwardLoadType(loadType)) {
HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->name());
HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueName());
if (childItem) {
// Use the original URL to ensure we get all the side-effects, such as
// onLoad handlers, of any redirects that happened. An example of where
@@ -939,7 +939,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer,
}
}

RefPtr<Archive> subframeArchive = activeDocumentLoader()->popArchiveForSubframe(childFrame->tree()->name());
RefPtr<Archive> subframeArchive = activeDocumentLoader()->popArchiveForSubframe(childFrame->tree()->uniqueName());

if (subframeArchive)
childFrame->loader()->loadArchive(subframeArchive.release());
@@ -1832,7 +1832,7 @@ void FrameLoader::commitProvisionalLoad()
RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history()->provisionalItem()) : 0;
RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;

LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data(),
LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->uniqueName().string().utf8().data(), m_URL.string().utf8().data(),
pdl ? pdl->url().string().utf8().data() : "<no provisional DocumentLoader>");

// Check to see if we need to cache the page we are navigating away from into the back/forward cache.
@@ -1880,7 +1880,7 @@ void FrameLoader::commitProvisionalLoad()
didOpenURL(url);
}

LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data());
LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->uniqueName().string().utf8().data(), m_URL.string().utf8().data());

if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
history()->updateForClientRedirect();
@@ -149,7 +149,7 @@ void HistoryController::saveDocumentState()
ASSERT(document);

if (item->isCurrentDocument(document)) {
LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->name().string().utf8().data(), item);
LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->uniqueName().string().utf8().data(), item);
item->setDocumentState(document->formElementsState());
}
}
@@ -188,7 +188,7 @@ void HistoryController::restoreDocumentState()
if (!itemToRestore)
return;

LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->name().string().utf8().data(), itemToRestore);
LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->uniqueName().string().utf8().data(), itemToRestore);
doc->setStateForNewFormElements(itemToRestore->documentState());
}

@@ -480,10 +480,10 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal)
originalURL = blankURL();

Frame* parentFrame = m_frame->tree()->parent();
String parent = parentFrame ? parentFrame->tree()->name() : "";
String parent = parentFrame ? parentFrame->tree()->uniqueName() : "";
String title = documentLoader ? documentLoader->title() : "";

RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->name(), parent, title);
RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->uniqueName(), parent, title);
item->setOriginalURLString(originalURL.string());

if (!unreachableURL.isEmpty() || !documentLoader || documentLoader->response().httpStatusCode() >= 400)
@@ -598,7 +598,7 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt
// Helper method that determines whether the current frame tree matches given history item's.
bool HistoryController::currentFramesMatchItem(HistoryItem* item) const
{
if ((!m_frame->tree()->name().isEmpty() || !item->target().isEmpty()) && m_frame->tree()->name() != item->target())
if ((!m_frame->tree()->uniqueName().isEmpty() || !item->target().isEmpty()) && m_frame->tree()->uniqueName() != item->target())
return false;

const HistoryItemVector& childItems = item->children();
@@ -101,7 +101,7 @@ void ProgressTracker::reset()

void ProgressTracker::progressStarted(Frame* frame)
{
LOG(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->name().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get());
LOG(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->uniqueName().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get());

frame->loader()->client()->willChangeEstimatedProgress();

@@ -119,7 +119,7 @@ void ProgressTracker::progressStarted(Frame* frame)

void ProgressTracker::progressCompleted(Frame* frame)
{
LOG(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->name().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get());
LOG(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->uniqueName().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get());

if (m_numProgressTrackedFrames <= 0)
return;
@@ -492,7 +492,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
if (responseURL.isNull())
responseURL = KURL(ParsedURLString, "");

PassRefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree()->name());
PassRefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree()->uniqueName());

Vector<PassRefPtr<LegacyWebArchive> > subframeArchives;
Vector<PassRefPtr<ArchiveResource> > subresources;
@@ -509,7 +509,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
if (subframeArchive)
subframeArchives.append(subframeArchive);
else
LOG_ERROR("Unabled to archive subframe %s", childFrame->tree()->name().string().utf8().data());
LOG_ERROR("Unabled to archive subframe %s", childFrame->tree()->uniqueName().string().utf8().data());
} else {
ListHashSet<KURL> subresourceURLs;
node->getSubresourceURLs(subresourceURLs);
@@ -40,17 +40,19 @@ FrameTree::~FrameTree()

void FrameTree::setName(const AtomicString& name)
{
m_name = name;
if (!parent()) {
m_name = name;
m_uniqueName = name;
return;
}
m_name = AtomicString(); // Remove our old frame name so it's not considered in uniqueChildName.
m_name = parent()->tree()->uniqueChildName(name);
m_uniqueName = AtomicString(); // Remove our old frame name so it's not considered in uniqueChildName.
m_uniqueName = parent()->tree()->uniqueChildName(name);
}

void FrameTree::clearName()
{
m_name = AtomicString();
m_uniqueName = AtomicString();
}

Frame* FrameTree::parent(bool checkForDisconnectedFrame) const
@@ -119,19 +121,19 @@ AtomicString FrameTree::uniqueChildName(const AtomicString& requestedName) const
Vector<Frame*, 16> chain;
Frame* frame;
for (frame = m_thisFrame; frame; frame = frame->tree()->parent()) {
if (frame->tree()->name().startsWith(framePathPrefix))
if (frame->tree()->uniqueName().startsWith(framePathPrefix))
break;
chain.append(frame);
}
String name;
name += framePathPrefix;
if (frame)
name += frame->tree()->name().string().substring(framePathPrefixLength,
frame->tree()->name().length() - framePathPrefixLength - framePathSuffixLength);
name += frame->tree()->uniqueName().string().substring(framePathPrefixLength,
frame->tree()->uniqueName().length() - framePathPrefixLength - framePathSuffixLength);
for (int i = chain.size() - 1; i >= 0; --i) {
frame = chain[i];
name += "/";
name += frame->tree()->name();
name += frame->tree()->uniqueName();
}

// Suffix buffer has more than enough space for:
@@ -159,7 +161,7 @@ Frame* FrameTree::child(unsigned index) const
Frame* FrameTree::child(const AtomicString& name) const
{
for (Frame* child = firstChild(); child; child = child->tree()->nextSibling())
if (child->tree()->name() == name)
if (child->tree()->uniqueName() == name)
return child;
return 0;
}
@@ -181,7 +183,7 @@ Frame* FrameTree::find(const AtomicString& name) const

// Search subtree starting with this frame first.
for (Frame* frame = m_thisFrame; frame; frame = frame->tree()->traverseNext(m_thisFrame))
if (frame->tree()->name() == name)
if (frame->tree()->uniqueName() == name)
return frame;

// Search the entire tree for this page next.
@@ -192,7 +194,7 @@ Frame* FrameTree::find(const AtomicString& name) const
return 0;

for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
if (frame->tree()->name() == name)
if (frame->tree()->uniqueName() == name)
return frame;

// Search the entire tree of each of the other pages in this namespace.
@@ -203,7 +205,7 @@ Frame* FrameTree::find(const AtomicString& name) const
Page* otherPage = *it;
if (otherPage != page) {
for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
if (frame->tree()->name() == name)
if (frame->tree()->uniqueName() == name)
return frame;
}
}
@@ -39,6 +39,7 @@ namespace WebCore {
~FrameTree();

const AtomicString& name() const { return m_name; }
const AtomicString& uniqueName() const { return m_uniqueName; }
void setName(const AtomicString&);
void clearName();
Frame* parent(bool checkForDisconnectedFrame = false) const;
@@ -73,7 +74,8 @@ namespace WebCore {
Frame* m_thisFrame;

Frame* m_parent;
AtomicString m_name;
AtomicString m_name; // The actual frame name (may be empty).
AtomicString m_uniqueName;

// FIXME: use ListRefPtr?
RefPtr<Frame> m_nextSibling;

0 comments on commit 1ac47ac

Please sign in to comment.