// WebURLLoaderTestDelegate overrides: void didReceiveData(WebURLLoaderClient* originalClient, WebURLLoader* loader, const char* data, int dataLength, int encodedDataLength) override { EXPECT_EQ(34, dataLength) << "foo.html was not served in a single chunk"; m_loaderClient = originalClient; m_loader = loader; for (int i = 0; i < dataLength; ++i) m_data.push(data[i]); { // Serve the first byte to the real WebURLLoaderCLient, which // should trigger frameDetach() due to committing a provisional // load. TemporaryChange<bool> dispatching(m_dispatchingDidReceiveData, true); dispatchOneByte(); } // Serve the remaining bytes to complete the load. EXPECT_FALSE(m_data.empty()); while (!m_data.empty()) dispatchOneByte(); }
// WebFrameClient overrides: void frameDetached(WebLocalFrame* frame, DetachType detachType) override { if (m_dispatchingDidReceiveData) { // This should be called by the first didReceiveData() call, since // it should commit the provisional load. EXPECT_GT(m_data.size(), 10u); // Dispatch dataReceived() callbacks for part of the remaining // data, saving the rest to be dispatched at the top-level as // normal. while (m_data.size() > 10) dispatchOneByte(); m_servedReentrantly = true; } TestWebFrameClient::frameDetached(frame, detachType); }