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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 webView->setBaseBackgroundColor(kTranslucentPutty); | 297 webView->setBaseBackgroundColor(kTranslucentPutty); |
298 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. | 298 // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. |
299 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); | 299 EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); |
300 | 300 |
301 webView->setBaseBackgroundColor(kTransparent); | 301 webView->setBaseBackgroundColor(kTransparent); |
302 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:transparent}</style></head></html>", baseURL); | 302 FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>b
ody {background-color:transparent}</style></head></html>", baseURL); |
303 // Expected: transparent on top of kTransparent will still be transparent. | 303 // Expected: transparent on top of kTransparent will still be transparent. |
304 EXPECT_EQ(kTransparent, webView->backgroundColor()); | 304 EXPECT_EQ(kTransparent, webView->backgroundColor()); |
305 | 305 |
306 LocalFrame* frame = webView->mainFrameImpl()->frame(); | 306 LocalFrame* frame = webView->mainFrameImpl()->frame(); |
| 307 // The prepareForDestruction() and prepareForDetach() calls are a hack to |
| 308 // prevent createView() from violating invariants about frame state during |
| 309 // navigation/detach. |
| 310 frame->document()->prepareForDestruction(); |
307 | 311 |
308 // Creating a new frame view with the background color having 0 alpha. | 312 // Creating a new frame view with the background color having 0 alpha. |
309 frame->createView(IntSize(1024, 768), Color::transparent, true); | 313 frame->createView(IntSize(1024, 768), Color::transparent, true); |
310 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); | 314 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); |
| 315 frame->view()->prepareForDetach(); |
311 | 316 |
312 Color kTransparentRed(100, 0, 0, 0); | 317 Color kTransparentRed(100, 0, 0, 0); |
313 frame->createView(IntSize(1024, 768), kTransparentRed, true); | 318 frame->createView(IntSize(1024, 768), kTransparentRed, true); |
314 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); | 319 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); |
| 320 frame->view()->prepareForDetach(); |
315 } | 321 } |
316 | 322 |
317 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 323 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
318 { | 324 { |
319 const WebColor kBlue = 0xFF0000FF; | 325 const WebColor kBlue = 0xFF0000FF; |
320 FrameTestHelpers::TestWebViewClient webViewClient; | 326 FrameTestHelpers::TestWebViewClient webViewClient; |
321 WebView* webView = WebViewImpl::create(&webViewClient); | 327 WebView* webView = WebViewImpl::create(&webViewClient); |
322 EXPECT_NE(kBlue, webView->backgroundColor()); | 328 EXPECT_NE(kBlue, webView->backgroundColor()); |
323 // webView does not have a frame yet, but we should still be able to set the
background color. | 329 // webView does not have a frame yet, but we should still be able to set the
background color. |
324 webView->setBaseBackgroundColor(kBlue); | 330 webView->setBaseBackgroundColor(kBlue); |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 // Test without any preventDefault. | 2513 // Test without any preventDefault. |
2508 client.reset(); | 2514 client.reset(); |
2509 frame->executeScript(WebScriptSource("setTest('none');")); | 2515 frame->executeScript(WebScriptSource("setTest('none');")); |
2510 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 2516 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
2511 EXPECT_TRUE(client.getWasCalled()); | 2517 EXPECT_TRUE(client.getWasCalled()); |
2512 | 2518 |
2513 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2519 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
2514 } | 2520 } |
2515 | 2521 |
2516 } // namespace | 2522 } // namespace |
OLD | NEW |