| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 public: | 135 public: |
| 136 void onPrintPage() { m_printedPage = true; } | 136 void onPrintPage() { m_printedPage = true; } |
| 137 bool printedAtLeastOnePage() { return m_printedPage; } | 137 bool printedAtLeastOnePage() { return m_printedPage; } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 bool m_printedPage = false; | 140 bool m_printedPage = false; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 void TestPlugin::printPage(int pageNumber, WebCanvas* canvas) | 143 void TestPlugin::printPage(int pageNumber, WebCanvas* canvas) |
| 144 { | 144 { |
| 145 ASSERT(m_testClient); | 145 DCHECK(m_testClient); |
| 146 m_testClient->onPrintPage(); | 146 m_testClient->onPrintPage(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) | 149 WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id) |
| 150 { | 150 { |
| 151 WebElement element = webView->mainFrame()->document().getElementById(id); | 151 WebElement element = webView->mainFrame()->document().getElementById(id); |
| 152 return element.pluginContainer(); | 152 return element.pluginContainer(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace | 155 } // namespace |
| 156 | 156 |
| 157 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) | 157 TEST_F(WebPluginContainerTest, WindowToLocalPointTest) |
| 158 { | 158 { |
| 159 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 159 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 160 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 160 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 161 FrameTestHelpers::WebViewHelper webViewHelper; | 161 FrameTestHelpers::WebViewHelper webViewHelper; |
| 162 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 162 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 163 ASSERT(webView); | 163 DCHECK(webView); |
| 164 webView->settings()->setPluginsEnabled(true); | 164 webView->settings()->setPluginsEnabled(true); |
| 165 webView->resize(WebSize(300, 300)); | 165 webView->resize(WebSize(300, 300)); |
| 166 webView->updateAllLifecyclePhases(); | 166 webView->updateAllLifecyclePhases(); |
| 167 runPendingTasks(); | 167 runPendingTasks(); |
| 168 | 168 |
| 169 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); | 169 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); |
| 170 ASSERT(pluginContainerOne); | 170 DCHECK(pluginContainerOne); |
| 171 WebPoint point1 = pluginContainerOne->rootFrameToLocalPoint(WebPoint(10, 10)
); | 171 WebPoint point1 = pluginContainerOne->rootFrameToLocalPoint(WebPoint(10, 10)
); |
| 172 ASSERT_EQ(0, point1.x); | 172 ASSERT_EQ(0, point1.x); |
| 173 ASSERT_EQ(0, point1.y); | 173 ASSERT_EQ(0, point1.y); |
| 174 WebPoint point2 = pluginContainerOne->rootFrameToLocalPoint(WebPoint(100, 10
0)); | 174 WebPoint point2 = pluginContainerOne->rootFrameToLocalPoint(WebPoint(100, 10
0)); |
| 175 ASSERT_EQ(90, point2.x); | 175 ASSERT_EQ(90, point2.x); |
| 176 ASSERT_EQ(90, point2.y); | 176 ASSERT_EQ(90, point2.y); |
| 177 | 177 |
| 178 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); | 178 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); |
| 179 ASSERT(pluginContainerTwo); | 179 DCHECK(pluginContainerTwo); |
| 180 WebPoint point3 = pluginContainerTwo->rootFrameToLocalPoint(WebPoint(0, 10))
; | 180 WebPoint point3 = pluginContainerTwo->rootFrameToLocalPoint(WebPoint(0, 10))
; |
| 181 ASSERT_EQ(10, point3.x); | 181 ASSERT_EQ(10, point3.x); |
| 182 ASSERT_EQ(0, point3.y); | 182 ASSERT_EQ(0, point3.y); |
| 183 WebPoint point4 = pluginContainerTwo->rootFrameToLocalPoint(WebPoint(-10, 10
)); | 183 WebPoint point4 = pluginContainerTwo->rootFrameToLocalPoint(WebPoint(-10, 10
)); |
| 184 ASSERT_EQ(10, point4.x); | 184 ASSERT_EQ(10, point4.x); |
| 185 ASSERT_EQ(10, point4.y); | 185 ASSERT_EQ(10, point4.y); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) | 188 TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused) |
| 189 { | 189 { |
| 190 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); | 190 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); |
| 191 | 191 |
| 192 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 192 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 193 FrameTestHelpers::WebViewHelper webViewHelper; | 193 FrameTestHelpers::WebViewHelper webViewHelper; |
| 194 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); | 194 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); |
| 195 ASSERT(webView); | 195 DCHECK(webView); |
| 196 webView->updateAllLifecyclePhases(); | 196 webView->updateAllLifecyclePhases(); |
| 197 | 197 |
| 198 WebDocument document = webView->mainFrame()->document(); | 198 WebDocument document = webView->mainFrame()->document(); |
| 199 EXPECT_TRUE(document.isPluginDocument()); | 199 EXPECT_TRUE(document.isPluginDocument()); |
| 200 WebPluginContainer* pluginContainer = getWebPluginContainer(webView, "plugin
"); | 200 WebPluginContainer* pluginContainer = getWebPluginContainer(webView, "plugin
"); |
| 201 EXPECT_EQ(document.focusedElement(), pluginContainer->element()); | 201 EXPECT_EQ(document.focusedElement(), pluginContainer->element()); |
| 202 } | 202 } |
| 203 | 203 |
| 204 TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) | 204 TEST_F(WebPluginContainerTest, IFramePluginDocumentNotFocused) |
| 205 { | 205 { |
| 206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); | 206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); |
| 207 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("iframe_pdf.html"), WebString::fromUTF8("text/html"
)); | 207 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("iframe_pdf.html"), WebString::fromUTF8("text/html"
)); |
| 208 | 208 |
| 209 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 209 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 210 FrameTestHelpers::WebViewHelper webViewHelper; | 210 FrameTestHelpers::WebViewHelper webViewHelper; |
| 211 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "iframe_pdf.h
tml", true, &pluginWebFrameClient); | 211 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "iframe_pdf.h
tml", true, &pluginWebFrameClient); |
| 212 ASSERT(webView); | 212 DCHECK(webView); |
| 213 webView->updateAllLifecyclePhases(); | 213 webView->updateAllLifecyclePhases(); |
| 214 | 214 |
| 215 WebDocument document = webView->mainFrame()->document(); | 215 WebDocument document = webView->mainFrame()->document(); |
| 216 WebFrame* iframe = webView->mainFrame()->firstChild(); | 216 WebFrame* iframe = webView->mainFrame()->firstChild(); |
| 217 EXPECT_TRUE(iframe->document().isPluginDocument()); | 217 EXPECT_TRUE(iframe->document().isPluginDocument()); |
| 218 WebPluginContainer* pluginContainer = iframe->document().getElementById("plu
gin").pluginContainer(); | 218 WebPluginContainer* pluginContainer = iframe->document().getElementById("plu
gin").pluginContainer(); |
| 219 EXPECT_NE(document.focusedElement(), pluginContainer->element()); | 219 EXPECT_NE(document.focusedElement(), pluginContainer->element()); |
| 220 EXPECT_NE(iframe->document().focusedElement(), pluginContainer->element()); | 220 EXPECT_NE(iframe->document().focusedElement(), pluginContainer->element()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(WebPluginContainerTest, PrintOnePage) | 223 TEST_F(WebPluginContainerTest, PrintOnePage) |
| 224 { | 224 { |
| 225 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); | 225 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); |
| 226 | 226 |
| 227 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 227 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 228 FrameTestHelpers::WebViewHelper webViewHelper; | 228 FrameTestHelpers::WebViewHelper webViewHelper; |
| 229 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); | 229 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); |
| 230 ASSERT(webView); | 230 DCHECK(webView); |
| 231 webView->updateAllLifecyclePhases(); | 231 webView->updateAllLifecyclePhases(); |
| 232 runPendingTasks(); | 232 runPendingTasks(); |
| 233 WebFrame* frame = webView->mainFrame(); | 233 WebFrame* frame = webView->mainFrame(); |
| 234 | 234 |
| 235 WebPrintParams printParams; | 235 WebPrintParams printParams; |
| 236 printParams.printContentArea.width = 500; | 236 printParams.printContentArea.width = 500; |
| 237 printParams.printContentArea.height = 500; | 237 printParams.printContentArea.height = 500; |
| 238 | 238 |
| 239 frame->printBegin(printParams); | 239 frame->printBegin(printParams); |
| 240 SkPictureRecorder recorder; | 240 SkPictureRecorder recorder; |
| 241 frame->printPage(0, recorder.beginRecording(IntRect())); | 241 frame->printPage(0, recorder.beginRecording(IntRect())); |
| 242 frame->printEnd(); | 242 frame->printEnd(); |
| 243 ASSERT(pluginWebFrameClient.printedAtLeastOnePage()); | 243 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(WebPluginContainerTest, PrintAllPages) | 246 TEST_F(WebPluginContainerTest, PrintAllPages) |
| 247 { | 247 { |
| 248 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); | 248 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf")
); |
| 249 | 249 |
| 250 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 250 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 251 FrameTestHelpers::WebViewHelper webViewHelper; | 251 FrameTestHelpers::WebViewHelper webViewHelper; |
| 252 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); | 252 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", t
rue, &pluginWebFrameClient); |
| 253 ASSERT(webView); | 253 DCHECK(webView); |
| 254 webView->updateAllLifecyclePhases(); | 254 webView->updateAllLifecyclePhases(); |
| 255 runPendingTasks(); | 255 runPendingTasks(); |
| 256 WebFrame* frame = webView->mainFrame(); | 256 WebFrame* frame = webView->mainFrame(); |
| 257 | 257 |
| 258 WebPrintParams printParams; | 258 WebPrintParams printParams; |
| 259 printParams.printContentArea.width = 500; | 259 printParams.printContentArea.width = 500; |
| 260 printParams.printContentArea.height = 500; | 260 printParams.printContentArea.height = 500; |
| 261 | 261 |
| 262 frame->printBegin(printParams); | 262 frame->printBegin(printParams); |
| 263 SkPictureRecorder recorder; | 263 SkPictureRecorder recorder; |
| 264 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), WebSize(
)); | 264 frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), WebSize(
)); |
| 265 frame->printEnd(); | 265 frame->printEnd(); |
| 266 ASSERT(pluginWebFrameClient.printedAtLeastOnePage()); | 266 DCHECK(pluginWebFrameClient.printedAtLeastOnePage()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) | 269 TEST_F(WebPluginContainerTest, LocalToWindowPointTest) |
| 270 { | 270 { |
| 271 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 271 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 272 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 272 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 273 FrameTestHelpers::WebViewHelper webViewHelper; | 273 FrameTestHelpers::WebViewHelper webViewHelper; |
| 274 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 274 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 275 ASSERT(webView); | 275 DCHECK(webView); |
| 276 webView->settings()->setPluginsEnabled(true); | 276 webView->settings()->setPluginsEnabled(true); |
| 277 webView->resize(WebSize(300, 300)); | 277 webView->resize(WebSize(300, 300)); |
| 278 webView->updateAllLifecyclePhases(); | 278 webView->updateAllLifecyclePhases(); |
| 279 runPendingTasks(); | 279 runPendingTasks(); |
| 280 | 280 |
| 281 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); | 281 WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebS
tring::fromUTF8("translated-plugin")); |
| 282 ASSERT(pluginContainerOne); | 282 DCHECK(pluginContainerOne); |
| 283 WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0)); | 283 WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0)); |
| 284 ASSERT_EQ(10, point1.x); | 284 ASSERT_EQ(10, point1.x); |
| 285 ASSERT_EQ(10, point1.y); | 285 ASSERT_EQ(10, point1.y); |
| 286 WebPoint point2 = pluginContainerOne->localToRootFramePoint(WebPoint(90, 90)
); | 286 WebPoint point2 = pluginContainerOne->localToRootFramePoint(WebPoint(90, 90)
); |
| 287 ASSERT_EQ(100, point2.x); | 287 ASSERT_EQ(100, point2.x); |
| 288 ASSERT_EQ(100, point2.y); | 288 ASSERT_EQ(100, point2.y); |
| 289 | 289 |
| 290 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); | 290 WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebS
tring::fromUTF8("rotated-plugin")); |
| 291 ASSERT(pluginContainerTwo); | 291 DCHECK(pluginContainerTwo); |
| 292 WebPoint point3 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 0))
; | 292 WebPoint point3 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 0))
; |
| 293 ASSERT_EQ(0, point3.x); | 293 ASSERT_EQ(0, point3.x); |
| 294 ASSERT_EQ(10, point3.y); | 294 ASSERT_EQ(10, point3.y); |
| 295 WebPoint point4 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 10)
); | 295 WebPoint point4 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 10)
); |
| 296 ASSERT_EQ(-10, point4.x); | 296 ASSERT_EQ(-10, point4.x); |
| 297 ASSERT_EQ(10, point4.y); | 297 ASSERT_EQ(10, point4.y); |
| 298 } | 298 } |
| 299 | 299 |
| 300 // Verifies executing the command 'Copy' results in copying to the clipboard. | 300 // Verifies executing the command 'Copy' results in copying to the clipboard. |
| 301 TEST_F(WebPluginContainerTest, Copy) | 301 TEST_F(WebPluginContainerTest, Copy) |
| 302 { | 302 { |
| 303 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 303 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 304 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 304 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 305 FrameTestHelpers::WebViewHelper webViewHelper; | 305 FrameTestHelpers::WebViewHelper webViewHelper; |
| 306 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 306 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 307 ASSERT(webView); | 307 DCHECK(webView); |
| 308 webView->settings()->setPluginsEnabled(true); | 308 webView->settings()->setPluginsEnabled(true); |
| 309 webView->resize(WebSize(300, 300)); | 309 webView->resize(WebSize(300, 300)); |
| 310 webView->updateAllLifecyclePhases(); | 310 webView->updateAllLifecyclePhases(); |
| 311 runPendingTasks(); | 311 runPendingTasks(); |
| 312 | 312 |
| 313 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 313 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 314 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne
Element)); | 314 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne
Element)); |
| 315 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 315 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to | 318 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to |
| 319 // the clipboard. | 319 // the clipboard. |
| 320 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) | 320 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) |
| 321 { | 321 { |
| 322 URLTestHelpers::registerMockedURLFromBaseURL( | 322 URLTestHelpers::registerMockedURLFromBaseURL( |
| 323 WebString::fromUTF8(m_baseURL.c_str()), | 323 WebString::fromUTF8(m_baseURL.c_str()), |
| 324 WebString::fromUTF8("plugin_container.html")); | 324 WebString::fromUTF8("plugin_container.html")); |
| 325 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 325 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 326 FrameTestHelpers::WebViewHelper webViewHelper; | 326 FrameTestHelpers::WebViewHelper webViewHelper; |
| 327 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 327 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 328 ASSERT(webView); | 328 DCHECK(webView); |
| 329 webView->settings()->setPluginsEnabled(true); | 329 webView->settings()->setPluginsEnabled(true); |
| 330 webView->resize(WebSize(300, 300)); | 330 webView->resize(WebSize(300, 300)); |
| 331 webView->updateAllLifecyclePhases(); | 331 webView->updateAllLifecyclePhases(); |
| 332 runPendingTasks(); | 332 runPendingTasks(); |
| 333 | 333 |
| 334 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 334 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 335 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 335 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 336 #if OS(MACOSX) | 336 #if OS(MACOSX) |
| 337 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 337 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 338 #endif | 338 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) | 374 TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) |
| 375 { | 375 { |
| 376 URLTestHelpers::registerMockedURLFromBaseURL( | 376 URLTestHelpers::registerMockedURLFromBaseURL( |
| 377 WebString::fromUTF8(m_baseURL.c_str()), | 377 WebString::fromUTF8(m_baseURL.c_str()), |
| 378 WebString::fromUTF8("plugin_container.html")); | 378 WebString::fromUTF8("plugin_container.html")); |
| 379 CustomPluginWebFrameClient<EventTestPlugin> pluginWebFrameClient; // Must ou
tlive webViewHelper. | 379 CustomPluginWebFrameClient<EventTestPlugin> pluginWebFrameClient; // Must ou
tlive webViewHelper. |
| 380 FrameTestHelpers::WebViewHelper webViewHelper; | 380 FrameTestHelpers::WebViewHelper webViewHelper; |
| 381 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 381 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 382 ASSERT(webView); | 382 DCHECK(webView); |
| 383 webView->settings()->setPluginsEnabled(true); | 383 webView->settings()->setPluginsEnabled(true); |
| 384 webView->resize(WebSize(300, 300)); | 384 webView->resize(WebSize(300, 300)); |
| 385 webView->updateAllLifecyclePhases(); | 385 webView->updateAllLifecyclePhases(); |
| 386 runPendingTasks(); | 386 runPendingTasks(); |
| 387 | 387 |
| 388 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 388 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 389 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(pluginContainerOneE
lement.pluginContainer())->plugin(); | 389 WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(pluginContainerOneE
lement.pluginContainer())->plugin(); |
| 390 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); | 390 EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin); |
| 391 | 391 |
| 392 WebGestureEvent event; | 392 WebGestureEvent event; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 414 EXPECT_EQ(WebInputEvent::GestureLongPress, testPlugin->getLastInputEventType
()); | 414 EXPECT_EQ(WebInputEvent::GestureLongPress, testPlugin->getLastInputEventType
()); |
| 415 } | 415 } |
| 416 | 416 |
| 417 // Verify that isRectTopmost returns false when the document is detached. | 417 // Verify that isRectTopmost returns false when the document is detached. |
| 418 TEST_F(WebPluginContainerTest, IsRectTopmostTest) | 418 TEST_F(WebPluginContainerTest, IsRectTopmostTest) |
| 419 { | 419 { |
| 420 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 420 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 421 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 421 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 422 FrameTestHelpers::WebViewHelper webViewHelper; | 422 FrameTestHelpers::WebViewHelper webViewHelper; |
| 423 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 423 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 424 ASSERT(webView); | 424 DCHECK(webView); |
| 425 webView->settings()->setPluginsEnabled(true); | 425 webView->settings()->setPluginsEnabled(true); |
| 426 webView->resize(WebSize(300, 300)); | 426 webView->resize(WebSize(300, 300)); |
| 427 webView->updateAllLifecyclePhases(); | 427 webView->updateAllLifecyclePhases(); |
| 428 runPendingTasks(); | 428 runPendingTasks(); |
| 429 | 429 |
| 430 RawPtr<WebPluginContainerImpl> pluginContainerImpl = | 430 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 431 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 431 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 432 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 432 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 433 | 433 |
| 434 WebRect rect = pluginContainerImpl->element().boundsInViewport(); | 434 WebRect rect = pluginContainerImpl->element().boundsInViewport(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 450 } while (false) | 450 } while (false) |
| 451 | 451 |
| 452 TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) | 452 TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement) |
| 453 { | 453 { |
| 454 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 454 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 455 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_containing_page.html")); | 455 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_containing_page.html")); |
| 456 | 456 |
| 457 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 457 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 458 FrameTestHelpers::WebViewHelper webViewHelper; | 458 FrameTestHelpers::WebViewHelper webViewHelper; |
| 459 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); | 459 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); |
| 460 ASSERT(webView); | 460 DCHECK(webView); |
| 461 webView->settings()->setPluginsEnabled(true); | 461 webView->settings()->setPluginsEnabled(true); |
| 462 webView->resize(WebSize(300, 300)); | 462 webView->resize(WebSize(300, 300)); |
| 463 webView->updateAllLifecyclePhases(); | 463 webView->updateAllLifecyclePhases(); |
| 464 runPendingTasks(); | 464 runPendingTasks(); |
| 465 | 465 |
| 466 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); | 466 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); |
| 467 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); | 467 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); |
| 468 | 468 |
| 469 ASSERT(pluginContainerImpl.get()); | 469 DCHECK(pluginContainerImpl.get()); |
| 470 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 470 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 471 | 471 |
| 472 IntRect windowRect, clipRect, unobscuredRect; | 472 IntRect windowRect, clipRect, unobscuredRect; |
| 473 Vector<IntRect> cutOutRects; | 473 Vector<IntRect> cutOutRects; |
| 474 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); | 474 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 475 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); | 475 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); |
| 476 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); | 476 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); |
| 477 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); | 477 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); |
| 478 | 478 |
| 479 // Cause the plugin's frame to be detached. | 479 // Cause the plugin's frame to be detached. |
| 480 webViewHelper.reset(); | 480 webViewHelper.reset(); |
| 481 } | 481 } |
| 482 | 482 |
| 483 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) | 483 TEST_F(WebPluginContainerTest, ClippedRectsForSubpixelPositionedPlugin) |
| 484 { | 484 { |
| 485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 486 | 486 |
| 487 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 487 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 488 FrameTestHelpers::WebViewHelper webViewHelper; | 488 FrameTestHelpers::WebViewHelper webViewHelper; |
| 489 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 489 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 490 ASSERT(webView); | 490 DCHECK(webView); |
| 491 webView->settings()->setPluginsEnabled(true); | 491 webView->settings()->setPluginsEnabled(true); |
| 492 webView->resize(WebSize(300, 300)); | 492 webView->resize(WebSize(300, 300)); |
| 493 webView->updateAllLifecyclePhases(); | 493 webView->updateAllLifecyclePhases(); |
| 494 runPendingTasks(); | 494 runPendingTasks(); |
| 495 | 495 |
| 496 WebElement pluginElement = webView->mainFrame()->document().getElementById("
subpixel-positioned-plugin"); | 496 WebElement pluginElement = webView->mainFrame()->document().getElementById("
subpixel-positioned-plugin"); |
| 497 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); | 497 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); |
| 498 | 498 |
| 499 ASSERT(pluginContainerImpl.get()); | 499 DCHECK(pluginContainerImpl.get()); |
| 500 | 500 |
| 501 IntRect windowRect, clipRect, unobscuredRect; | 501 IntRect windowRect, clipRect, unobscuredRect; |
| 502 Vector<IntRect> cutOutRects; | 502 Vector<IntRect> cutOutRects; |
| 503 | 503 |
| 504 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); | 504 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 505 // TODO(chrishtr): these values should not be -1, they should be 0. They are
-1 because WebPluginContainerImpl currently uses an IntRect for | 505 // TODO(chrishtr): these values should not be -1, they should be 0. They are
-1 because WebPluginContainerImpl currently uses an IntRect for |
| 506 // frameRect() to determine the position of the plugin, which results in a l
oss of precision if it is actually subpixel positioned. | 506 // frameRect() to determine the position of the plugin, which results in a l
oss of precision if it is actually subpixel positioned. |
| 507 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect); | 507 EXPECT_RECT_EQ(IntRect(0, 0, 40, 40), windowRect); |
| 508 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), clipRect); | 508 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), clipRect); |
| 509 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), unobscuredRect); | 509 EXPECT_RECT_EQ(IntRect(-1, -1, 41, 41), unobscuredRect); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 532 // In destroy, isRectTopmost is no longer valid. | 532 // In destroy, isRectTopmost is no longer valid. |
| 533 EXPECT_FALSE(container()->isRectTopmost(topmostRect)); | 533 EXPECT_FALSE(container()->isRectTopmost(topmostRect)); |
| 534 FakeWebPlugin::destroy(); | 534 FakeWebPlugin::destroy(); |
| 535 } | 535 } |
| 536 }; | 536 }; |
| 537 | 537 |
| 538 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 538 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 539 CustomPluginWebFrameClient<TopmostPlugin> pluginWebFrameClient; // Must outl
ive webViewHelper. | 539 CustomPluginWebFrameClient<TopmostPlugin> pluginWebFrameClient; // Must outl
ive webViewHelper. |
| 540 FrameTestHelpers::WebViewHelper webViewHelper; | 540 FrameTestHelpers::WebViewHelper webViewHelper; |
| 541 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 541 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 542 ASSERT(webView); | 542 DCHECK(webView); |
| 543 webView->settings()->setPluginsEnabled(true); | 543 webView->settings()->setPluginsEnabled(true); |
| 544 webView->resize(WebSize(300, 300)); | 544 webView->resize(WebSize(300, 300)); |
| 545 webView->updateAllLifecyclePhases(); | 545 webView->updateAllLifecyclePhases(); |
| 546 runPendingTasks(); | 546 runPendingTasks(); |
| 547 | 547 |
| 548 RawPtr<WebPluginContainerImpl> pluginContainerImpl = | 548 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 549 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 549 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 550 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 550 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 551 | 551 |
| 552 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); | 552 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 634 } |
| 635 | 635 |
| 636 TEST_F(WebPluginContainerTest, NeedsWheelEvents) | 636 TEST_F(WebPluginContainerTest, NeedsWheelEvents) |
| 637 { | 637 { |
| 638 URLTestHelpers::registerMockedURLFromBaseURL( | 638 URLTestHelpers::registerMockedURLFromBaseURL( |
| 639 WebString::fromUTF8(m_baseURL.c_str()), | 639 WebString::fromUTF8(m_baseURL.c_str()), |
| 640 WebString::fromUTF8("plugin_container.html")); | 640 WebString::fromUTF8("plugin_container.html")); |
| 641 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper | 641 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper |
| 642 FrameTestHelpers::WebViewHelper webViewHelper; | 642 FrameTestHelpers::WebViewHelper webViewHelper; |
| 643 WebViewImpl* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_c
ontainer.html", true, &pluginWebFrameClient); | 643 WebViewImpl* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_c
ontainer.html", true, &pluginWebFrameClient); |
| 644 ASSERT(webView); | 644 DCHECK(webView); |
| 645 webView->settings()->setPluginsEnabled(true); | 645 webView->settings()->setPluginsEnabled(true); |
| 646 webView->resize(WebSize(300, 300)); | 646 webView->resize(WebSize(300, 300)); |
| 647 webView->updateAllLifecyclePhases(); | 647 webView->updateAllLifecyclePhases(); |
| 648 runPendingTasks(); | 648 runPendingTasks(); |
| 649 | 649 |
| 650 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 650 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 651 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 651 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 652 | 652 |
| 653 runPendingTasks(); | 653 runPendingTasks(); |
| 654 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); | 654 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); |
| 655 } | 655 } |
| 656 | 656 |
| 657 } // namespace blink | 657 } // namespace blink |
| OLD | NEW |