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 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 // Now retrieve the FocusedNode and test it should be null. | 3104 // Now retrieve the FocusedNode and test it should be null. |
3105 EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); | 3105 EXPECT_EQ(0, webViewHelper.webViewImpl()->focusedElement()); |
3106 } | 3106 } |
3107 | 3107 |
3108 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 3108 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
3109 // and destroyed for verification. | 3109 // and destroyed for verification. |
3110 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC
lient { | 3110 class ContextLifetimeTestWebFrameClient : public FrameTestHelpers::TestWebFrameC
lient { |
3111 public: | 3111 public: |
3112 struct Notification { | 3112 struct Notification { |
3113 public: | 3113 public: |
3114 Notification(WebLocalFrame* frame, v8::Handle<v8::Context> context, int
worldId) | 3114 Notification(WebLocalFrame* frame, v8::Local<v8::Context> context, int w
orldId) |
3115 : frame(frame) | 3115 : frame(frame) |
3116 , context(context->GetIsolate(), context) | 3116 , context(context->GetIsolate(), context) |
3117 , worldId(worldId) | 3117 , worldId(worldId) |
3118 { | 3118 { |
3119 } | 3119 } |
3120 | 3120 |
3121 ~Notification() | 3121 ~Notification() |
3122 { | 3122 { |
3123 context.Reset(); | 3123 context.Reset(); |
3124 } | 3124 } |
(...skipping 22 matching lines...) Expand all Loading... |
3147 delete releaseNotifications[i]; | 3147 delete releaseNotifications[i]; |
3148 | 3148 |
3149 createNotifications.clear(); | 3149 createNotifications.clear(); |
3150 releaseNotifications.clear(); | 3150 releaseNotifications.clear(); |
3151 } | 3151 } |
3152 | 3152 |
3153 std::vector<Notification*> createNotifications; | 3153 std::vector<Notification*> createNotifications; |
3154 std::vector<Notification*> releaseNotifications; | 3154 std::vector<Notification*> releaseNotifications; |
3155 | 3155 |
3156 private: | 3156 private: |
3157 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Handle<v8::Con
text> context, int extensionGroup, int worldId) override | 3157 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Cont
ext> context, int extensionGroup, int worldId) override |
3158 { | 3158 { |
3159 createNotifications.push_back(new Notification(frame, context, worldId))
; | 3159 createNotifications.push_back(new Notification(frame, context, worldId))
; |
3160 } | 3160 } |
3161 | 3161 |
3162 virtual void willReleaseScriptContext(WebLocalFrame* frame, v8::Handle<v8::C
ontext> context, int worldId) override | 3162 virtual void willReleaseScriptContext(WebLocalFrame* frame, v8::Local<v8::Co
ntext> context, int worldId) override |
3163 { | 3163 { |
3164 releaseNotifications.push_back(new Notification(frame, context, worldId)
); | 3164 releaseNotifications.push_back(new Notification(frame, context, worldId)
); |
3165 } | 3165 } |
3166 }; | 3166 }; |
3167 | 3167 |
3168 // TODO(aa): Deflake this test. | 3168 // TODO(aa): Deflake this test. |
3169 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) | 3169 TEST_F(WebFrameTest, FLAKY_ContextNotificationsLoadUnload) |
3170 { | 3170 { |
3171 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 3171 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
3172 | 3172 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3415 frame->executeCommand(WebString::fromUTF8("SelectAll")); | 3415 frame->executeCommand(WebString::fromUTF8("SelectAll")); |
3416 EXPECT_TRUE(frame->hasSelection()); | 3416 EXPECT_TRUE(frame->hasSelection()); |
3417 frame->executeCommand(WebString::fromUTF8("Unselect")); | 3417 frame->executeCommand(WebString::fromUTF8("Unselect")); |
3418 EXPECT_FALSE(frame->hasSelection()); | 3418 EXPECT_FALSE(frame->hasSelection()); |
3419 WebString selectionHtml = frame->selectionAsMarkup(); | 3419 WebString selectionHtml = frame->selectionAsMarkup(); |
3420 EXPECT_TRUE(selectionHtml.isEmpty()); | 3420 EXPECT_TRUE(selectionHtml.isEmpty()); |
3421 } | 3421 } |
3422 | 3422 |
3423 class TestExecuteScriptDuringDidCreateScriptContext : public FrameTestHelpers::T
estWebFrameClient { | 3423 class TestExecuteScriptDuringDidCreateScriptContext : public FrameTestHelpers::T
estWebFrameClient { |
3424 public: | 3424 public: |
3425 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Handle<v8::Con
text> context, int extensionGroup, int worldId) override | 3425 virtual void didCreateScriptContext(WebLocalFrame* frame, v8::Local<v8::Cont
ext> context, int extensionGroup, int worldId) override |
3426 { | 3426 { |
3427 frame->executeScript(WebScriptSource("window.history = 'replaced';")); | 3427 frame->executeScript(WebScriptSource("window.history = 'replaced';")); |
3428 } | 3428 } |
3429 }; | 3429 }; |
3430 | 3430 |
3431 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) | 3431 TEST_F(WebFrameTest, ExecuteScriptDuringDidCreateScriptContext) |
3432 { | 3432 { |
3433 registerMockedHttpURLLoad("hello_world.html"); | 3433 registerMockedHttpURLLoad("hello_world.html"); |
3434 | 3434 |
3435 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; | 3435 TestExecuteScriptDuringDidCreateScriptContext webFrameClient; |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4309 { | 4309 { |
4310 registerMockedHttpURLLoad(testFile); | 4310 registerMockedHttpURLLoad(testFile); |
4311 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); | 4311 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_ba
seURL + testFile); |
4312 m_webViewHelper.webView()->layout(); | 4312 m_webViewHelper.webView()->layout(); |
4313 | 4313 |
4314 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection()
; | 4314 const WebSelection* selection = m_fakeSelectionLayerTreeView.selection()
; |
4315 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); | 4315 const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.star
t(); |
4316 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); | 4316 const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
4317 | 4317 |
4318 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); | 4318 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
4319 v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->t
oWebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult"))
; | 4319 v8::Local<v8::Value> result = m_webViewHelper.webView()->mainFrame()->to
WebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult")); |
4320 if (result.IsEmpty() || (*result)->IsUndefined()) { | 4320 if (result.IsEmpty() || (*result)->IsUndefined()) { |
4321 EXPECT_FALSE(selection); | 4321 EXPECT_FALSE(selection); |
4322 EXPECT_FALSE(selectStart); | 4322 EXPECT_FALSE(selectStart); |
4323 EXPECT_FALSE(selectEnd); | 4323 EXPECT_FALSE(selectEnd); |
4324 return; | 4324 return; |
4325 } | 4325 } |
4326 | 4326 |
4327 ASSERT_TRUE(selection); | 4327 ASSERT_TRUE(selection); |
4328 ASSERT_TRUE(selectStart); | 4328 ASSERT_TRUE(selectStart); |
4329 ASSERT_TRUE(selectEnd); | 4329 ASSERT_TRUE(selectEnd); |
(...skipping 2983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7313 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); | 7313 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); |
7314 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); | 7314 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); |
7315 | 7315 |
7316 // Manually reset to break WebViewHelpers' dependencies on the stack | 7316 // Manually reset to break WebViewHelpers' dependencies on the stack |
7317 // allocated WebFrameClients. | 7317 // allocated WebFrameClients. |
7318 webViewHelper.reset(); | 7318 webViewHelper.reset(); |
7319 popupWebViewHelper.reset(); | 7319 popupWebViewHelper.reset(); |
7320 } | 7320 } |
7321 | 7321 |
7322 } // namespace blink | 7322 } // namespace blink |
OLD | NEW |