Exemple #1
0
WebURL WebDocument::manifestURL() const {
  const Document* document = constUnwrap<Document>();
  HTMLLinkElement* linkElement = document->linkManifest();
  if (!linkElement)
    return WebURL();
  return linkElement->href();
}
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()));
}
JSValue* JSHTMLLinkElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case DisabledAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsBoolean(imp->disabled());
    }
    case CharsetAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->charset());
    }
    case HrefAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->href());
    }
    case HreflangAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->hreflang());
    }
    case MediaAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->media());
    }
    case RelAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->rel());
    }
    case RevAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->rev());
    }
    case TargetAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->target());
    }
    case TypeAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return jsString(exec, imp->type());
    }
    case SheetAttrNum: {
        HTMLLinkElement* imp = static_cast<HTMLLinkElement*>(impl());
        return toJS(exec, WTF::getPtr(imp->sheet()));
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
void FrameLoaderClientBlackBerry::dispatchDidFinishLoad()
{
    didFinishOrFailLoading(ResourceError());

    if (m_webPagePrivate->m_dumpRenderTree)
        m_webPagePrivate->m_dumpRenderTree->didFinishLoadForFrame(m_frame);

    if (!isMainFrame() || m_webPagePrivate->m_webSettings->isEmailMode()
        || !m_frame->document() || !m_frame->document()->head())
        return;

    HTMLHeadElement* headElement = m_frame->document()->head();
    // FIXME: Handle NOSCRIPT special case?

    // Process document metadata.
    RefPtr<NodeList> nodeList = headElement->getElementsByTagName(HTMLNames::metaTag.localName());
    unsigned int size = nodeList->length();
    ScopeArray<WebString> headers;

    // This may allocate more space than needed since not all meta elements will be http-equiv.
    headers.reset(new WebString[2 * size]);
    unsigned headersLength = 0;

    for (unsigned i = 0; i < size; ++i) {
        HTMLMetaElement* metaElement = static_cast<HTMLMetaElement*>(nodeList->item(i));
        if (WTF::equalIgnoringCase(metaElement->name(), "apple-mobile-web-app-capable")
            && WTF::equalIgnoringCase(metaElement->content().stripWhiteSpace(), "yes"))
            m_webPagePrivate->m_client->setWebAppCapable();
        else {
            String httpEquiv = metaElement->httpEquiv().stripWhiteSpace();
            String content = metaElement->content().stripWhiteSpace();

            if (!httpEquiv.isNull() && !content.isNull()) {
                headers[headersLength++] = httpEquiv;
                headers[headersLength++] = content;
            }
        }
    }

    if (headersLength > 0)
        m_webPagePrivate->m_client->setMetaHeaders(headers, headersLength);

    nodeList = headElement->getElementsByTagName(HTMLNames::linkTag.localName());
    size = nodeList->length();

    for (unsigned i = 0; i < size; ++i) {
        HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(nodeList->item(i));
        String href = linkElement->href().string();
        if (!href.isEmpty()) {
            String title = linkElement->title();

            if (WTF::equalIgnoringCase(linkElement->rel(), "apple-touch-icon"))
                m_webPagePrivate->m_client->setLargeIcon(href.latin1().data());
            else if (WTF::equalIgnoringCase(linkElement->rel(), "search")) {
                if (WTF::equalIgnoringCase(linkElement->type(), "application/opensearchdescription+xml"))
                    m_webPagePrivate->m_client->setSearchProviderDetails(title.utf8().data(), href.utf8().data());
            } else if (WTF::equalIgnoringCase(linkElement->rel(), "alternate")
                && (WTF::equalIgnoringCase(linkElement->type(), "application/rss+xml")
                || WTF::equalIgnoringCase(linkElement->type(), "application/atom+xml")))
                m_webPagePrivate->m_client->setAlternateFeedDetails(title.utf8().data(), href.utf8().data());
        }
    }

#if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
    if (!m_webPagePrivate->m_webSettings->isPrivateBrowsingEnabled())
        credentialManager().autofillPasswordForms(m_frame->document()->forms());
#endif
}