| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); | 368 std::string content = webViewHelper.webView()->mainFrame()->contentAsText(10
24).utf8(); |
| 369 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 369 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
| 370 } | 370 } |
| 371 | 371 |
| 372 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 372 class CSSCallbackWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 373 public: | 373 public: |
| 374 CSSCallbackWebFrameClient() : m_updateCount(0) { } | 374 CSSCallbackWebFrameClient() : m_updateCount(0) { } |
| 375 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) override; | 375 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) override; |
| 376 | 376 |
| 377 std::map<WebLocalFrame*, std::set<std::string> > m_matchedSelectors; | 377 std::map<WebLocalFrame*, std::set<std::string>> m_matchedSelectors; |
| 378 int m_updateCount; | 378 int m_updateCount; |
| 379 }; | 379 }; |
| 380 | 380 |
| 381 void CSSCallbackWebFrameClient::didMatchCSS(WebLocalFrame* frame, const WebVecto
r<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchin
gSelectors) | 381 void CSSCallbackWebFrameClient::didMatchCSS(WebLocalFrame* frame, const WebVecto
r<WebString>& newlyMatchingSelectors, const WebVector<WebString>& stoppedMatchin
gSelectors) |
| 382 { | 382 { |
| 383 ++m_updateCount; | 383 ++m_updateCount; |
| 384 std::set<std::string>& frameSelectors = m_matchedSelectors[frame]; | 384 std::set<std::string>& frameSelectors = m_matchedSelectors[frame]; |
| 385 for (size_t i = 0; i < newlyMatchingSelectors.size(); ++i) { | 385 for (size_t i = 0; i < newlyMatchingSelectors.size(); ++i) { |
| 386 std::string selector = newlyMatchingSelectors[i].utf8(); | 386 std::string selector = newlyMatchingSelectors[i].utf8(); |
| 387 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; | 387 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; |
| 388 frameSelectors.insert(selector); | 388 frameSelectors.insert(selector); |
| 389 } | 389 } |
| 390 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { | 390 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { |
| 391 std::string selector = stoppedMatchingSelectors[i].utf8(); | 391 std::string selector = stoppedMatchingSelectors[i].utf8(); |
| 392 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; | 392 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; |
| 393 frameSelectors.erase(selector); | 393 frameSelectors.erase(selector); |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 | 396 |
| 397 class WebFrameCSSCallbackTest : public testing::Test { | 397 class WebFrameCSSCallbackTest : public testing::Test { |
| 398 protected: | 398 protected: |
| 399 WebFrameCSSCallbackTest() | 399 WebFrameCSSCallbackTest() |
| 400 { | 400 { |
| 401 | |
| 402 m_frame = m_helper.initializeAndLoad("about:blank", true, &m_client)->ma
inFrame()->toWebLocalFrame(); | 401 m_frame = m_helper.initializeAndLoad("about:blank", true, &m_client)->ma
inFrame()->toWebLocalFrame(); |
| 403 } | 402 } |
| 404 | 403 |
| 405 ~WebFrameCSSCallbackTest() | 404 ~WebFrameCSSCallbackTest() |
| 406 { | 405 { |
| 407 EXPECT_EQ(1U, m_client.m_matchedSelectors.size()); | 406 EXPECT_EQ(1U, m_client.m_matchedSelectors.size()); |
| 408 } | 407 } |
| 409 | 408 |
| 410 WebDocument doc() const | 409 WebDocument doc() const |
| 411 { | 410 { |
| (...skipping 5495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5907 | 5906 |
| 5908 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), FrameLoadTypeBackForward, HistorySameDocumentLoad); | 5907 toLocalFrame(webViewImpl->page()->mainFrame())->loader().loadHistoryItem(ite
m.get(), FrameLoadTypeBackForward, HistorySameDocumentLoad); |
| 5909 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 5908 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
| 5910 } | 5909 } |
| 5911 | 5910 |
| 5912 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5911 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 5913 public: | 5912 public: |
| 5914 TestHistoryWebFrameClient() | 5913 TestHistoryWebFrameClient() |
| 5915 { | 5914 { |
| 5916 m_replacesCurrentHistoryItem = false; | 5915 m_replacesCurrentHistoryItem = false; |
| 5917 m_frame = 0; | 5916 m_frame = nullptr; |
| 5918 } | 5917 } |
| 5919 | 5918 |
| 5920 void didStartProvisionalLoad(WebLocalFrame* frame, bool isTransitionNavigati
on, double) | 5919 void didStartProvisionalLoad(WebLocalFrame* frame, bool isTransitionNavigati
on, double) |
| 5921 { | 5920 { |
| 5922 WebDataSource* ds = frame->provisionalDataSource(); | 5921 WebDataSource* ds = frame->provisionalDataSource(); |
| 5923 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 5922 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); |
| 5924 m_frame = frame; | 5923 m_frame = frame; |
| 5925 } | 5924 } |
| 5926 | 5925 |
| 5927 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } | 5926 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6924 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6923 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6925 | 6924 |
| 6926 // Neither should a page reload. | 6925 // Neither should a page reload. |
| 6927 localFrame->reload(); | 6926 localFrame->reload(); |
| 6928 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6927 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 6929 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6928 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 6930 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6929 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 6931 } | 6930 } |
| 6932 | 6931 |
| 6933 } // namespace | 6932 } // namespace |
| OLD | NEW |