Home | History | Annotate | Download | only in web
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "config.h"
      6 #include "public/web/WebNode.h"
      7 
      8 #include "core/testing/DummyPageHolder.h"
      9 #include "public/web/WebElement.h"
     10 #include "public/web/WebElementCollection.h"
     11 #include <gtest/gtest.h>
     12 
     13 namespace blink {
     14 
     15 using WebCore::Document;
     16 using WebCore::DummyPageHolder;
     17 using WebCore::IntSize;
     18 
     19 class WebNodeTest : public testing::Test {
     20 protected:
     21     Document& document() { return m_pageHolder->document(); }
     22 
     23 private:
     24     virtual void SetUp() OVERRIDE;
     25 
     26     OwnPtr<DummyPageHolder> m_pageHolder;
     27 };
     28 
     29 void WebNodeTest::SetUp()
     30 {
     31     m_pageHolder = WebCore::DummyPageHolder::create(IntSize(800, 600));
     32 }
     33 
     34 TEST_F(WebNodeTest, GetElementsByTagName)
     35 {
     36     document().documentElement()->setInnerHTML("<body><LABEL></LABEL><svg xmlns='http://www.w3.org/2000/svg'><label></label></svg></body>", ASSERT_NO_EXCEPTION);
     37     WebNode node(document().documentElement());
     38     // WebNode::getElementsByTagName returns only HTML elements.
     39     WebElementCollection collection = node.getElementsByTagName("label");
     40     EXPECT_EQ(1u, collection.length());
     41     EXPECT_TRUE(collection.firstItem().hasHTMLTagName("label"));
     42     // The argument should be lower-case.
     43     collection = node.getElementsByTagName("LABEL");
     44     EXPECT_EQ(0u, collection.length());
     45 }
     46 
     47 }
     48