static v8::Handle<v8::Value> contentDocumentAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLIFrameElement.contentDocument._get"); HTMLIFrameElement* imp = V8HTMLIFrameElement::toNative(info.Holder()); if (!V8BindingSecurity::checkNodeSecurity(V8BindingState::Only(), imp->contentDocument())) return v8::Handle<v8::Value>(); return toV8(imp->contentDocument()); }
TEST_F(FrameThrottlingTest, HiddenSameOriginFramesAreNotThrottled) { SimRequest mainResource("https://example.com/", "text/html"); SimRequest frameResource("https://example.com/iframe.html", "text/html"); loadURL("https://example.com/"); mainResource.complete("<iframe id=frame src=iframe.html></iframe>"); frameResource.complete("<iframe id=innerFrame></iframe>"); auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")); auto* frameDocument = frameElement->contentDocument(); HTMLIFrameElement* innerFrameElement = toHTMLIFrameElement(frameDocument->getElementById("innerFrame")); auto* innerFrameDocument = innerFrameElement->contentDocument(); EXPECT_FALSE(document().view()->canThrottleRendering()); EXPECT_FALSE(frameDocument->view()->canThrottleRendering()); EXPECT_FALSE(innerFrameDocument->view()->canThrottleRendering()); // Hidden same origin frames are not throttled. frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); compositeFrame(); EXPECT_FALSE(document().view()->canThrottleRendering()); EXPECT_FALSE(frameDocument->view()->canThrottleRendering()); EXPECT_FALSE(innerFrameDocument->view()->canThrottleRendering()); }
JSValue* JSHTMLIFrameElement::getValueProperty(ExecState* exec, int token) const { switch (token) { case AlignAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->align()); } case FrameBorderAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->frameBorder()); } case HeightAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->height()); } case LongDescAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->longDesc()); } case MarginHeightAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->marginHeight()); } case MarginWidthAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->marginWidth()); } case NameAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->name()); } case ScrollingAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->scrolling()); } case SrcAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->src()); } case WidthAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return jsString(exec, imp->width()); } case ContentDocumentAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return checkNodeSecurity(exec, imp->contentDocument()) ? toJS(exec, WTF::getPtr(imp->contentDocument())) : jsUndefined(); } case ContentWindowAttrNum: { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); return toJS(exec, WTF::getPtr(imp->contentWindow())); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue* value) { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); String srcValue = valueToStringWithNullCheck(exec, value); if (protocolIs(parseURL(srcValue), "javascript")) { if (!checkNodeSecurity(exec, imp->contentDocument())) return; } imp->setSrc(srcValue); }
void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue value) { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); String srcValue = valueToStringWithNullCheck(exec, value); if (protocolIsJavaScript(deprecatedParseURL(srcValue))) { Document* contentDocument = imp->contentDocument(); if (contentDocument && !checkNodeSecurity(exec, contentDocument)) return; } imp->setAttribute(srcAttr, srcValue); }
JSValue jsHTMLIFrameElementContentDocument(ExecState* exec, JSValue slotBase, const Identifier&) { JSHTMLIFrameElement* castedThis = static_cast<JSHTMLIFrameElement*>(asObject(slotBase)); HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(castedThis->impl()); return checkNodeSecurity(exec, imp->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->contentDocument())) : jsUndefined(); }