TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints) { expectHeader("http://www.example.com/1.gif", "Width", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendResourceWidth(true); document->setClientHintsPreferences(preferences); expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500); expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666); expectHeader("http://www.example.com/1.gif", "DPR", false, ""); }
TEST_F(FrameFetchContextHintsTest, MonitorDPRHints) { expectHeader("http://www.example.com/1.gif", "DPR", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendDPR(true); document->setClientHintsPreferences(preferences); expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); dummyPageHolder->page().setDeviceScaleFactor(2.5); expectHeader("http://www.example.com/1.gif", "DPR", true, "2.5"); expectHeader("http://www.example.com/1.gif", "RW", false, ""); }
TEST_F(FrameFetchContextHintsTest, MonitorBothHints) { expectHeader("http://www.example.com/1.gif", "DPR", false, ""); expectHeader("http://www.example.com/1.gif", "RW", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendDPR(true); preferences.setShouldSendRW(true); document->setClientHintsPreferences(preferences); expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); expectHeader("http://www.example.com/1.gif", "RW", true, "500"); }
TEST_F(FrameFetchContextHintsTest, MonitorRWHints) { expectHeader("http://www.example.com/1.gif", "RW", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendRW(true); document->setClientHintsPreferences(preferences); expectHeader("http://www.example.com/1.gif", "RW", true, "500"); dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false); dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800)); expectHeader("http://www.example.com/1.gif", "RW", true, "800"); expectHeader("http://www.example.com/1.gif", "DPR", false, ""); }
TEST_F(FrameFetchContextHintsTest, MonitorViewportWidthHints) { expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendViewportWidth(true); document->clientHintsPreferences().updateFrom(preferences); expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); dummyPageHolder->frameView().setLayoutSizeFixedToFrameSize(false); dummyPageHolder->frameView().setLayoutSize(IntSize(800, 800)); expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800"); expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "800", 666.6666); expectHeader("http://www.example.com/1.gif", "DPR", false, ""); }
TEST_F(FrameFetchContextHintsTest, MonitorResourceWidthHints) { expectHeader("http://www.example.com/1.gif", "Width", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendResourceWidth(true); document->clientHintsPreferences().updateFrom(preferences); expectHeader("http://www.example.com/1.gif", "Width", true, "500", 500); expectHeader("http://www.example.com/1.gif", "Width", true, "667", 666.6666); expectHeader("http://www.example.com/1.gif", "DPR", false, ""); dummyPageHolder->page().setDeviceScaleFactor(2.5); expectHeader("http://www.example.com/1.gif", "Width", true, "1250", 500); expectHeader("http://www.example.com/1.gif", "Width", true, "1667", 666.6666); }
TEST_F(FrameFetchContextHintsTest, MonitorAllHints) { expectHeader("http://www.example.com/1.gif", "DPR", false, ""); expectHeader("http://www.example.com/1.gif", "Viewport-Width", false, ""); expectHeader("http://www.example.com/1.gif", "Width", false, ""); ClientHintsPreferences preferences; preferences.setShouldSendDPR(true); preferences.setShouldSendResourceWidth(true); preferences.setShouldSendViewportWidth(true); document->clientHintsPreferences().updateFrom(preferences); expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); expectHeader("http://www.example.com/1.gif", "Width", true, "400", 400); expectHeader("http://www.example.com/1.gif", "Viewport-Width", true, "500"); }