当前位置: 首页>>代码示例>>C++>>正文


C++ HTMLLinkElement::setAttribute方法代码示例

本文整理汇总了C++中HTMLLinkElement::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLLinkElement::setAttribute方法的具体用法?C++ HTMLLinkElement::setAttribute怎么用?C++ HTMLLinkElement::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLLinkElement的用法示例。


在下文中一共展示了HTMLLinkElement::setAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadURL

TEST_F(WebDocumentTest, ManifestURL)
{
    loadURL(std::string(kDefaultOrigin) + kManifestDummyFilePath);

    WebDocument webDoc = topWebDocument();
    Document* document = topDocument();
    HTMLLinkElement* linkManifest = document->linkManifest();

    // No href attribute was set.
    ASSERT_EQ(linkManifest->href(), static_cast<KURL>(webDoc.manifestURL()));

    // Set to some absolute url.
    linkManifest->setAttribute(HTMLNames::hrefAttr, "http://example.com/manifest.json");
    ASSERT_EQ(linkManifest->href(), static_cast<KURL>(webDoc.manifestURL()));

    // Set to some relative url.
    linkManifest->setAttribute(HTMLNames::hrefAttr, "static/manifest.json");
    ASSERT_EQ(linkManifest->href(), static_cast<KURL>(webDoc.manifestURL()));
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:19,代码来源:WebDocumentTest.cpp

示例2:

TEST(HTMLLinkElementSizesAttributeTest,
     setSizesAttribute_updatesSizesPropertyValue) {
  Document* document = Document::create();
  HTMLLinkElement* link =
      HTMLLinkElement::create(*document, /* createdByParser: */ false);
  DOMTokenList* sizes = link->sizes();
  EXPECT_EQ(nullAtom, sizes->value());
  link->setAttribute(HTMLNames::sizesAttr, "y  x ");
  EXPECT_EQ("y  x ", sizes->value());
}
开发者ID:mirror,项目名称:chromium,代码行数:10,代码来源:HTMLLinkElementSizesAttributeTest.cpp

示例3: document

// This test checks that Documunt::linkManifest() returns a value conform to the specification.
TEST_F(DocumentTest, LinkManifest)
{
    // Test the default result.
    EXPECT_EQ(0, document().linkManifest());

    // Check that we use the first manifest with <link rel=manifest>
    HTMLLinkElement* link = HTMLLinkElement::create(document(), false);
    link->setAttribute(blink::HTMLNames::relAttr, "manifest");
    link->setAttribute(blink::HTMLNames::hrefAttr, "foo.json");
    document().head()->appendChild(link);
    EXPECT_EQ(link, document().linkManifest());

    HTMLLinkElement* link2 = HTMLLinkElement::create(document(), false);
    link2->setAttribute(blink::HTMLNames::relAttr, "manifest");
    link2->setAttribute(blink::HTMLNames::hrefAttr, "bar.json");
    document().head()->insertBefore(link2, link);
    EXPECT_EQ(link2, document().linkManifest());
    document().head()->appendChild(link2);
    EXPECT_EQ(link, document().linkManifest());

    // Check that crazy URLs are accepted.
    link->setAttribute(blink::HTMLNames::hrefAttr, "http:foo.json");
    EXPECT_EQ(link, document().linkManifest());

    // Check that empty URLs are accepted.
    link->setAttribute(blink::HTMLNames::hrefAttr, "");
    EXPECT_EQ(link, document().linkManifest());

    // Check that URLs from different origins are accepted.
    link->setAttribute(blink::HTMLNames::hrefAttr, "http://example.org/manifest.json");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::hrefAttr, "http://foo.example.org/manifest.json");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::hrefAttr, "http://foo.bar/manifest.json");
    EXPECT_EQ(link, document().linkManifest());

    // More than one token in @rel is accepted.
    link->setAttribute(blink::HTMLNames::relAttr, "foo bar manifest");
    EXPECT_EQ(link, document().linkManifest());

    // Such as spaces around the token.
    link->setAttribute(blink::HTMLNames::relAttr, " manifest ");
    EXPECT_EQ(link, document().linkManifest());

    // Check that rel=manifest actually matters.
    link->setAttribute(blink::HTMLNames::relAttr, "");
    EXPECT_EQ(link2, document().linkManifest());
    link->setAttribute(blink::HTMLNames::relAttr, "manifest");

    // Check that link outside of the <head> are ignored.
    document().head()->removeChild(link, ASSERT_NO_EXCEPTION);
    document().head()->removeChild(link2, ASSERT_NO_EXCEPTION);
    EXPECT_EQ(0, document().linkManifest());
    document().body()->appendChild(link);
    EXPECT_EQ(0, document().linkManifest());
    document().head()->appendChild(link);
    document().head()->appendChild(link2);

    // Check that some attribute values do not have an effect.
    link->setAttribute(blink::HTMLNames::crossoriginAttr, "use-credentials");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::hreflangAttr, "klingon");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::typeAttr, "image/gif");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::sizesAttr, "16x16");
    EXPECT_EQ(link, document().linkManifest());
    link->setAttribute(blink::HTMLNames::mediaAttr, "print");
    EXPECT_EQ(link, document().linkManifest());
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:71,代码来源:DocumentTest.cpp

示例4: setJSHTMLLinkElementType

void setJSHTMLLinkElementType(ExecState* exec, JSObject* thisObject, JSValue value)
{
    JSHTMLLinkElement* castedThis = static_cast<JSHTMLLinkElement*>(thisObject);
    HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(castedThis->impl());
    imp->setAttribute(WebCore::HTMLNames::typeAttr, valueToStringWithNullCheck(exec, value));
}
开发者ID:13W,项目名称:phantomjs,代码行数:6,代码来源:JSHTMLLinkElement.cpp


注:本文中的HTMLLinkElement::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。