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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { | 445 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { |
446 RegisterMockedHttpURLLoad("foo.html"); | 446 RegisterMockedHttpURLLoad("foo.html"); |
447 | 447 |
448 FrameTestHelpers::WebViewHelper web_view_helper; | 448 FrameTestHelpers::WebViewHelper web_view_helper; |
449 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 449 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
450 | 450 |
451 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 451 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
452 ScriptExecutionCallbackHelper callback_helper( | 452 ScriptExecutionCallbackHelper callback_helper( |
453 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext()); | 453 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext()); |
454 web_view_helper.WebView() | 454 web_view_helper.WebView() |
455 ->MainFrame() | 455 ->MainFrameImpl() |
456 ->ToWebLocalFrame() | |
457 ->RequestExecuteScriptAndReturnValue( | 456 ->RequestExecuteScriptAndReturnValue( |
458 WebScriptSource(WebString("'hello';")), false, &callback_helper); | 457 WebScriptSource(WebString("'hello';")), false, &callback_helper); |
459 RunPendingTasks(); | 458 RunPendingTasks(); |
460 EXPECT_TRUE(callback_helper.DidComplete()); | 459 EXPECT_TRUE(callback_helper.DidComplete()); |
461 EXPECT_EQ("hello", callback_helper.StringValue()); | 460 EXPECT_EQ("hello", callback_helper.StringValue()); |
462 } | 461 } |
463 | 462 |
464 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { | 463 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { |
465 RegisterMockedHttpURLLoad("foo.html"); | 464 RegisterMockedHttpURLLoad("foo.html"); |
466 RegisterMockedHttpURLLoad("bar.html"); | 465 RegisterMockedHttpURLLoad("bar.html"); |
(...skipping 3746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4213 EXPECT_EQ(2ul, ix); | 4212 EXPECT_EQ(2ul, ix); |
4214 } | 4213 } |
4215 | 4214 |
4216 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) { | 4215 TEST_P(ParameterizedWebFrameTest, FirstRectForCharacterRangeWithPinchZoom) { |
4217 RegisterMockedHttpURLLoad("textbox.html"); | 4216 RegisterMockedHttpURLLoad("textbox.html"); |
4218 | 4217 |
4219 FrameTestHelpers::WebViewHelper web_view_helper; | 4218 FrameTestHelpers::WebViewHelper web_view_helper; |
4220 web_view_helper.InitializeAndLoad(base_url_ + "textbox.html", true); | 4219 web_view_helper.InitializeAndLoad(base_url_ + "textbox.html", true); |
4221 web_view_helper.Resize(WebSize(640, 480)); | 4220 web_view_helper.Resize(WebSize(640, 480)); |
4222 | 4221 |
4223 WebLocalFrame* main_frame = | 4222 WebLocalFrame* main_frame = web_view_helper.WebView()->MainFrameImpl(); |
4224 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); | |
4225 main_frame->ExecuteScript(WebScriptSource("selectRange();")); | 4223 main_frame->ExecuteScript(WebScriptSource("selectRange();")); |
4226 | 4224 |
4227 WebRect old_rect; | 4225 WebRect old_rect; |
4228 main_frame->FirstRectForCharacterRange(0, 5, old_rect); | 4226 main_frame->FirstRectForCharacterRange(0, 5, old_rect); |
4229 | 4227 |
4230 WebFloatPoint visual_offset(100, 130); | 4228 WebFloatPoint visual_offset(100, 130); |
4231 float scale = 2; | 4229 float scale = 2; |
4232 web_view_helper.WebView()->SetPageScaleFactor(scale); | 4230 web_view_helper.WebView()->SetPageScaleFactor(scale); |
4233 web_view_helper.WebView()->SetVisualViewportOffset(visual_offset); | 4231 web_view_helper.WebView()->SetVisualViewportOffset(visual_offset); |
4234 | 4232 |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4669 FrameTestHelpers::WebViewHelper web_view_helper; | 4667 FrameTestHelpers::WebViewHelper web_view_helper; |
4670 web_view_helper.InitializeAndLoad( | 4668 web_view_helper.InitializeAndLoad( |
4671 base_url_ + "context_notifications_test.html", true, &web_frame_client); | 4669 base_url_ + "context_notifications_test.html", true, &web_frame_client); |
4672 | 4670 |
4673 // Add an isolated world. | 4671 // Add an isolated world. |
4674 web_frame_client.Reset(); | 4672 web_frame_client.Reset(); |
4675 | 4673 |
4676 int isolated_world_id = 42; | 4674 int isolated_world_id = 42; |
4677 WebScriptSource script_source("hi!"); | 4675 WebScriptSource script_source("hi!"); |
4678 int num_sources = 1; | 4676 int num_sources = 1; |
4679 web_view_helper.WebView()->MainFrame()->ExecuteScriptInIsolatedWorld( | 4677 web_view_helper.WebView()->MainFrameImpl()->ExecuteScriptInIsolatedWorld( |
4680 isolated_world_id, &script_source, num_sources); | 4678 isolated_world_id, &script_source, num_sources); |
4681 | 4679 |
4682 // We should now have a new create notification. | 4680 // We should now have a new create notification. |
4683 ASSERT_EQ(1u, create_notifications.size()); | 4681 ASSERT_EQ(1u, create_notifications.size()); |
4684 auto& notification = create_notifications[0]; | 4682 auto& notification = create_notifications[0]; |
4685 ASSERT_EQ(isolated_world_id, notification->world_id); | 4683 ASSERT_EQ(isolated_world_id, notification->world_id); |
4686 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); | 4684 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); |
4687 | 4685 |
4688 // We don't have an API to enumarate isolated worlds for a frame, but we can | 4686 // We don't have an API to enumarate isolated worlds for a frame, but we can |
4689 // at least assert that the context we got is *not* the main world's context. | 4687 // at least assert that the context we got is *not* the main world's context. |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6960 | 6958 |
6961 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBody) { | 6959 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBody) { |
6962 TestAccessInitialDocumentWebFrameClient web_frame_client; | 6960 TestAccessInitialDocumentWebFrameClient web_frame_client; |
6963 FrameTestHelpers::WebViewHelper web_view_helper; | 6961 FrameTestHelpers::WebViewHelper web_view_helper; |
6964 web_view_helper.Initialize(true, &web_frame_client); | 6962 web_view_helper.Initialize(true, &web_frame_client); |
6965 RunPendingTasks(); | 6963 RunPendingTasks(); |
6966 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 6964 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
6967 | 6965 |
6968 // Create another window that will try to access it. | 6966 // Create another window that will try to access it. |
6969 FrameTestHelpers::WebViewHelper new_web_view_helper; | 6967 FrameTestHelpers::WebViewHelper new_web_view_helper; |
6970 WebView* new_view = new_web_view_helper.InitializeWithOpener( | 6968 WebViewBase* new_view = new_web_view_helper.InitializeWithOpener( |
6971 web_view_helper.WebView()->MainFrame(), true); | 6969 web_view_helper.WebView()->MainFrame(), true); |
6972 RunPendingTasks(); | 6970 RunPendingTasks(); |
6973 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 6971 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
6974 | 6972 |
6975 // Access the initial document by modifying the body. | 6973 // Access the initial document by modifying the body. |
6976 new_view->MainFrame()->ExecuteScript( | 6974 new_view->MainFrameImpl()->ExecuteScript( |
6977 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")); | 6975 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")); |
6978 RunPendingTasks(); | 6976 RunPendingTasks(); |
6979 EXPECT_EQ(2, web_frame_client.did_access_initial_document_); | 6977 EXPECT_EQ(2, web_frame_client.did_access_initial_document_); |
6980 | 6978 |
6981 web_view_helper.Reset(); | 6979 web_view_helper.Reset(); |
6982 } | 6980 } |
6983 | 6981 |
6984 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentOpen) { | 6982 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentOpen) { |
6985 TestAccessInitialDocumentWebFrameClient web_frame_client; | 6983 TestAccessInitialDocumentWebFrameClient web_frame_client; |
6986 FrameTestHelpers::WebViewHelper web_view_helper; | 6984 FrameTestHelpers::WebViewHelper web_view_helper; |
6987 web_view_helper.Initialize(true, &web_frame_client); | 6985 web_view_helper.Initialize(true, &web_frame_client); |
6988 RunPendingTasks(); | 6986 RunPendingTasks(); |
6989 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 6987 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
6990 | 6988 |
6991 // Create another window that will try to access it. | 6989 // Create another window that will try to access it. |
6992 FrameTestHelpers::WebViewHelper new_web_view_helper; | 6990 FrameTestHelpers::WebViewHelper new_web_view_helper; |
6993 WebView* new_view = new_web_view_helper.InitializeWithOpener( | 6991 WebViewBase* new_view = new_web_view_helper.InitializeWithOpener( |
6994 web_view_helper.WebView()->MainFrame(), true); | 6992 web_view_helper.WebView()->MainFrame(), true); |
6995 RunPendingTasks(); | 6993 RunPendingTasks(); |
6996 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 6994 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
6997 | 6995 |
6998 // Access the initial document by calling document.open(), which allows | 6996 // Access the initial document by calling document.open(), which allows |
6999 // arbitrary modification of the initial document. | 6997 // arbitrary modification of the initial document. |
7000 new_view->MainFrame()->ExecuteScript( | 6998 new_view->MainFrameImpl()->ExecuteScript( |
7001 WebScriptSource("window.opener.document.open();")); | 6999 WebScriptSource("window.opener.document.open();")); |
7002 RunPendingTasks(); | 7000 RunPendingTasks(); |
7003 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); | 7001 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); |
7004 | 7002 |
7005 web_view_helper.Reset(); | 7003 web_view_helper.Reset(); |
7006 } | 7004 } |
7007 | 7005 |
7008 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentNavigator) { | 7006 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentNavigator) { |
7009 TestAccessInitialDocumentWebFrameClient web_frame_client; | 7007 TestAccessInitialDocumentWebFrameClient web_frame_client; |
7010 FrameTestHelpers::WebViewHelper web_view_helper; | 7008 FrameTestHelpers::WebViewHelper web_view_helper; |
7011 web_view_helper.Initialize(true, &web_frame_client); | 7009 web_view_helper.Initialize(true, &web_frame_client); |
7012 RunPendingTasks(); | 7010 RunPendingTasks(); |
7013 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7011 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7014 | 7012 |
7015 // Create another window that will try to access it. | 7013 // Create another window that will try to access it. |
7016 FrameTestHelpers::WebViewHelper new_web_view_helper; | 7014 FrameTestHelpers::WebViewHelper new_web_view_helper; |
7017 WebView* new_view = new_web_view_helper.InitializeWithOpener( | 7015 WebViewBase* new_view = new_web_view_helper.InitializeWithOpener( |
7018 web_view_helper.WebView()->MainFrame(), true); | 7016 web_view_helper.WebView()->MainFrame(), true); |
7019 RunPendingTasks(); | 7017 RunPendingTasks(); |
7020 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7018 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7021 | 7019 |
7022 // Access the initial document to get to the navigator object. | 7020 // Access the initial document to get to the navigator object. |
7023 new_view->MainFrame()->ExecuteScript( | 7021 new_view->MainFrameImpl()->ExecuteScript( |
7024 WebScriptSource("console.log(window.opener.navigator);")); | 7022 WebScriptSource("console.log(window.opener.navigator);")); |
7025 RunPendingTasks(); | 7023 RunPendingTasks(); |
7026 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); | 7024 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); |
7027 | 7025 |
7028 web_view_helper.Reset(); | 7026 web_view_helper.Reset(); |
7029 } | 7027 } |
7030 | 7028 |
7031 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) { | 7029 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentViaJavascriptUrl) { |
7032 TestAccessInitialDocumentWebFrameClient web_frame_client; | 7030 TestAccessInitialDocumentWebFrameClient web_frame_client; |
7033 FrameTestHelpers::WebViewHelper web_view_helper; | 7031 FrameTestHelpers::WebViewHelper web_view_helper; |
(...skipping 13 matching lines...) Expand all Loading... |
7047 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) | 7045 TEST_P(ParameterizedWebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
7048 { | 7046 { |
7049 TestAccessInitialDocumentWebFrameClient web_frame_client; | 7047 TestAccessInitialDocumentWebFrameClient web_frame_client; |
7050 FrameTestHelpers::WebViewHelper web_view_helper; | 7048 FrameTestHelpers::WebViewHelper web_view_helper; |
7051 web_view_helper.Initialize(true, &web_frame_client); | 7049 web_view_helper.Initialize(true, &web_frame_client); |
7052 RunPendingTasks(); | 7050 RunPendingTasks(); |
7053 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7051 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7054 | 7052 |
7055 // Create another window that will try to access it. | 7053 // Create another window that will try to access it. |
7056 FrameTestHelpers::WebViewHelper new_web_view_helper; | 7054 FrameTestHelpers::WebViewHelper new_web_view_helper; |
7057 WebView* new_view = new_web_view_helper.InitializeWithOpener( | 7055 WebViewBase* new_view = new_web_view_helper.InitializeWithOpener( |
7058 web_view_helper.WebView()->MainFrame(), true); | 7056 web_view_helper.WebView()->MainFrame(), true); |
7059 RunPendingTasks(); | 7057 RunPendingTasks(); |
7060 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7058 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7061 | 7059 |
7062 // Access the initial document by modifying the body. | 7060 // Access the initial document by modifying the body. |
7063 new_view->MainFrame()->ExecuteScript( | 7061 new_view->MainFrameImpl()->ExecuteScript( |
7064 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")); | 7062 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")); |
7065 EXPECT_EQ(2, web_frame_client.did_access_initial_document_); | 7063 EXPECT_EQ(2, web_frame_client.did_access_initial_document_); |
7066 | 7064 |
7067 // Run a modal dialog, which used to run a nested run loop and require | 7065 // Run a modal dialog, which used to run a nested run loop and require |
7068 // a special case for notifying about the access. | 7066 // a special case for notifying about the access. |
7069 new_view->MainFrame()->ExecuteScript( | 7067 new_view->MainFrameImpl()->ExecuteScript( |
7070 WebScriptSource("window.opener.confirm('Modal');")); | 7068 WebScriptSource("window.opener.confirm('Modal');")); |
7071 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); | 7069 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); |
7072 | 7070 |
7073 // Ensure that we don't notify again later. | 7071 // Ensure that we don't notify again later. |
7074 RunPendingTasks(); | 7072 RunPendingTasks(); |
7075 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); | 7073 EXPECT_EQ(3, web_frame_client.did_access_initial_document_); |
7076 | 7074 |
7077 web_view_helper.Reset(); | 7075 web_view_helper.Reset(); |
7078 } | 7076 } |
7079 | 7077 |
7080 TEST_P(ParameterizedWebFrameTest, DidWriteToInitialDocumentBeforeModalDialog) | 7078 TEST_P(ParameterizedWebFrameTest, DidWriteToInitialDocumentBeforeModalDialog) |
7081 { | 7079 { |
7082 TestAccessInitialDocumentWebFrameClient web_frame_client; | 7080 TestAccessInitialDocumentWebFrameClient web_frame_client; |
7083 FrameTestHelpers::WebViewHelper web_view_helper; | 7081 FrameTestHelpers::WebViewHelper web_view_helper; |
7084 web_view_helper.Initialize(true, &web_frame_client); | 7082 web_view_helper.Initialize(true, &web_frame_client); |
7085 RunPendingTasks(); | 7083 RunPendingTasks(); |
7086 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7084 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7087 | 7085 |
7088 // Create another window that will try to access it. | 7086 // Create another window that will try to access it. |
7089 FrameTestHelpers::WebViewHelper new_web_view_helper; | 7087 FrameTestHelpers::WebViewHelper new_web_view_helper; |
7090 WebView* new_view = new_web_view_helper.InitializeWithOpener( | 7088 WebViewBase* new_view = new_web_view_helper.InitializeWithOpener( |
7091 web_view_helper.WebView()->MainFrame(), true); | 7089 web_view_helper.WebView()->MainFrame(), true); |
7092 RunPendingTasks(); | 7090 RunPendingTasks(); |
7093 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); | 7091 EXPECT_EQ(0, web_frame_client.did_access_initial_document_); |
7094 | 7092 |
7095 // Access the initial document with document.write, which moves us past the | 7093 // Access the initial document with document.write, which moves us past the |
7096 // initial empty document state of the state machine. | 7094 // initial empty document state of the state machine. |
7097 new_view->MainFrame()->ExecuteScript( | 7095 new_view->MainFrameImpl()->ExecuteScript( |
7098 WebScriptSource("window.opener.document.write('Modified'); " | 7096 WebScriptSource("window.opener.document.write('Modified'); " |
7099 "window.opener.document.close();")); | 7097 "window.opener.document.close();")); |
7100 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); | 7098 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); |
7101 | 7099 |
7102 // Run a modal dialog, which used to run a nested run loop and require | 7100 // Run a modal dialog, which used to run a nested run loop and require |
7103 // a special case for notifying about the access. | 7101 // a special case for notifying about the access. |
7104 new_view->MainFrame()->ExecuteScript( | 7102 new_view->MainFrameImpl()->ExecuteScript( |
7105 WebScriptSource("window.opener.confirm('Modal');")); | 7103 WebScriptSource("window.opener.confirm('Modal');")); |
7106 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); | 7104 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); |
7107 | 7105 |
7108 // Ensure that we don't notify again later. | 7106 // Ensure that we don't notify again later. |
7109 RunPendingTasks(); | 7107 RunPendingTasks(); |
7110 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); | 7108 EXPECT_EQ(1, web_frame_client.did_access_initial_document_); |
7111 | 7109 |
7112 web_view_helper.Reset(); | 7110 web_view_helper.Reset(); |
7113 } | 7111 } |
7114 | 7112 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7755 // Tests that the first navigation in an initially blank subframe will result in | 7753 // Tests that the first navigation in an initially blank subframe will result in |
7756 // a history entry being replaced and not a new one being added. | 7754 // a history entry being replaced and not a new one being added. |
7757 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { | 7755 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { |
7758 RegisterMockedHttpURLLoad("history.html"); | 7756 RegisterMockedHttpURLLoad("history.html"); |
7759 RegisterMockedHttpURLLoad("find.html"); | 7757 RegisterMockedHttpURLLoad("find.html"); |
7760 | 7758 |
7761 TestHistoryWebFrameClient client; | 7759 TestHistoryWebFrameClient client; |
7762 FrameTestHelpers::WebViewHelper web_view_helper; | 7760 FrameTestHelpers::WebViewHelper web_view_helper; |
7763 web_view_helper.InitializeAndLoad("about:blank", true, &client); | 7761 web_view_helper.InitializeAndLoad("about:blank", true, &client); |
7764 | 7762 |
7765 WebFrame* frame = web_view_helper.WebView()->MainFrame(); | 7763 WebLocalFrame* frame = web_view_helper.WebView()->MainFrameImpl(); |
7766 | 7764 |
7767 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( | 7765 frame->ExecuteScript(WebScriptSource(WebString::FromUTF8( |
7768 "document.body.appendChild(document.createElement('iframe'))"))); | 7766 "document.body.appendChild(document.createElement('iframe'))"))); |
7769 | 7767 |
7770 WebFrame* iframe = frame->FirstChild(); | 7768 WebFrame* iframe = frame->FirstChild(); |
7771 ASSERT_EQ(&client, ToWebLocalFrameBase(iframe)->Client()); | 7769 ASSERT_EQ(&client, ToWebLocalFrameBase(iframe)->Client()); |
7772 | 7770 |
7773 std::string url1 = base_url_ + "history.html"; | 7771 std::string url1 = base_url_ + "history.html"; |
7774 FrameTestHelpers::LoadFrame(iframe, url1); | 7772 FrameTestHelpers::LoadFrame(iframe, url1); |
7775 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); | 7773 EXPECT_EQ(url1, iframe->GetDocument().Url().GetString().Utf8()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7829 PaintLayerCompositor* compositor = web_view_helper.WebView()->Compositor(); | 7827 PaintLayerCompositor* compositor = web_view_helper.WebView()->Compositor(); |
7830 ASSERT_TRUE(compositor->ScrollLayer()); | 7828 ASSERT_TRUE(compositor->ScrollLayer()); |
7831 | 7829 |
7832 // Verify that the WebLayer is not scrollable initially. | 7830 // Verify that the WebLayer is not scrollable initially. |
7833 GraphicsLayer* scroll_layer = compositor->ScrollLayer(); | 7831 GraphicsLayer* scroll_layer = compositor->ScrollLayer(); |
7834 WebLayer* web_scroll_layer = scroll_layer->PlatformLayer(); | 7832 WebLayer* web_scroll_layer = scroll_layer->PlatformLayer(); |
7835 ASSERT_FALSE(web_scroll_layer->UserScrollableHorizontal()); | 7833 ASSERT_FALSE(web_scroll_layer->UserScrollableHorizontal()); |
7836 ASSERT_FALSE(web_scroll_layer->UserScrollableVertical()); | 7834 ASSERT_FALSE(web_scroll_layer->UserScrollableVertical()); |
7837 | 7835 |
7838 // Call javascript to make the layer scrollable, and verify it. | 7836 // Call javascript to make the layer scrollable, and verify it. |
7839 WebLocalFrameBase* frame = | 7837 WebLocalFrameBase* frame = web_view_helper.WebView()->MainFrameImpl(); |
7840 (WebLocalFrameBase*)web_view_helper.WebView()->MainFrame(); | |
7841 frame->ExecuteScript(WebScriptSource("allowScroll();")); | 7838 frame->ExecuteScript(WebScriptSource("allowScroll();")); |
7842 web_view_helper.WebView()->UpdateAllLifecyclePhases(); | 7839 web_view_helper.WebView()->UpdateAllLifecyclePhases(); |
7843 ASSERT_TRUE(web_scroll_layer->UserScrollableHorizontal()); | 7840 ASSERT_TRUE(web_scroll_layer->UserScrollableHorizontal()); |
7844 ASSERT_TRUE(web_scroll_layer->UserScrollableVertical()); | 7841 ASSERT_TRUE(web_scroll_layer->UserScrollableVertical()); |
7845 } | 7842 } |
7846 | 7843 |
7847 // Test that currentHistoryItem reflects the current page, not the provisional | 7844 // Test that currentHistoryItem reflects the current page, not the provisional |
7848 // load. | 7845 // load. |
7849 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { | 7846 TEST_P(ParameterizedWebFrameTest, CurrentHistoryItem) { |
7850 RegisterMockedHttpURLLoad("fixed_layout.html"); | 7847 RegisterMockedHttpURLLoad("fixed_layout.html"); |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8891 RegisterMockedHttpURLLoad("frame-a-b-c.html"); | 8888 RegisterMockedHttpURLLoad("frame-a-b-c.html"); |
8892 RegisterMockedHttpURLLoad("subframe-a.html"); | 8889 RegisterMockedHttpURLLoad("subframe-a.html"); |
8893 RegisterMockedHttpURLLoad("subframe-b.html"); | 8890 RegisterMockedHttpURLLoad("subframe-b.html"); |
8894 RegisterMockedHttpURLLoad("subframe-c.html"); | 8891 RegisterMockedHttpURLLoad("subframe-c.html"); |
8895 RegisterMockedHttpURLLoad("subframe-hello.html"); | 8892 RegisterMockedHttpURLLoad("subframe-hello.html"); |
8896 | 8893 |
8897 web_view_helper_.InitializeAndLoad(base_url_ + "frame-a-b-c.html", true); | 8894 web_view_helper_.InitializeAndLoad(base_url_ + "frame-a-b-c.html", true); |
8898 } | 8895 } |
8899 | 8896 |
8900 void Reset() { web_view_helper_.Reset(); } | 8897 void Reset() { web_view_helper_.Reset(); } |
8901 WebFrame* MainFrame() const { | 8898 WebLocalFrame* MainFrame() const { |
8902 return web_view_helper_.WebView()->MainFrame(); | 8899 return web_view_helper_.WebView()->MainFrameImpl(); |
8903 } | 8900 } |
8904 WebViewBase* WebView() const { return web_view_helper_.WebView(); } | 8901 WebViewBase* WebView() const { return web_view_helper_.WebView(); } |
8905 | 8902 |
8906 private: | 8903 private: |
8907 FrameTestHelpers::WebViewHelper web_view_helper_; | 8904 FrameTestHelpers::WebViewHelper web_view_helper_; |
8908 }; | 8905 }; |
8909 | 8906 |
8910 TEST_F(WebFrameSwapTest, SwapMainFrame) { | 8907 TEST_F(WebFrameSwapTest, SwapMainFrame) { |
8911 WebRemoteFrame* remote_frame = | 8908 WebRemoteFrame* remote_frame = |
8912 WebRemoteFrame::Create(WebTreeScopeType::kDocument, nullptr); | 8909 WebRemoteFrame::Create(WebTreeScopeType::kDocument, nullptr); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9553 Reset(); | 9550 Reset(); |
9554 } | 9551 } |
9555 | 9552 |
9556 TEST_F(WebFrameSwapTest, WindowOpenOnRemoteFrame) { | 9553 TEST_F(WebFrameSwapTest, WindowOpenOnRemoteFrame) { |
9557 RemoteNavigationClient remote_client; | 9554 RemoteNavigationClient remote_client; |
9558 WebRemoteFrame* remote_frame = remote_client.GetFrame(); | 9555 WebRemoteFrame* remote_frame = remote_client.GetFrame(); |
9559 MainFrame()->FirstChild()->Swap(remote_frame); | 9556 MainFrame()->FirstChild()->Swap(remote_frame); |
9560 remote_frame->SetReplicatedOrigin( | 9557 remote_frame->SetReplicatedOrigin( |
9561 WebSecurityOrigin::CreateFromString("http://127.0.0.1")); | 9558 WebSecurityOrigin::CreateFromString("http://127.0.0.1")); |
9562 | 9559 |
9563 ASSERT_TRUE(MainFrame()->IsWebLocalFrame()); | |
9564 ASSERT_TRUE(MainFrame()->FirstChild()->IsWebRemoteFrame()); | 9560 ASSERT_TRUE(MainFrame()->FirstChild()->IsWebRemoteFrame()); |
9565 LocalDOMWindow* main_window = | 9561 LocalDOMWindow* main_window = |
9566 ToWebLocalFrameBase(MainFrame())->GetFrame()->DomWindow(); | 9562 ToWebLocalFrameBase(MainFrame())->GetFrame()->DomWindow(); |
9567 | 9563 |
9568 KURL destination = ToKURL("data:text/html:destination"); | 9564 KURL destination = ToKURL("data:text/html:destination"); |
9569 NonThrowableExceptionState exception_state; | 9565 NonThrowableExceptionState exception_state; |
9570 main_window->open(destination.GetString(), "frame1", "", main_window, | 9566 main_window->open(destination.GetString(), "frame1", "", main_window, |
9571 main_window, exception_state); | 9567 main_window, exception_state); |
9572 ASSERT_FALSE(remote_client.LastRequest().IsNull()); | 9568 ASSERT_FALSE(remote_client.LastRequest().IsNull()); |
9573 EXPECT_EQ(remote_client.LastRequest().Url(), WebURL(destination)); | 9569 EXPECT_EQ(remote_client.LastRequest().Url(), WebURL(destination)); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9834 FrameTestHelpers::WebViewHelper web_view_helper; | 9830 FrameTestHelpers::WebViewHelper web_view_helper; |
9835 TestConsoleMessageWebFrameClient web_frame_client; | 9831 TestConsoleMessageWebFrameClient web_frame_client; |
9836 FrameTestHelpers::TestWebViewClient web_view_client; | 9832 FrameTestHelpers::TestWebViewClient web_view_client; |
9837 web_view_helper.InitializeAndLoad(base_url_ + "hidden_frames.html", true, | 9833 web_view_helper.InitializeAndLoad(base_url_ + "hidden_frames.html", true, |
9838 &web_frame_client, &web_view_client); | 9834 &web_frame_client, &web_view_client); |
9839 | 9835 |
9840 // Create another window with a cross-origin page, and point its opener to | 9836 // Create another window with a cross-origin page, and point its opener to |
9841 // first window. | 9837 // first window. |
9842 FrameTestHelpers::WebViewHelper popup_web_view_helper; | 9838 FrameTestHelpers::WebViewHelper popup_web_view_helper; |
9843 TestConsoleMessageWebFrameClient popup_web_frame_client; | 9839 TestConsoleMessageWebFrameClient popup_web_frame_client; |
9844 WebView* popup_view = popup_web_view_helper.InitializeAndLoad( | 9840 WebViewBase* popup_view = popup_web_view_helper.InitializeAndLoad( |
9845 chrome_url_ + "hello_world.html", true, &popup_web_frame_client); | 9841 chrome_url_ + "hello_world.html", true, &popup_web_frame_client); |
9846 popup_view->MainFrame()->SetOpener(web_view_helper.WebView()->MainFrame()); | 9842 popup_view->MainFrame()->SetOpener(web_view_helper.WebView()->MainFrame()); |
9847 | 9843 |
9848 // Attempt a blocked navigation of an opener's subframe, and ensure that | 9844 // Attempt a blocked navigation of an opener's subframe, and ensure that |
9849 // the error shows up on the popup (calling) window's console, rather than | 9845 // the error shows up on the popup (calling) window's console, rather than |
9850 // the target window. | 9846 // the target window. |
9851 popup_view->MainFrame()->ExecuteScript(WebScriptSource( | 9847 popup_view->MainFrameImpl()->ExecuteScript(WebScriptSource( |
9852 "try { opener.frames[1].location.href='data:text/html,foo'; } catch (e) " | 9848 "try { opener.frames[1].location.href='data:text/html,foo'; } catch (e) " |
9853 "{}")); | 9849 "{}")); |
9854 EXPECT_TRUE(web_frame_client.messages.IsEmpty()); | 9850 EXPECT_TRUE(web_frame_client.messages.IsEmpty()); |
9855 ASSERT_EQ(1u, popup_web_frame_client.messages.size()); | 9851 ASSERT_EQ(1u, popup_web_frame_client.messages.size()); |
9856 EXPECT_TRUE(std::string::npos != | 9852 EXPECT_TRUE(std::string::npos != |
9857 popup_web_frame_client.messages[0].text.Utf8().find( | 9853 popup_web_frame_client.messages[0].text.Utf8().find( |
9858 "Unsafe JavaScript attempt to initiate navigation")); | 9854 "Unsafe JavaScript attempt to initiate navigation")); |
9859 | 9855 |
9860 // Try setting a cross-origin iframe element's source to a javascript: URL, | 9856 // Try setting a cross-origin iframe element's source to a javascript: URL, |
9861 // and check that this error is also printed on the calling window. | 9857 // and check that this error is also printed on the calling window. |
9862 popup_view->MainFrame()->ExecuteScript( | 9858 popup_view->MainFrameImpl()->ExecuteScript( |
9863 WebScriptSource("opener.document.querySelectorAll('iframe')[1].src='" | 9859 WebScriptSource("opener.document.querySelectorAll('iframe')[1].src='" |
9864 "javascript:alert()'")); | 9860 "javascript:alert()'")); |
9865 EXPECT_TRUE(web_frame_client.messages.IsEmpty()); | 9861 EXPECT_TRUE(web_frame_client.messages.IsEmpty()); |
9866 ASSERT_EQ(2u, popup_web_frame_client.messages.size()); | 9862 ASSERT_EQ(2u, popup_web_frame_client.messages.size()); |
9867 EXPECT_TRUE( | 9863 EXPECT_TRUE( |
9868 std::string::npos != | 9864 std::string::npos != |
9869 popup_web_frame_client.messages[1].text.Utf8().find("Blocked a frame")); | 9865 popup_web_frame_client.messages[1].text.Utf8().find("Blocked a frame")); |
9870 | 9866 |
9871 // Manually reset to break WebViewHelpers' dependencies on the stack | 9867 // Manually reset to break WebViewHelpers' dependencies on the stack |
9872 // allocated WebFrameClients. | 9868 // allocated WebFrameClients. |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10543 bool visible_; | 10539 bool visible_; |
10544 }; | 10540 }; |
10545 | 10541 |
10546 class WebFrameVisibilityChangeTest : public WebFrameTest { | 10542 class WebFrameVisibilityChangeTest : public WebFrameTest { |
10547 public: | 10543 public: |
10548 WebFrameVisibilityChangeTest() { | 10544 WebFrameVisibilityChangeTest() { |
10549 RegisterMockedHttpURLLoad("visible_iframe.html"); | 10545 RegisterMockedHttpURLLoad("visible_iframe.html"); |
10550 RegisterMockedHttpURLLoad("single_iframe.html"); | 10546 RegisterMockedHttpURLLoad("single_iframe.html"); |
10551 frame_ = web_view_helper_ | 10547 frame_ = web_view_helper_ |
10552 .InitializeAndLoad(base_url_ + "single_iframe.html", true) | 10548 .InitializeAndLoad(base_url_ + "single_iframe.html", true) |
10553 ->MainFrame(); | 10549 ->MainFrameImpl(); |
10554 web_remote_frame_ = RemoteFrameClient()->GetFrame(); | 10550 web_remote_frame_ = RemoteFrameClient()->GetFrame(); |
10555 } | 10551 } |
10556 | 10552 |
10557 ~WebFrameVisibilityChangeTest() {} | 10553 ~WebFrameVisibilityChangeTest() {} |
10558 | 10554 |
10559 void ExecuteScriptOnMainFrame(const WebScriptSource& script) { | 10555 void ExecuteScriptOnMainFrame(const WebScriptSource& script) { |
10560 MainFrame()->ExecuteScript(script); | 10556 MainFrame()->ExecuteScript(script); |
10561 MainFrame()->View()->UpdateAllLifecyclePhases(); | 10557 MainFrame()->View()->UpdateAllLifecyclePhases(); |
10562 RunPendingTasks(); | 10558 RunPendingTasks(); |
10563 } | 10559 } |
10564 | 10560 |
10565 void SwapLocalFrameToRemoteFrame() { | 10561 void SwapLocalFrameToRemoteFrame() { |
10566 LastChild(MainFrame())->Swap(RemoteFrame()); | 10562 LastChild(MainFrame())->Swap(RemoteFrame()); |
10567 RemoteFrame()->SetReplicatedOrigin(SecurityOrigin::CreateUnique()); | 10563 RemoteFrame()->SetReplicatedOrigin(SecurityOrigin::CreateUnique()); |
10568 } | 10564 } |
10569 | 10565 |
10570 WebFrame* MainFrame() { return frame_; } | 10566 WebLocalFrame* MainFrame() { return frame_; } |
10571 WebRemoteFrameImpl* RemoteFrame() { return web_remote_frame_; } | 10567 WebRemoteFrameImpl* RemoteFrame() { return web_remote_frame_; } |
10572 TestWebRemoteFrameClientForVisibility* RemoteFrameClient() { | 10568 TestWebRemoteFrameClientForVisibility* RemoteFrameClient() { |
10573 return &remote_frame_client_; | 10569 return &remote_frame_client_; |
10574 } | 10570 } |
10575 | 10571 |
10576 private: | 10572 private: |
10577 TestWebRemoteFrameClientForVisibility remote_frame_client_; | 10573 TestWebRemoteFrameClientForVisibility remote_frame_client_; |
10578 FrameTestHelpers::WebViewHelper web_view_helper_; | 10574 FrameTestHelpers::WebViewHelper web_view_helper_; |
10579 WebFrame* frame_; | 10575 WebLocalFrame* frame_; |
10580 Persistent<WebRemoteFrameImpl> web_remote_frame_; | 10576 Persistent<WebRemoteFrameImpl> web_remote_frame_; |
10581 }; | 10577 }; |
10582 | 10578 |
10583 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameVisibilityChange) { | 10579 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameVisibilityChange) { |
10584 SwapLocalFrameToRemoteFrame(); | 10580 SwapLocalFrameToRemoteFrame(); |
10585 ExecuteScriptOnMainFrame(WebScriptSource( | 10581 ExecuteScriptOnMainFrame(WebScriptSource( |
10586 "document.querySelector('iframe').style.display = 'none';")); | 10582 "document.querySelector('iframe').style.display = 'none';")); |
10587 EXPECT_FALSE(RemoteFrameClient()->IsVisible()); | 10583 EXPECT_FALSE(RemoteFrameClient()->IsVisible()); |
10588 | 10584 |
10589 ExecuteScriptOnMainFrame(WebScriptSource( | 10585 ExecuteScriptOnMainFrame(WebScriptSource( |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12185 if (obj->IsText()) { | 12181 if (obj->IsText()) { |
12186 LayoutText* layout_text = ToLayoutText(obj); | 12182 LayoutText* layout_text = ToLayoutText(obj); |
12187 text = layout_text->GetText(); | 12183 text = layout_text->GetText(); |
12188 break; | 12184 break; |
12189 } | 12185 } |
12190 } | 12186 } |
12191 EXPECT_EQ("foo alt", text.Utf8()); | 12187 EXPECT_EQ("foo alt", text.Utf8()); |
12192 } | 12188 } |
12193 | 12189 |
12194 } // namespace blink | 12190 } // namespace blink |
OLD | NEW |