| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1270 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 1271 public: | 1271 public: |
| 1272 PrintWebViewClient() | 1272 PrintWebViewClient() |
| 1273 : m_printCalled(false) | 1273 : m_printCalled(false) |
| 1274 { | 1274 { |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 // WebViewClient methods | 1277 // WebViewClient methods |
| 1278 virtual void printPage(WebLocalFrame*) override | 1278 void printPage(WebLocalFrame*) override |
| 1279 { | 1279 { |
| 1280 m_printCalled = true; | 1280 m_printCalled = true; |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 bool printCalled() const { return m_printCalled; } | 1283 bool printCalled() const { return m_printCalled; } |
| 1284 | 1284 |
| 1285 private: | 1285 private: |
| 1286 bool m_printCalled; | 1286 bool m_printCalled; |
| 1287 }; | 1287 }; |
| 1288 | 1288 |
| 1289 | 1289 |
| 1290 TEST_F(WebViewTest, PrintWithXHRInFlight) | 1290 TEST_F(WebViewTest, PrintWithXHRInFlight) |
| 1291 { | 1291 { |
| 1292 PrintWebViewClient client; | 1292 PrintWebViewClient client; |
| 1293 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); | 1293 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("print_with_xhr_inflight.html")); |
| 1294 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); | 1294 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "pr
int_with_xhr_inflight.html", true, 0, &client); |
| 1295 | 1295 |
| 1296 ASSERT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame())->document()->load
EventFinished()); | 1296 ASSERT_TRUE(toLocalFrame(webViewImpl->page()->mainFrame())->document()->load
EventFinished()); |
| 1297 EXPECT_TRUE(client.printCalled()); | 1297 EXPECT_TRUE(client.printCalled()); |
| 1298 m_webViewHelper.reset(); | 1298 m_webViewHelper.reset(); |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 class DropTask : public WebThread::Task { | 1301 class DropTask : public WebThread::Task { |
| 1302 public: | 1302 public: |
| 1303 explicit DropTask(WebView* webView) : m_webView(webView) | 1303 explicit DropTask(WebView* webView) : m_webView(webView) |
| 1304 { | 1304 { |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 virtual void run() override | 1307 void run() override |
| 1308 { | 1308 { |
| 1309 const WebPoint clientPoint(0, 0); | 1309 const WebPoint clientPoint(0, 0); |
| 1310 const WebPoint screenPoint(0, 0); | 1310 const WebPoint screenPoint(0, 0); |
| 1311 m_webView->dragTargetDrop(clientPoint, screenPoint, 0); | 1311 m_webView->dragTargetDrop(clientPoint, screenPoint, 0); |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 private: | 1314 private: |
| 1315 WebView* const m_webView; | 1315 WebView* const m_webView; |
| 1316 }; | 1316 }; |
| 1317 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) | 1317 static void DragAndDropURL(WebViewImpl* webView, const std::string& url) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 | 1357 |
| 1358 // Attempt to drag and drop to barUrl and verify that no navigation has occu
rred. | 1358 // Attempt to drag and drop to barUrl and verify that no navigation has occu
rred. |
| 1359 DragAndDropURL(webView, barUrl); | 1359 DragAndDropURL(webView, barUrl); |
| 1360 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); | 1360 EXPECT_EQ(fooUrl, webView->mainFrame()->document().url().string().utf8()); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { | 1363 class ContentDetectorClient : public FrameTestHelpers::TestWebViewClient { |
| 1364 public: | 1364 public: |
| 1365 ContentDetectorClient() { reset(); } | 1365 ContentDetectorClient() { reset(); } |
| 1366 | 1366 |
| 1367 virtual WebContentDetectionResult detectContentAround(const WebHitTestResult
& hitTest) override | 1367 WebContentDetectionResult detectContentAround(const WebHitTestResult& hitTes
t) override |
| 1368 { | 1368 { |
| 1369 m_contentDetectionRequested = true; | 1369 m_contentDetectionRequested = true; |
| 1370 return m_contentDetectionResult; | 1370 return m_contentDetectionResult; |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 virtual void scheduleContentIntent(const WebURL& url) override | 1373 void scheduleContentIntent(const WebURL& url) override |
| 1374 { | 1374 { |
| 1375 m_scheduledIntentURL = url; | 1375 m_scheduledIntentURL = url; |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 virtual void cancelScheduledContentIntents() override | 1378 void cancelScheduledContentIntents() override |
| 1379 { | 1379 { |
| 1380 m_pendingIntentsCancelled = true; | 1380 m_pendingIntentsCancelled = true; |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 void reset() | 1383 void reset() |
| 1384 { | 1384 { |
| 1385 m_contentDetectionRequested = false; | 1385 m_contentDetectionRequested = false; |
| 1386 m_pendingIntentsCancelled = false; | 1386 m_pendingIntentsCancelled = false; |
| 1387 m_scheduledIntentURL = WebURL(); | 1387 m_scheduledIntentURL = WebURL(); |
| 1388 m_contentDetectionResult = WebContentDetectionResult(); | 1388 m_contentDetectionResult = WebContentDetectionResult(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 webViewImpl->handleInputEvent(event); | 1602 webViewImpl->handleInputEvent(event); |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 class MockAutofillClient : public WebAutofillClient { | 1605 class MockAutofillClient : public WebAutofillClient { |
| 1606 public: | 1606 public: |
| 1607 MockAutofillClient() | 1607 MockAutofillClient() |
| 1608 : m_ignoreTextChanges(false) | 1608 : m_ignoreTextChanges(false) |
| 1609 , m_textChangesFromUserGesture(0) | 1609 , m_textChangesFromUserGesture(0) |
| 1610 , m_textChangesWhileIgnored(0) | 1610 , m_textChangesWhileIgnored(0) |
| 1611 , m_textChangesWhileNotIgnored(0) | 1611 , m_textChangesWhileNotIgnored(0) |
| 1612 , m_userGestureNotificationsCount(0) { } | 1612 , m_userGestureNotificationsCount(0) {} |
| 1613 | 1613 |
| 1614 virtual ~MockAutofillClient() { } | 1614 ~MockAutofillClient() override {} |
| 1615 | 1615 |
| 1616 virtual void setIgnoreTextChanges(bool ignore) override { m_ignoreTextChange
s = ignore; } | 1616 void setIgnoreTextChanges(bool ignore) override { m_ignoreTextChanges = igno
re; } |
| 1617 virtual void textFieldDidChange(const WebFormControlElement&) override | 1617 void textFieldDidChange(const WebFormControlElement&) override |
| 1618 { | 1618 { |
| 1619 if (m_ignoreTextChanges) | 1619 if (m_ignoreTextChanges) |
| 1620 ++m_textChangesWhileIgnored; | 1620 ++m_textChangesWhileIgnored; |
| 1621 else | 1621 else |
| 1622 ++m_textChangesWhileNotIgnored; | 1622 ++m_textChangesWhileNotIgnored; |
| 1623 | 1623 |
| 1624 if (UserGestureIndicator::processingUserGesture()) | 1624 if (UserGestureIndicator::processingUserGesture()) |
| 1625 ++m_textChangesFromUserGesture; | 1625 ++m_textChangesFromUserGesture; |
| 1626 } | 1626 } |
| 1627 virtual void firstUserGestureObserved() override { ++m_userGestureNotificati
onsCount; } | 1627 void firstUserGestureObserved() override { ++m_userGestureNotificationsCount
; } |
| 1628 | 1628 |
| 1629 void clearChangeCounts() | 1629 void clearChangeCounts() |
| 1630 { | 1630 { |
| 1631 m_textChangesWhileIgnored = 0; | 1631 m_textChangesWhileIgnored = 0; |
| 1632 m_textChangesWhileNotIgnored = 0; | 1632 m_textChangesWhileNotIgnored = 0; |
| 1633 } | 1633 } |
| 1634 | 1634 |
| 1635 int textChangesFromUserGesture() { return m_textChangesFromUserGesture; } | 1635 int textChangesFromUserGesture() { return m_textChangesFromUserGesture; } |
| 1636 int textChangesWhileIgnored() { return m_textChangesWhileIgnored; } | 1636 int textChangesWhileIgnored() { return m_textChangesWhileIgnored; } |
| 1637 int textChangesWhileNotIgnored() { return m_textChangesWhileNotIgnored; } | 1637 int textChangesWhileNotIgnored() { return m_textChangesWhileNotIgnored; } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1804 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 1805 public: | 1805 public: |
| 1806 ViewCreatingWebViewClient() | 1806 ViewCreatingWebViewClient() |
| 1807 : m_didFocusCalled(false) | 1807 : m_didFocusCalled(false) |
| 1808 { | 1808 { |
| 1809 } | 1809 } |
| 1810 | 1810 |
| 1811 // WebViewClient methods | 1811 // WebViewClient methods |
| 1812 virtual WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebW
indowFeatures&, const WebString& name, WebNavigationPolicy, bool) override | 1812 WebView* createView(WebLocalFrame*, const WebURLRequest&, const WebWindowFea
tures&, const WebString& name, WebNavigationPolicy, bool) override |
| 1813 { | 1813 { |
| 1814 return m_webViewHelper.initialize(true, 0, 0); | 1814 return m_webViewHelper.initialize(true, 0, 0); |
| 1815 } | 1815 } |
| 1816 | 1816 |
| 1817 // WebWidgetClient methods | 1817 // WebWidgetClient methods |
| 1818 virtual void didFocus() override | 1818 void didFocus() override |
| 1819 { | 1819 { |
| 1820 m_didFocusCalled = true; | 1820 m_didFocusCalled = true; |
| 1821 } | 1821 } |
| 1822 | 1822 |
| 1823 bool didFocusCalled() const { return m_didFocusCalled; } | 1823 bool didFocusCalled() const { return m_didFocusCalled; } |
| 1824 WebView* createdWebView() const { return m_webViewHelper.webView(); } | 1824 WebView* createdWebView() const { return m_webViewHelper.webView(); } |
| 1825 | 1825 |
| 1826 private: | 1826 private: |
| 1827 FrameTestHelpers::WebViewHelper m_webViewHelper; | 1827 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 1828 bool m_didFocusCalled; | 1828 bool m_didFocusCalled; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 webView->layout(); | 2083 webView->layout(); |
| 2084 WebRect cropRect(0, 0, 100, 100); | 2084 WebRect cropRect(0, 0, 100, 100); |
| 2085 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 2085 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); |
| 2086 EXPECT_STREQ("", clipText.utf8().c_str()); | 2086 EXPECT_STREQ("", clipText.utf8().c_str()); |
| 2087 EXPECT_STREQ("", clipHtml.utf8().c_str()); | 2087 EXPECT_STREQ("", clipHtml.utf8().c_str()); |
| 2088 } | 2088 } |
| 2089 | 2089 |
| 2090 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien
t { | 2090 class CreateChildCounterFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
| 2091 public: | 2091 public: |
| 2092 CreateChildCounterFrameClient() : m_count(0) { } | 2092 CreateChildCounterFrameClient() : m_count(0) { } |
| 2093 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType,
const WebString& frameName, WebSandboxFlags) override; | 2093 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType, const We
bString& frameName, WebSandboxFlags) override; |
| 2094 | 2094 |
| 2095 int count() const { return m_count; } | 2095 int count() const { return m_count; } |
| 2096 | 2096 |
| 2097 private: | 2097 private: |
| 2098 int m_count; | 2098 int m_count; |
| 2099 }; | 2099 }; |
| 2100 | 2100 |
| 2101 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent,
WebTreeScopeType scope, const WebString& frameName, WebSandboxFlags sandboxFlag
s) | 2101 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent,
WebTreeScopeType scope, const WebString& frameName, WebSandboxFlags sandboxFlag
s) |
| 2102 { | 2102 { |
| 2103 ++m_count; | 2103 ++m_count; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); | 2156 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("add_frame_in_unload.html")); |
| 2157 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload_wrapper.h
tml", true, &frameClient); | 2157 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload_wrapper.h
tml", true, &frameClient); |
| 2158 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); | 2158 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), "about:b
lank"); |
| 2159 EXPECT_EQ(1, frameClient.count()); | 2159 EXPECT_EQ(1, frameClient.count()); |
| 2160 m_webViewHelper.reset(); | 2160 m_webViewHelper.reset(); |
| 2161 } | 2161 } |
| 2162 | 2162 |
| 2163 class TouchEventHandlerWebViewClient : public FrameTestHelpers::TestWebViewClien
t { | 2163 class TouchEventHandlerWebViewClient : public FrameTestHelpers::TestWebViewClien
t { |
| 2164 public: | 2164 public: |
| 2165 // WebWidgetClient methods | 2165 // WebWidgetClient methods |
| 2166 virtual void hasTouchEventHandlers(bool state) override | 2166 void hasTouchEventHandlers(bool state) override |
| 2167 { | 2167 { |
| 2168 m_hasTouchEventHandlerCount[state]++; | 2168 m_hasTouchEventHandlerCount[state]++; |
| 2169 } | 2169 } |
| 2170 | 2170 |
| 2171 // Local methods | 2171 // Local methods |
| 2172 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() | 2172 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() |
| 2173 { | 2173 { |
| 2174 } | 2174 } |
| 2175 | 2175 |
| 2176 int getAndResetHasTouchEventHandlerCallCount(bool state) | 2176 int getAndResetHasTouchEventHandlerCallCount(bool state) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 Heap::collectAllGarbage(); | 2334 Heap::collectAllGarbage(); |
| 2335 #endif | 2335 #endif |
| 2336 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); | 2336 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); |
| 2337 } | 2337 } |
| 2338 | 2338 |
| 2339 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { | 2339 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView
Client { |
| 2340 public: | 2340 public: |
| 2341 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } | 2341 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } |
| 2342 | 2342 |
| 2343 // WebWidgetClient methods | 2343 // WebWidgetClient methods |
| 2344 virtual void didUpdateTextOfFocusedElementByNonUserInput() override | 2344 void didUpdateTextOfFocusedElementByNonUserInput() override |
| 2345 { | 2345 { |
| 2346 m_textIsUpdated = true; | 2346 m_textIsUpdated = true; |
| 2347 } | 2347 } |
| 2348 | 2348 |
| 2349 void reset() | 2349 void reset() |
| 2350 { | 2350 { |
| 2351 m_textIsUpdated = false; | 2351 m_textIsUpdated = false; |
| 2352 } | 2352 } |
| 2353 | 2353 |
| 2354 bool textIsUpdated() const | 2354 bool textIsUpdated() const |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 webView = m_webViewHelper.initializeAndLoad(url, true); | 2634 webView = m_webViewHelper.initializeAndLoad(url, true); |
| 2635 | 2635 |
| 2636 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1)); | 2636 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1)); |
| 2637 size = webView->contentsPreferredMinimumSize(); | 2637 size = webView->contentsPreferredMinimumSize(); |
| 2638 EXPECT_EQ(2, size.width); | 2638 EXPECT_EQ(2, size.width); |
| 2639 EXPECT_EQ(2, size.height); | 2639 EXPECT_EQ(2, size.height); |
| 2640 } | 2640 } |
| 2641 | 2641 |
| 2642 class UnhandledTapWebViewClient : public FrameTestHelpers::TestWebViewClient { | 2642 class UnhandledTapWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 2643 public: | 2643 public: |
| 2644 virtual void showUnhandledTapUIIfNeeded(const WebPoint& tappedPosition, cons
t WebNode& tappedNode, bool pageChanged) override | 2644 void showUnhandledTapUIIfNeeded(const WebPoint& tappedPosition, const WebNod
e& tappedNode, bool pageChanged) override |
| 2645 { | 2645 { |
| 2646 m_wasCalled = true; | 2646 m_wasCalled = true; |
| 2647 m_tappedPosition = tappedPosition; | 2647 m_tappedPosition = tappedPosition; |
| 2648 m_tappedNode = tappedNode; | 2648 m_tappedNode = tappedNode; |
| 2649 m_pageChanged = pageChanged; | 2649 m_pageChanged = pageChanged; |
| 2650 } | 2650 } |
| 2651 bool getWasCalled() const { return m_wasCalled; } | 2651 bool getWasCalled() const { return m_wasCalled; } |
| 2652 int getTappedXPos() const { return m_tappedPosition.x(); } | 2652 int getTappedXPos() const { return m_tappedPosition.x(); } |
| 2653 int getTappedYPos() const { return m_tappedPosition.y(); } | 2653 int getTappedYPos() const { return m_tappedPosition.y(); } |
| 2654 bool isTappedNodeNull() const { return m_tappedNode.isNull(); } | 2654 bool isTappedNodeNull() const { return m_tappedNode.isNull(); } |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 for (size_t i = 0; i < renders.size(); ++i) { | 3043 for (size_t i = 0; i < renders.size(); ++i) { |
| 3044 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3044 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
| 3045 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3045 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
| 3046 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3046 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
| 3047 double docDuration = docFinishTime - docStartTime; | 3047 double docDuration = docFinishTime - docStartTime; |
| 3048 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3048 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
| 3049 } | 3049 } |
| 3050 } | 3050 } |
| 3051 | 3051 |
| 3052 } // namespace blink | 3052 } // namespace blink |
| OLD | NEW |