static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorldBehavior bypassBehavior, Element& element, const ClientHintsPreferences& clientHintsPreferences) { if (bypassBehavior == ImageLoader::BypassMainWorldCSP) request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); AtomicString crossOriginMode = element.fastGetAttribute(HTMLNames::crossoriginAttr); if (!crossOriginMode.isNull()) request.setCrossOriginAccessControl(element.document().securityOrigin(), crossOriginMode); if (clientHintsPreferences.shouldSendResourceWidth() && isHTMLImageElement(element)) request.setResourceWidth(toHTMLImageElement(element).resourceWidth()); }
void expectHeader(const char* input, const char* headerName, bool isPresent, const char* headerValue, float width = 0) { KURL inputURL(ParsedURLString, input); FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), FetchInitiatorInfo()); if (width > 0) { FetchRequest::ResourceWidth resourceWidth; resourceWidth.width = width; resourceWidth.isSet = true; fetchRequest.setResourceWidth(resourceWidth); } fetchContext->addClientHintsIfNecessary(fetchRequest); EXPECT_STREQ(isPresent ? headerValue : "", fetchRequest.resourceRequest().httpHeaderField(headerName).utf8().data()); }