Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 #include "core/layout/LayoutView.h" | 65 #include "core/layout/LayoutView.h" |
| 66 #include "core/layout/compositing/LayerCompositor.h" | 66 #include "core/layout/compositing/LayerCompositor.h" |
| 67 #include "core/loader/DocumentThreadableLoader.h" | 67 #include "core/loader/DocumentThreadableLoader.h" |
| 68 #include "core/loader/DocumentThreadableLoaderClient.h" | 68 #include "core/loader/DocumentThreadableLoaderClient.h" |
| 69 #include "core/loader/FrameLoadRequest.h" | 69 #include "core/loader/FrameLoadRequest.h" |
| 70 #include "core/loader/ThreadableLoader.h" | 70 #include "core/loader/ThreadableLoader.h" |
| 71 #include "core/page/EventHandler.h" | 71 #include "core/page/EventHandler.h" |
| 72 #include "core/page/Page.h" | 72 #include "core/page/Page.h" |
| 73 #include "core/testing/NullExecutionContext.h" | 73 #include "core/testing/NullExecutionContext.h" |
| 74 #include "core/testing/URLTestHelpers.h" | 74 #include "core/testing/URLTestHelpers.h" |
| 75 #include "core/testing/UnitTestHelpers.h" | |
| 75 #include "modules/mediastream/MediaStream.h" | 76 #include "modules/mediastream/MediaStream.h" |
| 76 #include "modules/mediastream/MediaStreamRegistry.h" | 77 #include "modules/mediastream/MediaStreamRegistry.h" |
| 77 #include "platform/DragImage.h" | 78 #include "platform/DragImage.h" |
| 78 #include "platform/PlatformResourceLoader.h" | 79 #include "platform/PlatformResourceLoader.h" |
| 79 #include "platform/RuntimeEnabledFeatures.h" | 80 #include "platform/RuntimeEnabledFeatures.h" |
| 80 #include "platform/UserGestureIndicator.h" | 81 #include "platform/UserGestureIndicator.h" |
| 81 #include "platform/geometry/FloatRect.h" | 82 #include "platform/geometry/FloatRect.h" |
| 82 #include "platform/network/ResourceError.h" | 83 #include "platform/network/ResourceError.h" |
| 83 #include "platform/scroll/ScrollbarTheme.h" | 84 #include "platform/scroll/ScrollbarTheme.h" |
| 84 #include "platform/weborigin/SchemeRegistry.h" | 85 #include "platform/weborigin/SchemeRegistry.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 108 #include "public/web/WebSpellCheckClient.h" | 109 #include "public/web/WebSpellCheckClient.h" |
| 109 #include "public/web/WebTextCheckingCompletion.h" | 110 #include "public/web/WebTextCheckingCompletion.h" |
| 110 #include "public/web/WebTextCheckingResult.h" | 111 #include "public/web/WebTextCheckingResult.h" |
| 111 #include "public/web/WebViewClient.h" | 112 #include "public/web/WebViewClient.h" |
| 112 #include "web/WebLocalFrameImpl.h" | 113 #include "web/WebLocalFrameImpl.h" |
| 113 #include "web/WebRemoteFrameImpl.h" | 114 #include "web/WebRemoteFrameImpl.h" |
| 114 #include "web/WebViewImpl.h" | 115 #include "web/WebViewImpl.h" |
| 115 #include "web/tests/FrameTestHelpers.h" | 116 #include "web/tests/FrameTestHelpers.h" |
| 116 #include "wtf/Forward.h" | 117 #include "wtf/Forward.h" |
| 117 #include "wtf/dtoa/utils.h" | 118 #include "wtf/dtoa/utils.h" |
| 118 #include <gmock/gmock.h> | |
| 119 #include <gtest/gtest.h> | 119 #include <gtest/gtest.h> |
| 120 #include <map> | 120 #include <map> |
| 121 #include <v8.h> | 121 #include <v8.h> |
| 122 | 122 |
| 123 namespace { | 123 using blink::URLTestHelpers::toKURL; |
| 124 using blink::FrameTestHelpers::UseMockScrollbarSettings; | |
| 125 using blink::testing::runPendingTasks; | |
| 126 using testing::ElementsAre; | |
| 124 | 127 |
| 125 using blink::URLTestHelpers::toKURL; | 128 namespace blink { |
| 126 using blink::FrameTestHelpers::runPendingTasks; | |
| 127 using blink::FrameTestHelpers::UseMockScrollbarSettings; | |
| 128 using namespace blink; | |
| 129 | 129 |
| 130 const int touchPointPadding = 32; | 130 const int touchPointPadding = 32; |
| 131 | 131 |
| 132 #define EXPECT_RECT_EQ(expected, actual) \ | 132 #define EXPECT_RECT_EQ(expected, actual) \ |
| 133 do { \ | 133 do { \ |
| 134 EXPECT_EQ(expected.x(), actual.x()); \ | 134 EXPECT_EQ(expected.x(), actual.x()); \ |
| 135 EXPECT_EQ(expected.y(), actual.y()); \ | 135 EXPECT_EQ(expected.y(), actual.y()); \ |
| 136 EXPECT_EQ(expected.width(), actual.width()); \ | 136 EXPECT_EQ(expected.width(), actual.width()); \ |
| 137 EXPECT_EQ(expected.height(), actual.height()); \ | 137 EXPECT_EQ(expected.height(), actual.height()); \ |
| 138 } while (false) | 138 } while (false) |
| 139 | 139 |
| 140 #define EXPECT_POINT_EQ(expected, actual) \ | 140 #define EXPECT_POINT_EQ(expected, actual) \ |
| 141 do { \ | 141 do { \ |
| 142 EXPECT_EQ(expected.x(), actual.x()); \ | 142 EXPECT_EQ(expected.x(), actual.x()); \ |
| 143 EXPECT_EQ(expected.y(), actual.y()); \ | 143 EXPECT_EQ(expected.y(), actual.y()); \ |
| 144 } while (false) | 144 } while (false) |
| 145 | 145 |
| 146 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ | 146 #define EXPECT_FLOAT_POINT_EQ(expected, actual) \ |
| 147 do { \ | 147 do { \ |
| 148 EXPECT_FLOAT_EQ(expected.x(), actual.x()); \ | 148 EXPECT_FLOAT_EQ(expected.x(), actual.x()); \ |
| 149 EXPECT_FLOAT_EQ(expected.y(), actual.y()); \ | 149 EXPECT_FLOAT_EQ(expected.y(), actual.y()); \ |
| 150 } while (false) | 150 } while (false) |
| 151 | 151 |
| 152 | 152 class WebFrameTest : public ::testing::Test { |
| 153 class WebFrameTest : public testing::Test { | |
| 154 protected: | 153 protected: |
| 155 WebFrameTest() | 154 WebFrameTest() |
| 156 : m_baseURL("http://internal.test/") | 155 : m_baseURL("http://internal.test/") |
| 157 , m_notBaseURL("http://external.test/") | 156 , m_notBaseURL("http://external.test/") |
| 158 , m_chromeURL("chrome://") | 157 , m_chromeURL("chrome://") |
| 159 { | 158 { |
| 160 } | 159 } |
| 161 | 160 |
| 162 virtual ~WebFrameTest() | 161 virtual ~WebFrameTest() |
| 163 { | 162 { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; | 387 EXPECT_EQ(0U, frameSelectors.count(selector)) << selector; |
| 389 frameSelectors.insert(selector); | 388 frameSelectors.insert(selector); |
| 390 } | 389 } |
| 391 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { | 390 for (size_t i = 0; i < stoppedMatchingSelectors.size(); ++i) { |
| 392 std::string selector = stoppedMatchingSelectors[i].utf8(); | 391 std::string selector = stoppedMatchingSelectors[i].utf8(); |
| 393 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; | 392 EXPECT_EQ(1U, frameSelectors.count(selector)) << selector; |
| 394 frameSelectors.erase(selector); | 393 frameSelectors.erase(selector); |
| 395 } | 394 } |
| 396 } | 395 } |
| 397 | 396 |
| 398 class WebFrameCSSCallbackTest : public testing::Test { | 397 class WebFrameCSSCallbackTest : public ::testing::Test { |
| 399 protected: | 398 protected: |
| 400 WebFrameCSSCallbackTest() | 399 WebFrameCSSCallbackTest() |
| 401 { | 400 { |
| 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 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 "</style>" | 449 "</style>" |
| 451 "<div class=\"initial_on\"></div>" | 450 "<div class=\"initial_on\"></div>" |
| 452 "<div class=\"initial_off\"></div>"); | 451 "<div class=\"initial_off\"></div>"); |
| 453 | 452 |
| 454 std::vector<WebString> selectors; | 453 std::vector<WebString> selectors; |
| 455 selectors.push_back(WebString::fromUTF8("div.initial_on")); | 454 selectors.push_back(WebString::fromUTF8("div.initial_on")); |
| 456 m_frame->document().watchCSSSelectors(WebVector<WebString>(selectors)); | 455 m_frame->document().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 457 m_frame->view()->layout(); | 456 m_frame->view()->layout(); |
| 458 runPendingTasks(); | 457 runPendingTasks(); |
| 459 EXPECT_EQ(1, updateCount()); | 458 EXPECT_EQ(1, updateCount()); |
| 460 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_on")); | 459 EXPECT_THAT(matchedSelectors(), ElementsAre("div.initial_on")); |
|
dcheng
2015/03/02 14:25:29
FWIW, I'd prefer to see this in a separate changel
sadrul
2015/03/02 16:01:35
Indeed. Unfortunately, I had to include the change
| |
| 461 | 460 |
| 462 // Check that adding a watched selector calls back for already-present nodes . | 461 // Check that adding a watched selector calls back for already-present nodes . |
| 463 selectors.push_back(WebString::fromUTF8("div.initial_off")); | 462 selectors.push_back(WebString::fromUTF8("div.initial_off")); |
| 464 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 463 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 465 m_frame->view()->layout(); | 464 m_frame->view()->layout(); |
| 466 runPendingTasks(); | 465 runPendingTasks(); |
| 467 EXPECT_EQ(2, updateCount()); | 466 EXPECT_EQ(2, updateCount()); |
| 468 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("div.initial_off", "div .initial_on")); | 467 EXPECT_THAT(matchedSelectors(), ElementsAre("div.initial_off", "div.initial_ on")); |
| 469 | 468 |
| 470 // Check that we can turn off callbacks for certain selectors. | 469 // Check that we can turn off callbacks for certain selectors. |
| 471 doc().watchCSSSelectors(WebVector<WebString>()); | 470 doc().watchCSSSelectors(WebVector<WebString>()); |
| 472 m_frame->view()->layout(); | 471 m_frame->view()->layout(); |
| 473 runPendingTasks(); | 472 runPendingTasks(); |
| 474 EXPECT_EQ(3, updateCount()); | 473 EXPECT_EQ(3, updateCount()); |
| 475 EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); | 474 EXPECT_THAT(matchedSelectors(), ElementsAre()); |
| 476 } | 475 } |
| 477 | 476 |
| 478 TEST_F(WebFrameCSSCallbackTest, SharedLayoutStyle) | 477 TEST_F(WebFrameCSSCallbackTest, SharedLayoutStyle) |
| 479 { | 478 { |
| 480 // Check that adding an element calls back when it matches an existing rule. | 479 // Check that adding an element calls back when it matches an existing rule. |
| 481 std::vector<WebString> selectors; | 480 std::vector<WebString> selectors; |
| 482 selectors.push_back(WebString::fromUTF8("span")); | 481 selectors.push_back(WebString::fromUTF8("span")); |
| 483 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 482 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 484 | 483 |
| 485 executeScript( | 484 executeScript( |
| 486 "i1 = document.createElement('span');" | 485 "i1 = document.createElement('span');" |
| 487 "i1.id = 'first_span';" | 486 "i1.id = 'first_span';" |
| 488 "document.body.appendChild(i1)"); | 487 "document.body.appendChild(i1)"); |
| 489 EXPECT_EQ(1, updateCount()); | 488 EXPECT_EQ(1, updateCount()); |
| 490 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 489 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 491 | 490 |
| 492 // Adding a second element that shares a LayoutStyle shouldn't call back. | 491 // Adding a second element that shares a LayoutStyle shouldn't call back. |
| 493 // We use <span>s to avoid default style rules that can set | 492 // We use <span>s to avoid default style rules that can set |
| 494 // LayoutStyle::unique(). | 493 // LayoutStyle::unique(). |
| 495 executeScript( | 494 executeScript( |
| 496 "i2 = document.createElement('span');" | 495 "i2 = document.createElement('span');" |
| 497 "i2.id = 'second_span';" | 496 "i2.id = 'second_span';" |
| 498 "i1 = document.getElementById('first_span');" | 497 "i1 = document.getElementById('first_span');" |
| 499 "i1.parentNode.insertBefore(i2, i1.nextSibling);"); | 498 "i1.parentNode.insertBefore(i2, i1.nextSibling);"); |
| 500 EXPECT_EQ(1, updateCount()); | 499 EXPECT_EQ(1, updateCount()); |
| 501 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 500 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 502 | 501 |
| 503 // Removing the first element shouldn't call back. | 502 // Removing the first element shouldn't call back. |
| 504 executeScript( | 503 executeScript( |
| 505 "i1 = document.getElementById('first_span');" | 504 "i1 = document.getElementById('first_span');" |
| 506 "i1.parentNode.removeChild(i1);"); | 505 "i1.parentNode.removeChild(i1);"); |
| 507 EXPECT_EQ(1, updateCount()); | 506 EXPECT_EQ(1, updateCount()); |
| 508 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 507 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 509 | 508 |
| 510 // But removing the second element *should* call back. | 509 // But removing the second element *should* call back. |
| 511 executeScript( | 510 executeScript( |
| 512 "i2 = document.getElementById('second_span');" | 511 "i2 = document.getElementById('second_span');" |
| 513 "i2.parentNode.removeChild(i2);"); | 512 "i2.parentNode.removeChild(i2);"); |
| 514 EXPECT_EQ(2, updateCount()); | 513 EXPECT_EQ(2, updateCount()); |
| 515 EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); | 514 EXPECT_THAT(matchedSelectors(), ElementsAre()); |
| 516 } | 515 } |
| 517 | 516 |
| 518 TEST_F(WebFrameCSSCallbackTest, CatchesAttributeChange) | 517 TEST_F(WebFrameCSSCallbackTest, CatchesAttributeChange) |
| 519 { | 518 { |
| 520 loadHTML("<span></span>"); | 519 loadHTML("<span></span>"); |
| 521 | 520 |
| 522 std::vector<WebString> selectors; | 521 std::vector<WebString> selectors; |
| 523 selectors.push_back(WebString::fromUTF8("span[attr=\"value\"]")); | 522 selectors.push_back(WebString::fromUTF8("span[attr=\"value\"]")); |
| 524 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 523 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 525 runPendingTasks(); | 524 runPendingTasks(); |
| 526 | 525 |
| 527 EXPECT_EQ(0, updateCount()); | 526 EXPECT_EQ(0, updateCount()); |
| 528 EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); | 527 EXPECT_THAT(matchedSelectors(), ElementsAre()); |
| 529 | 528 |
| 530 executeScript( | 529 executeScript( |
| 531 "document.querySelector('span').setAttribute('attr', 'value');"); | 530 "document.querySelector('span').setAttribute('attr', 'value');"); |
| 532 EXPECT_EQ(1, updateCount()); | 531 EXPECT_EQ(1, updateCount()); |
| 533 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span[attr=\"value\"]") ); | 532 EXPECT_THAT(matchedSelectors(), ElementsAre("span[attr=\"value\"]")); |
| 534 } | 533 } |
| 535 | 534 |
| 536 TEST_F(WebFrameCSSCallbackTest, DisplayNone) | 535 TEST_F(WebFrameCSSCallbackTest, DisplayNone) |
| 537 { | 536 { |
| 538 loadHTML("<div style='display:none'><span></span></div>"); | 537 loadHTML("<div style='display:none'><span></span></div>"); |
| 539 | 538 |
| 540 std::vector<WebString> selectors; | 539 std::vector<WebString> selectors; |
| 541 selectors.push_back(WebString::fromUTF8("span")); | 540 selectors.push_back(WebString::fromUTF8("span")); |
| 542 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 541 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 543 runPendingTasks(); | 542 runPendingTasks(); |
| 544 | 543 |
| 545 EXPECT_EQ(0, updateCount()) << "Don't match elements in display:none trees." ; | 544 EXPECT_EQ(0, updateCount()) << "Don't match elements in display:none trees." ; |
| 546 | 545 |
| 547 executeScript( | 546 executeScript( |
| 548 "d = document.querySelector('div');" | 547 "d = document.querySelector('div');" |
| 549 "d.style.display = 'block';"); | 548 "d.style.display = 'block';"); |
| 550 EXPECT_EQ(1, updateCount()) << "Match elements when they become displayed."; | 549 EXPECT_EQ(1, updateCount()) << "Match elements when they become displayed."; |
| 551 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 550 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 552 | 551 |
| 553 executeScript( | 552 executeScript( |
| 554 "d = document.querySelector('div');" | 553 "d = document.querySelector('div');" |
| 555 "d.style.display = 'none';"); | 554 "d.style.display = 'none';"); |
| 556 EXPECT_EQ(2, updateCount()) << "Unmatch elements when they become undisplaye d."; | 555 EXPECT_EQ(2, updateCount()) << "Unmatch elements when they become undisplaye d."; |
| 557 EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); | 556 EXPECT_THAT(matchedSelectors(), ElementsAre()); |
| 558 | 557 |
| 559 executeScript( | 558 executeScript( |
| 560 "s = document.querySelector('span');" | 559 "s = document.querySelector('span');" |
| 561 "s.style.display = 'none';"); | 560 "s.style.display = 'none';"); |
| 562 EXPECT_EQ(2, updateCount()) << "No effect from no-display'ing a span that's already undisplayed."; | 561 EXPECT_EQ(2, updateCount()) << "No effect from no-display'ing a span that's already undisplayed."; |
| 563 | 562 |
| 564 executeScript( | 563 executeScript( |
| 565 "d = document.querySelector('div');" | 564 "d = document.querySelector('div');" |
| 566 "d.style.display = 'block';"); | 565 "d.style.display = 'block';"); |
| 567 EXPECT_EQ(2, updateCount()) << "No effect from displaying a div whose span i s display:none."; | 566 EXPECT_EQ(2, updateCount()) << "No effect from displaying a div whose span i s display:none."; |
| 568 | 567 |
| 569 executeScript( | 568 executeScript( |
| 570 "s = document.querySelector('span');" | 569 "s = document.querySelector('span');" |
| 571 "s.style.display = 'inline';"); | 570 "s.style.display = 'inline';"); |
| 572 EXPECT_EQ(3, updateCount()) << "Now the span is visible and produces a callb ack."; | 571 EXPECT_EQ(3, updateCount()) << "Now the span is visible and produces a callb ack."; |
| 573 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 572 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 574 | 573 |
| 575 executeScript( | 574 executeScript( |
| 576 "s = document.querySelector('span');" | 575 "s = document.querySelector('span');" |
| 577 "s.style.display = 'none';"); | 576 "s.style.display = 'none';"); |
| 578 EXPECT_EQ(4, updateCount()) << "Undisplaying the span directly should produc e another callback."; | 577 EXPECT_EQ(4, updateCount()) << "Undisplaying the span directly should produc e another callback."; |
| 579 EXPECT_THAT(matchedSelectors(), testing::ElementsAre()); | 578 EXPECT_THAT(matchedSelectors(), ElementsAre()); |
| 580 } | 579 } |
| 581 | 580 |
| 582 TEST_F(WebFrameCSSCallbackTest, Reparenting) | 581 TEST_F(WebFrameCSSCallbackTest, Reparenting) |
| 583 { | 582 { |
| 584 loadHTML( | 583 loadHTML( |
| 585 "<div id='d1'><span></span></div>" | 584 "<div id='d1'><span></span></div>" |
| 586 "<div id='d2'></div>"); | 585 "<div id='d2'></div>"); |
| 587 | 586 |
| 588 std::vector<WebString> selectors; | 587 std::vector<WebString> selectors; |
| 589 selectors.push_back(WebString::fromUTF8("span")); | 588 selectors.push_back(WebString::fromUTF8("span")); |
| 590 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 589 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 591 m_frame->view()->layout(); | 590 m_frame->view()->layout(); |
| 592 runPendingTasks(); | 591 runPendingTasks(); |
| 593 | 592 |
| 594 EXPECT_EQ(1, updateCount()); | 593 EXPECT_EQ(1, updateCount()); |
| 595 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 594 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 596 | 595 |
| 597 executeScript( | 596 executeScript( |
| 598 "s = document.querySelector('span');" | 597 "s = document.querySelector('span');" |
| 599 "d2 = document.getElementById('d2');" | 598 "d2 = document.getElementById('d2');" |
| 600 "d2.appendChild(s);"); | 599 "d2.appendChild(s);"); |
| 601 EXPECT_EQ(1, updateCount()) << "Just moving an element that continues to mat ch shouldn't send a spurious callback."; | 600 EXPECT_EQ(1, updateCount()) << "Just moving an element that continues to mat ch shouldn't send a spurious callback."; |
| 602 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")); | 601 EXPECT_THAT(matchedSelectors(), ElementsAre("span")); |
| 603 } | 602 } |
| 604 | 603 |
| 605 TEST_F(WebFrameCSSCallbackTest, MultiSelector) | 604 TEST_F(WebFrameCSSCallbackTest, MultiSelector) |
| 606 { | 605 { |
| 607 loadHTML("<span></span>"); | 606 loadHTML("<span></span>"); |
| 608 | 607 |
| 609 // Check that selector lists match as the whole list, not as each element | 608 // Check that selector lists match as the whole list, not as each element |
| 610 // independently. | 609 // independently. |
| 611 std::vector<WebString> selectors; | 610 std::vector<WebString> selectors; |
| 612 selectors.push_back(WebString::fromUTF8("span")); | 611 selectors.push_back(WebString::fromUTF8("span")); |
| 613 selectors.push_back(WebString::fromUTF8("span,p")); | 612 selectors.push_back(WebString::fromUTF8("span,p")); |
| 614 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 613 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 615 m_frame->view()->layout(); | 614 m_frame->view()->layout(); |
| 616 runPendingTasks(); | 615 runPendingTasks(); |
| 617 | 616 |
| 618 EXPECT_EQ(1, updateCount()); | 617 EXPECT_EQ(1, updateCount()); |
| 619 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span", "span, p")); | 618 EXPECT_THAT(matchedSelectors(), ElementsAre("span", "span, p")); |
| 620 } | 619 } |
| 621 | 620 |
| 622 TEST_F(WebFrameCSSCallbackTest, InvalidSelector) | 621 TEST_F(WebFrameCSSCallbackTest, InvalidSelector) |
| 623 { | 622 { |
| 624 loadHTML("<p><span></span></p>"); | 623 loadHTML("<p><span></span></p>"); |
| 625 | 624 |
| 626 // Build a list with one valid selector and one invalid. | 625 // Build a list with one valid selector and one invalid. |
| 627 std::vector<WebString> selectors; | 626 std::vector<WebString> selectors; |
| 628 selectors.push_back(WebString::fromUTF8("span")); | 627 selectors.push_back(WebString::fromUTF8("span")); |
| 629 selectors.push_back(WebString::fromUTF8("[")); // Invalid. | 628 selectors.push_back(WebString::fromUTF8("[")); // Invalid. |
| 630 selectors.push_back(WebString::fromUTF8("p span")); // Not compound. | 629 selectors.push_back(WebString::fromUTF8("p span")); // Not compound. |
| 631 doc().watchCSSSelectors(WebVector<WebString>(selectors)); | 630 doc().watchCSSSelectors(WebVector<WebString>(selectors)); |
| 632 m_frame->view()->layout(); | 631 m_frame->view()->layout(); |
| 633 runPendingTasks(); | 632 runPendingTasks(); |
| 634 | 633 |
| 635 EXPECT_EQ(1, updateCount()); | 634 EXPECT_EQ(1, updateCount()); |
| 636 EXPECT_THAT(matchedSelectors(), testing::ElementsAre("span")) | 635 EXPECT_THAT(matchedSelectors(), ElementsAre("span")) |
| 637 << "An invalid selector shouldn't prevent other selectors from matching. "; | 636 << "An invalid selector shouldn't prevent other selectors from matching. "; |
| 638 } | 637 } |
| 639 | 638 |
| 640 TEST_F(WebFrameTest, DispatchMessageEventWithOriginCheck) | 639 TEST_F(WebFrameTest, DispatchMessageEventWithOriginCheck) |
| 641 { | 640 { |
| 642 registerMockedHttpURLLoad("postmessage_test.html"); | 641 registerMockedHttpURLLoad("postmessage_test.html"); |
| 643 | 642 |
| 644 // Pass true to enable JavaScript. | 643 // Pass true to enable JavaScript. |
| 645 FrameTestHelpers::WebViewHelper webViewHelper; | 644 FrameTestHelpers::WebViewHelper webViewHelper; |
| 646 webViewHelper.initializeAndLoad(m_baseURL + "postmessage_test.html", true); | 645 webViewHelper.initializeAndLoad(m_baseURL + "postmessage_test.html", true); |
| (...skipping 6675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7322 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7321 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 7323 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7322 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7324 | 7323 |
| 7325 // Neither should a page reload. | 7324 // Neither should a page reload. |
| 7326 localFrame->reload(); | 7325 localFrame->reload(); |
| 7327 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 7326 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
| 7328 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 7327 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
| 7329 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 7328 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
| 7330 } | 7329 } |
| 7331 | 7330 |
| 7332 } // namespace | 7331 } // namespace blink |
| OLD | NEW |