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 4840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) | 4851 TEST_F(WebFrameTest, MoveCaretSelectionTowardsWindowPointWithNoSelection) |
4852 { | 4852 { |
4853 FrameTestHelpers::WebViewHelper webViewHelper; | 4853 FrameTestHelpers::WebViewHelper webViewHelper; |
4854 webViewHelper.initializeAndLoad("about:blank", true); | 4854 webViewHelper.initializeAndLoad("about:blank", true); |
4855 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 4855 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
4856 | 4856 |
4857 // This test passes if this doesn't crash. | 4857 // This test passes if this doesn't crash. |
4858 frame->moveCaretSelection(WebPoint(0, 0)); | 4858 frame->moveCaretSelection(WebPoint(0, 0)); |
4859 } | 4859 } |
4860 | 4860 |
4861 TEST_F(WebFrameTest, NavigateToSandboxedMarkup) | |
4862 { | |
4863 FrameTestHelpers::TestWebFrameClient webFrameClient; | |
4864 FrameTestHelpers::WebViewHelper webViewHelper; | |
4865 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad("about:blank", tr
ue, &webFrameClient); | |
4866 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewHelper.webView()->main
Frame()); | |
4867 | |
4868 frame->document().setIsTransitionDocument(true); | |
4869 | |
4870 std::string markup("<div id='foo'></div><script>document.getElementById('foo
').setAttribute('dir', 'rtl')</script>"); | |
4871 frame->navigateToSandboxedMarkup(WebData(markup.data(), markup.length())); | |
4872 | |
4873 webFrameClient.waitForLoadToComplete(); | |
4874 | |
4875 WebDocument document = webViewImpl->mainFrame()->document(); | |
4876 WebElement transitionElement = document.getElementById("foo"); | |
4877 // Check that the markup got navigated to successfully. | |
4878 EXPECT_FALSE(transitionElement.isNull()); | |
4879 | |
4880 // Check that the inline script was not executed. | |
4881 EXPECT_FALSE(transitionElement.hasAttribute("dir")); | |
4882 } | |
4883 | |
4884 class SpellCheckClient : public WebSpellCheckClient { | 4861 class SpellCheckClient : public WebSpellCheckClient { |
4885 public: | 4862 public: |
4886 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } | 4863 explicit SpellCheckClient(uint32_t hash = 0) : m_numberOfTimesChecked(0), m_
hash(hash) { } |
4887 virtual ~SpellCheckClient() { } | 4864 virtual ~SpellCheckClient() { } |
4888 virtual void requestCheckingOfText(const WebString&, const WebVector<uint32_
t>&, const WebVector<unsigned>&, WebTextCheckingCompletion* completion) override | 4865 virtual void requestCheckingOfText(const WebString&, const WebVector<uint32_
t>&, const WebVector<unsigned>&, WebTextCheckingCompletion* completion) override |
4889 { | 4866 { |
4890 ++m_numberOfTimesChecked; | 4867 ++m_numberOfTimesChecked; |
4891 Vector<WebTextCheckingResult> results; | 4868 Vector<WebTextCheckingResult> results; |
4892 const int misspellingStartOffset = 1; | 4869 const int misspellingStartOffset = 1; |
4893 const int misspellingLength = 8; | 4870 const int misspellingLength = 8; |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5892 } | 5869 } |
5893 | 5870 |
5894 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5871 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
5895 public: | 5872 public: |
5896 TestHistoryWebFrameClient() | 5873 TestHistoryWebFrameClient() |
5897 { | 5874 { |
5898 m_replacesCurrentHistoryItem = false; | 5875 m_replacesCurrentHistoryItem = false; |
5899 m_frame = nullptr; | 5876 m_frame = nullptr; |
5900 } | 5877 } |
5901 | 5878 |
5902 void didStartProvisionalLoad(WebLocalFrame* frame, bool isTransitionNavigati
on, double) | 5879 void didStartProvisionalLoad(WebLocalFrame* frame, double) |
5903 { | 5880 { |
5904 WebDataSource* ds = frame->provisionalDataSource(); | 5881 WebDataSource* ds = frame->provisionalDataSource(); |
5905 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | 5882 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); |
5906 m_frame = frame; | 5883 m_frame = frame; |
5907 } | 5884 } |
5908 | 5885 |
5909 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } | 5886 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } |
5910 WebFrame* frame() { return m_frame; } | 5887 WebFrame* frame() { return m_frame; } |
5911 | 5888 |
5912 private: | 5889 private: |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7262 EXPECT_TRUE(client.failed()); | 7239 EXPECT_TRUE(client.failed()); |
7263 | 7240 |
7264 client.reset(); | 7241 client.reset(); |
7265 // Try to load the request with cross origin access. Should succeed. | 7242 // Try to load the request with cross origin access. Should succeed. |
7266 options.crossOriginRequestPolicy = AllowCrossOriginRequests; | 7243 options.crossOriginRequestPolicy = AllowCrossOriginRequests; |
7267 DocumentThreadableLoader::loadResourceSynchronously( | 7244 DocumentThreadableLoader::loadResourceSynchronously( |
7268 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); | 7245 *frame->document(), ResourceRequest(resourceUrl), client, options, resou
rceLoaderOptions); |
7269 EXPECT_FALSE(client.failed()); | 7246 EXPECT_FALSE(client.failed()); |
7270 } | 7247 } |
7271 | 7248 |
7272 class NavigationTransitionCallbackWebFrameClient : public FrameTestHelpers::Test
WebFrameClient { | |
7273 public: | |
7274 NavigationTransitionCallbackWebFrameClient() | |
7275 : m_navigationalDataReceivedCount(0) | |
7276 , m_provisionalLoadCount(0) | |
7277 , m_wasLastProvisionalLoadATransition(false) { } | |
7278 | |
7279 virtual void addNavigationTransitionData(const WebTransitionElementData& dat
a) override | |
7280 { | |
7281 m_navigationalDataReceivedCount++; | |
7282 } | |
7283 | |
7284 virtual void didStartProvisionalLoad(WebLocalFrame* localFrame, bool isTrans
itionNavigation, double) override | |
7285 { | |
7286 m_provisionalLoadCount++; | |
7287 m_wasLastProvisionalLoadATransition = isTransitionNavigation; | |
7288 } | |
7289 | |
7290 unsigned navigationalDataReceivedCount() const { return m_navigationalDataRe
ceivedCount; } | |
7291 unsigned provisionalLoadCount() const { return m_provisionalLoadCount; } | |
7292 bool wasLastProvisionalLoadATransition() const { return m_wasLastProvisional
LoadATransition; } | |
7293 | |
7294 private: | |
7295 unsigned m_navigationalDataReceivedCount; | |
7296 unsigned m_provisionalLoadCount; | |
7297 bool m_wasLastProvisionalLoadATransition; | |
7298 }; | |
7299 | |
7300 TEST_F(WebFrameTest, NavigationTransitionCallbacks) | |
7301 { | |
7302 RuntimeEnabledFeatures::setNavigationTransitionsEnabled(true); | |
7303 FrameTestHelpers::WebViewHelper viewHelper; | |
7304 NavigationTransitionCallbackWebFrameClient frameClient; | |
7305 WebLocalFrame* localFrame = viewHelper.initialize(true, &frameClient)->mainF
rame()->toWebLocalFrame(); | |
7306 | |
7307 const char* transitionHTMLString = | |
7308 "<!DOCTYPE html>" | |
7309 "<meta name='transition-elements' content='#foo;*'>" | |
7310 "<div id='foo'>"; | |
7311 | |
7312 // Initial document load should not be a transition. | |
7313 FrameTestHelpers::loadHTMLString(localFrame, transitionHTMLString, toKURL("h
ttp://internal.test")); | |
7314 EXPECT_EQ(1u, frameClient.provisionalLoadCount()); | |
7315 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | |
7316 EXPECT_EQ(0u, frameClient.navigationalDataReceivedCount()); | |
7317 | |
7318 // Going from internal.test containing transition elements to about:blank, s
hould be a transition. | |
7319 FrameTestHelpers::loadHTMLString(localFrame, transitionHTMLString, toKURL("a
bout:blank")); | |
7320 EXPECT_EQ(2u, frameClient.provisionalLoadCount()); | |
7321 EXPECT_TRUE(frameClient.wasLastProvisionalLoadATransition()); | |
7322 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | |
7323 | |
7324 // Navigating to the URL of the current page shouldn't be a transition. | |
7325 FrameTestHelpers::loadHTMLString(localFrame, transitionHTMLString, toKURL("a
bout:blank")); | |
7326 EXPECT_EQ(3u, frameClient.provisionalLoadCount()); | |
7327 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | |
7328 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | |
7329 | |
7330 // Neither should a page reload. | |
7331 localFrame->reload(); | |
7332 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | |
7333 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | |
7334 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | |
7335 } | |
7336 | |
7337 TEST_F(WebFrameTest, DetachRemoteFrame) | 7249 TEST_F(WebFrameTest, DetachRemoteFrame) |
7338 { | 7250 { |
7339 FrameTestHelpers::TestWebViewClient viewClient; | 7251 FrameTestHelpers::TestWebViewClient viewClient; |
7340 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7252 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7341 WebView* view = WebView::create(&viewClient); | 7253 WebView* view = WebView::create(&viewClient); |
7342 view->setMainFrame(remoteClient.frame()); | 7254 view->setMainFrame(remoteClient.frame()); |
7343 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7255 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
7344 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); | 7256 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild("", WebSandboxFlags::None, &childFrameClient); |
7345 childFrame->detach(); | 7257 childFrame->detach(); |
7346 view->close(); | 7258 view->close(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7423 | 7335 |
7424 EXPECT_EQ(parent, firstFrame->parent()); | 7336 EXPECT_EQ(parent, firstFrame->parent()); |
7425 EXPECT_EQ(parent, secondFrame->parent()); | 7337 EXPECT_EQ(parent, secondFrame->parent()); |
7426 EXPECT_EQ(parent, thirdFrame->parent()); | 7338 EXPECT_EQ(parent, thirdFrame->parent()); |
7427 EXPECT_EQ(parent, fourthFrame->parent()); | 7339 EXPECT_EQ(parent, fourthFrame->parent()); |
7428 | 7340 |
7429 view->close(); | 7341 view->close(); |
7430 } | 7342 } |
7431 | 7343 |
7432 } // namespace blink | 7344 } // namespace blink |
OLD | NEW |