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(); | |
311 | 307 |
312 // Creating a new frame view with the background color having 0 alpha. | 308 // Creating a new frame view with the background color having 0 alpha. |
313 frame->createView(IntSize(1024, 768), Color::transparent, true); | 309 frame->createView(IntSize(1024, 768), Color::transparent, true); |
314 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); | 310 EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor()); |
315 frame->view()->prepareForDetach(); | |
316 | 311 |
317 Color kTransparentRed(100, 0, 0, 0); | 312 Color kTransparentRed(100, 0, 0, 0); |
318 frame->createView(IntSize(1024, 768), kTransparentRed, true); | 313 frame->createView(IntSize(1024, 768), kTransparentRed, true); |
319 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); | 314 EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor()); |
320 frame->view()->prepareForDetach(); | |
321 } | 315 } |
322 | 316 |
323 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) | 317 TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) |
324 { | 318 { |
325 const WebColor kBlue = 0xFF0000FF; | 319 const WebColor kBlue = 0xFF0000FF; |
326 FrameTestHelpers::TestWebViewClient webViewClient; | 320 FrameTestHelpers::TestWebViewClient webViewClient; |
327 WebView* webView = WebViewImpl::create(&webViewClient); | 321 WebView* webView = WebViewImpl::create(&webViewClient); |
328 EXPECT_NE(kBlue, webView->backgroundColor()); | 322 EXPECT_NE(kBlue, webView->backgroundColor()); |
329 // webView does not have a frame yet, but we should still be able to set the
background color. | 323 // webView does not have a frame yet, but we should still be able to set the
background color. |
330 webView->setBaseBackgroundColor(kBlue); | 324 webView->setBaseBackgroundColor(kBlue); |
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 // Test without any preventDefault. | 2507 // Test without any preventDefault. |
2514 client.reset(); | 2508 client.reset(); |
2515 frame->executeScript(WebScriptSource("setTest('none');")); | 2509 frame->executeScript(WebScriptSource("setTest('none');")); |
2516 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 2510 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
2517 EXPECT_TRUE(client.getWasCalled()); | 2511 EXPECT_TRUE(client.getWasCalled()); |
2518 | 2512 |
2519 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2513 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
2520 } | 2514 } |
2521 | 2515 |
2522 } // namespace | 2516 } // namespace |
OLD | NEW |