Commit 0c236612 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Don't consider browsing contexts with empty names for named lookup.

Bug: 803620
Change-Id: I6c28067a10d812faf815a04360a701aee741abc5
Reviewed-on: https://chromium-review.googlesource.com/925541Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537735}
parent 1562bcc1
...@@ -11968,6 +11968,20 @@ TEST_P(WebFrameSimTest, RtlInitialScrollOffsetWithViewport) { ...@@ -11968,6 +11968,20 @@ TEST_P(WebFrameSimTest, RtlInitialScrollOffsetWithViewport) {
ASSERT_EQ(ScrollOffset(0, 0), area->GetScrollOffset()); ASSERT_EQ(ScrollOffset(0, 0), area->GetScrollOffset());
} }
TEST_P(WebFrameSimTest, NamedLookupIgnoresEmptyNames) {
SimRequest main_resource("https://example.com/main.html", "text/html");
LoadURL("https://example.com/main.html");
main_resource.Complete(R"HTML(
<body>
<iframe name="" src="data:text/html,"></iframe>
</body>)HTML");
EXPECT_EQ(nullptr, MainFrame().GetFrame()->Tree().ScopedChild(""));
EXPECT_EQ(nullptr,
MainFrame().GetFrame()->Tree().ScopedChild(AtomicString()));
EXPECT_EQ(nullptr, MainFrame().GetFrame()->Tree().ScopedChild(g_empty_atom));
}
TEST_P(ParameterizedWebFrameTest, NoLoadingCompletionCallbacksInDetach) { TEST_P(ParameterizedWebFrameTest, NoLoadingCompletionCallbacksInDetach) {
class LoadingObserverFrameClient class LoadingObserverFrameClient
: public FrameTestHelpers::TestWebFrameClient { : public FrameTestHelpers::TestWebFrameClient {
......
...@@ -139,6 +139,9 @@ Frame* FrameTree::ScopedChild(unsigned index) const { ...@@ -139,6 +139,9 @@ Frame* FrameTree::ScopedChild(unsigned index) const {
} }
Frame* FrameTree::ScopedChild(const AtomicString& name) const { Frame* FrameTree::ScopedChild(const AtomicString& name) const {
if (name.IsEmpty())
return nullptr;
for (Frame* child = FirstChild(); child; for (Frame* child = FirstChild(); child;
child = child->Tree().NextSibling()) { child = child->Tree().NextSibling()) {
if (child->Client()->InShadowTree()) if (child->Client()->InShadowTree())
......
...@@ -62,6 +62,11 @@ class CORE_EXPORT FrameTree final { ...@@ -62,6 +62,11 @@ class CORE_EXPORT FrameTree final {
unsigned ChildCount() const; unsigned ChildCount() const;
Frame* ScopedChild(unsigned index) const; Frame* ScopedChild(unsigned index) const;
// https://whatwg.org/C/window-object.html#named-access-on-the-window-object
// This implements the steps needed for looking up a child browsing context
// that matches |name|. If |name.IsEmpty()| is true, this is guaranteed to
// return null: the spec specifically states that browsing contexts with a
// name are never considered.
Frame* ScopedChild(const AtomicString& name) const; Frame* ScopedChild(const AtomicString& name) const;
unsigned ScopedChildCount() const; unsigned ScopedChildCount() const;
void InvalidateScopedChildCount(); void InvalidateScopedChildCount();
......
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