コード例 #1
0
TEST_F(WebEmbeddedWorkerImplTest, ScriptNotFound)
{
    WebURL scriptURL = URLTestHelpers::toKURL("https://www.example.com/sw-404.js");
    WebURLResponse response;
    response.initialize();
    response.setMIMEType("text/javascript");
    response.setHTTPStatusCode(404);
    WebURLError error;
    error.reason = 1010;
    error.domain = "WebEmbeddedWorkerImplTest";
    Platform::current()->unitTestSupport()->registerMockedErrorURL(scriptURL, response, error);
    m_startData.scriptURL = scriptURL;

    EXPECT_CALL(*m_mockClient, workerReadyForInspection())
        .Times(1);
    m_worker->startWorkerContext(m_startData);
    ::testing::Mock::VerifyAndClearExpectations(m_mockClient);

    // Load the shadow page.
    EXPECT_CALL(*m_mockClient, createServiceWorkerNetworkProvider(::testing::_))
        .WillOnce(::testing::Return(nullptr));
    Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
    ::testing::Mock::VerifyAndClearExpectations(m_mockClient);

    // Load the script.
    EXPECT_CALL(*m_mockClient, workerScriptLoaded())
        .Times(0);
    EXPECT_CALL(*m_mockClient, createServiceWorkerProvider())
        .Times(0);
    EXPECT_CALL(*m_mockClient, workerContextFailedToStart())
        .Times(1);
    Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
    ::testing::Mock::VerifyAndClearExpectations(m_mockClient);
}
コード例 #2
0
 KURL RegisterMockedUrl(const std::string& urlRoot, const WTF::String& filename)
 {
     WebURLResponse response;
     response.initialize();
     response.setMIMEType("text/html");
     WTF::String localPath = m_baseFilePath;
     localPath.append(filename);
     KURL url = toKURL(urlRoot + filename.utf8().data());
     Platform::current()->unitTestSupport()->registerMockedURL(url, response, localPath);
     return url;
 }
コード例 #3
0
    void registerErrorURL(const char* file, int statusCode)
    {
        WebURLError error;
        error.reason = 0xdead + statusCode;
        error.domain = "PageSerializerTest";

        WebURLResponse response;
        response.initialize();
        response.setMIMEType("text/html");
        response.setHTTPStatusCode(statusCode);

        Platform::current()->unitTestSupport()->registerMockedErrorURL(KURL(m_baseUrl, file), response, error);
    }