| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) { | 395 TEST_P(ParameterizedWebFrameTest, FrameForEnteredContext) { |
| 396 RegisterMockedHttpURLLoad("iframes_test.html"); | 396 RegisterMockedHttpURLLoad("iframes_test.html"); |
| 397 RegisterMockedHttpURLLoad("visible_iframe.html"); | 397 RegisterMockedHttpURLLoad("visible_iframe.html"); |
| 398 RegisterMockedHttpURLLoad("invisible_iframe.html"); | 398 RegisterMockedHttpURLLoad("invisible_iframe.html"); |
| 399 RegisterMockedHttpURLLoad("zero_sized_iframe.html"); | 399 RegisterMockedHttpURLLoad("zero_sized_iframe.html"); |
| 400 | 400 |
| 401 FrameTestHelpers::WebViewHelper web_view_helper; | 401 FrameTestHelpers::WebViewHelper web_view_helper; |
| 402 web_view_helper.InitializeAndLoad(base_url_ + "iframes_test.html", true); | 402 web_view_helper.InitializeAndLoad(base_url_ + "iframes_test.html", true); |
| 403 | 403 |
| 404 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 404 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 405 EXPECT_EQ( | 405 EXPECT_EQ(web_view_helper.WebView()->MainFrame(), |
| 406 web_view_helper.WebView()->MainFrame(), | 406 WebLocalFrame::FrameForContext(web_view_helper.WebView() |
| 407 WebLocalFrame::FrameForContext( | 407 ->MainFrameImpl() |
| 408 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext())); | 408 ->MainWorldScriptContext())); |
| 409 EXPECT_EQ(web_view_helper.WebView()->MainFrame()->FirstChild(), | 409 EXPECT_EQ(web_view_helper.WebView()->MainFrame()->FirstChild(), |
| 410 WebLocalFrame::FrameForContext(web_view_helper.WebView() | 410 WebLocalFrame::FrameForContext(web_view_helper.WebView() |
| 411 ->MainFrame() | 411 ->MainFrame() |
| 412 ->FirstChild() | 412 ->FirstChild() |
| 413 ->ToWebLocalFrame() |
| 413 ->MainWorldScriptContext())); | 414 ->MainWorldScriptContext())); |
| 414 } | 415 } |
| 415 | 416 |
| 416 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { | 417 class ScriptExecutionCallbackHelper : public WebScriptExecutionCallback { |
| 417 public: | 418 public: |
| 418 explicit ScriptExecutionCallbackHelper(v8::Local<v8::Context> context) | 419 explicit ScriptExecutionCallbackHelper(v8::Local<v8::Context> context) |
| 419 : did_complete_(false), bool_value_(false), context_(context) {} | 420 : did_complete_(false), bool_value_(false), context_(context) {} |
| 420 ~ScriptExecutionCallbackHelper() {} | 421 ~ScriptExecutionCallbackHelper() {} |
| 421 | 422 |
| 422 bool DidComplete() const { return did_complete_; } | 423 bool DidComplete() const { return did_complete_; } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 443 }; | 444 }; |
| 444 | 445 |
| 445 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { | 446 TEST_P(ParameterizedWebFrameTest, RequestExecuteScript) { |
| 446 RegisterMockedHttpURLLoad("foo.html"); | 447 RegisterMockedHttpURLLoad("foo.html"); |
| 447 | 448 |
| 448 FrameTestHelpers::WebViewHelper web_view_helper; | 449 FrameTestHelpers::WebViewHelper web_view_helper; |
| 449 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 450 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
| 450 | 451 |
| 451 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 452 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 452 ScriptExecutionCallbackHelper callback_helper( | 453 ScriptExecutionCallbackHelper callback_helper( |
| 453 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext()); | 454 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); |
| 454 web_view_helper.WebView() | 455 web_view_helper.WebView() |
| 455 ->MainFrameImpl() | 456 ->MainFrameImpl() |
| 456 ->RequestExecuteScriptAndReturnValue( | 457 ->RequestExecuteScriptAndReturnValue( |
| 457 WebScriptSource(WebString("'hello';")), false, &callback_helper); | 458 WebScriptSource(WebString("'hello';")), false, &callback_helper); |
| 458 RunPendingTasks(); | 459 RunPendingTasks(); |
| 459 EXPECT_TRUE(callback_helper.DidComplete()); | 460 EXPECT_TRUE(callback_helper.DidComplete()); |
| 460 EXPECT_EQ("hello", callback_helper.StringValue()); | 461 EXPECT_EQ("hello", callback_helper.StringValue()); |
| 461 } | 462 } |
| 462 | 463 |
| 463 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { | 464 TEST_P(ParameterizedWebFrameTest, SuspendedRequestExecuteScript) { |
| 464 RegisterMockedHttpURLLoad("foo.html"); | 465 RegisterMockedHttpURLLoad("foo.html"); |
| 465 RegisterMockedHttpURLLoad("bar.html"); | 466 RegisterMockedHttpURLLoad("bar.html"); |
| 466 | 467 |
| 467 FrameTestHelpers::WebViewHelper web_view_helper; | 468 FrameTestHelpers::WebViewHelper web_view_helper; |
| 468 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 469 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
| 469 | 470 |
| 470 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 471 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 471 ScriptExecutionCallbackHelper callback_helper( | 472 ScriptExecutionCallbackHelper callback_helper( |
| 472 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext()); | 473 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); |
| 473 | 474 |
| 474 // Suspend scheduled tasks so the script doesn't run. | 475 // Suspend scheduled tasks so the script doesn't run. |
| 475 web_view_helper.WebView() | 476 web_view_helper.WebView() |
| 476 ->MainFrameImpl() | 477 ->MainFrameImpl() |
| 477 ->GetFrame() | 478 ->GetFrame() |
| 478 ->GetDocument() | 479 ->GetDocument() |
| 479 ->SuspendScheduledTasks(); | 480 ->SuspendScheduledTasks(); |
| 480 web_view_helper.WebView() | 481 web_view_helper.WebView() |
| 481 ->MainFrameImpl() | 482 ->MainFrameImpl() |
| 482 ->RequestExecuteScriptAndReturnValue( | 483 ->RequestExecuteScriptAndReturnValue( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 497 | 498 |
| 498 FrameTestHelpers::WebViewHelper web_view_helper; | 499 FrameTestHelpers::WebViewHelper web_view_helper; |
| 499 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 500 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
| 500 | 501 |
| 501 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 502 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 502 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); | 503 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); |
| 503 }; | 504 }; |
| 504 | 505 |
| 505 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 506 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 506 v8::Local<v8::Context> context = | 507 v8::Local<v8::Context> context = |
| 507 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext(); | 508 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); |
| 508 ScriptExecutionCallbackHelper callback_helper(context); | 509 ScriptExecutionCallbackHelper callback_helper(context); |
| 509 v8::Local<v8::Function> function = | 510 v8::Local<v8::Function> function = |
| 510 v8::Function::New(context, callback).ToLocalChecked(); | 511 v8::Function::New(context, callback).ToLocalChecked(); |
| 511 web_view_helper.WebView() | 512 web_view_helper.WebView() |
| 512 ->MainFrame() | 513 ->MainFrame() |
| 513 ->ToWebLocalFrame() | 514 ->ToWebLocalFrame() |
| 514 ->RequestExecuteV8Function(context, function, | 515 ->RequestExecuteV8Function(context, function, |
| 515 v8::Undefined(context->GetIsolate()), 0, | 516 v8::Undefined(context->GetIsolate()), 0, |
| 516 nullptr, &callback_helper); | 517 nullptr, &callback_helper); |
| 517 RunPendingTasks(); | 518 RunPendingTasks(); |
| 518 EXPECT_TRUE(callback_helper.DidComplete()); | 519 EXPECT_TRUE(callback_helper.DidComplete()); |
| 519 EXPECT_EQ("hello", callback_helper.StringValue()); | 520 EXPECT_EQ("hello", callback_helper.StringValue()); |
| 520 } | 521 } |
| 521 | 522 |
| 522 TEST_P(ParameterizedWebFrameTest, RequestExecuteV8FunctionWhileSuspended) { | 523 TEST_P(ParameterizedWebFrameTest, RequestExecuteV8FunctionWhileSuspended) { |
| 523 RegisterMockedHttpURLLoad("foo.html"); | 524 RegisterMockedHttpURLLoad("foo.html"); |
| 524 | 525 |
| 525 FrameTestHelpers::WebViewHelper web_view_helper; | 526 FrameTestHelpers::WebViewHelper web_view_helper; |
| 526 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); | 527 web_view_helper.InitializeAndLoad(base_url_ + "foo.html", true); |
| 527 | 528 |
| 528 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 529 auto callback = [](const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 529 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); | 530 info.GetReturnValue().Set(V8String(info.GetIsolate(), "hello")); |
| 530 }; | 531 }; |
| 531 | 532 |
| 532 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 533 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 533 v8::Local<v8::Context> context = | 534 v8::Local<v8::Context> context = |
| 534 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext(); | 535 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); |
| 535 | 536 |
| 536 // Suspend scheduled tasks so the script doesn't run. | 537 // Suspend scheduled tasks so the script doesn't run. |
| 537 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 538 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); |
| 538 main_frame->GetFrame()->GetDocument()->SuspendScheduledTasks(); | 539 main_frame->GetFrame()->GetDocument()->SuspendScheduledTasks(); |
| 539 | 540 |
| 540 ScriptExecutionCallbackHelper callback_helper(context); | 541 ScriptExecutionCallbackHelper callback_helper(context); |
| 541 v8::Local<v8::Function> function = | 542 v8::Local<v8::Function> function = |
| 542 v8::Function::New(context, callback).ToLocalChecked(); | 543 v8::Function::New(context, callback).ToLocalChecked(); |
| 543 main_frame->RequestExecuteV8Function(context, function, | 544 main_frame->RequestExecuteV8Function(context, function, |
| 544 v8::Undefined(context->GetIsolate()), 0, | 545 v8::Undefined(context->GetIsolate()), 0, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 564 info.GetIsolate(), UserGestureIndicator::ProcessingUserGesture())); | 565 info.GetIsolate(), UserGestureIndicator::ProcessingUserGesture())); |
| 565 }; | 566 }; |
| 566 | 567 |
| 567 // Suspend scheduled tasks so the script doesn't run. | 568 // Suspend scheduled tasks so the script doesn't run. |
| 568 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); | 569 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); |
| 569 Document* document = main_frame->GetFrame()->GetDocument(); | 570 Document* document = main_frame->GetFrame()->GetDocument(); |
| 570 document->SuspendScheduledTasks(); | 571 document->SuspendScheduledTasks(); |
| 571 | 572 |
| 572 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 573 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 573 v8::Local<v8::Context> context = | 574 v8::Local<v8::Context> context = |
| 574 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext(); | 575 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(); |
| 575 | 576 |
| 576 std::unique_ptr<UserGestureIndicator> indicator = | 577 std::unique_ptr<UserGestureIndicator> indicator = |
| 577 WTF::WrapUnique(new UserGestureIndicator( | 578 WTF::WrapUnique(new UserGestureIndicator( |
| 578 UserGestureToken::Create(document, UserGestureToken::kNewGesture))); | 579 UserGestureToken::Create(document, UserGestureToken::kNewGesture))); |
| 579 ScriptExecutionCallbackHelper callback_helper(context); | 580 ScriptExecutionCallbackHelper callback_helper(context); |
| 580 v8::Local<v8::Function> function = | 581 v8::Local<v8::Function> function = |
| 581 v8::Function::New(context, callback).ToLocalChecked(); | 582 v8::Function::New(context, callback).ToLocalChecked(); |
| 582 main_frame->RequestExecuteV8Function( | 583 main_frame->RequestExecuteV8Function( |
| 583 main_frame->MainWorldScriptContext(), function, | 584 main_frame->MainWorldScriptContext(), function, |
| 584 v8::Undefined(context->GetIsolate()), 0, nullptr, &callback_helper); | 585 v8::Undefined(context->GetIsolate()), 0, nullptr, &callback_helper); |
| 585 | 586 |
| 586 RunPendingTasks(); | 587 RunPendingTasks(); |
| 587 EXPECT_FALSE(callback_helper.DidComplete()); | 588 EXPECT_FALSE(callback_helper.DidComplete()); |
| 588 | 589 |
| 589 main_frame->GetFrame()->GetDocument()->ResumeScheduledTasks(); | 590 main_frame->GetFrame()->GetDocument()->ResumeScheduledTasks(); |
| 590 RunPendingTasks(); | 591 RunPendingTasks(); |
| 591 EXPECT_TRUE(callback_helper.DidComplete()); | 592 EXPECT_TRUE(callback_helper.DidComplete()); |
| 592 EXPECT_EQ(true, callback_helper.BoolValue()); | 593 EXPECT_EQ(true, callback_helper.BoolValue()); |
| 593 } | 594 } |
| 594 | 595 |
| 595 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { | 596 TEST_P(ParameterizedWebFrameTest, IframeScriptRemovesSelf) { |
| 596 RegisterMockedHttpURLLoad("single_iframe.html"); | 597 RegisterMockedHttpURLLoad("single_iframe.html"); |
| 597 RegisterMockedHttpURLLoad("visible_iframe.html"); | 598 RegisterMockedHttpURLLoad("visible_iframe.html"); |
| 598 | 599 |
| 599 FrameTestHelpers::WebViewHelper web_view_helper; | 600 FrameTestHelpers::WebViewHelper web_view_helper; |
| 600 web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html", true); | 601 web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html", true); |
| 601 | 602 |
| 602 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 603 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 603 ScriptExecutionCallbackHelper callback_helper( | 604 ScriptExecutionCallbackHelper callback_helper( |
| 604 web_view_helper.WebView()->MainFrame()->MainWorldScriptContext()); | 605 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext()); |
| 605 web_view_helper.WebView() | 606 web_view_helper.WebView() |
| 606 ->MainFrame() | 607 ->MainFrame() |
| 607 ->FirstChild() | 608 ->FirstChild() |
| 608 ->ToWebLocalFrame() | 609 ->ToWebLocalFrame() |
| 609 ->RequestExecuteScriptAndReturnValue( | 610 ->RequestExecuteScriptAndReturnValue( |
| 610 WebScriptSource(WebString( | 611 WebScriptSource(WebString( |
| 611 "var iframe = " | 612 "var iframe = " |
| 612 "window.top.document.getElementsByTagName('iframe')[0]; " | 613 "window.top.document.getElementsByTagName('iframe')[0]; " |
| 613 "window.top.document.body.removeChild(iframe); 'hello';")), | 614 "window.top.document.body.removeChild(iframe); 'hello';")), |
| 614 false, &callback_helper); | 615 false, &callback_helper); |
| (...skipping 3949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4564 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> | 4565 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> |
| 4565 create_notifications; | 4566 create_notifications; |
| 4566 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> | 4567 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> |
| 4567 release_notifications; | 4568 release_notifications; |
| 4568 ContextLifetimeTestMainFrameClient web_frame_client(create_notifications, | 4569 ContextLifetimeTestMainFrameClient web_frame_client(create_notifications, |
| 4569 release_notifications); | 4570 release_notifications); |
| 4570 FrameTestHelpers::WebViewHelper web_view_helper; | 4571 FrameTestHelpers::WebViewHelper web_view_helper; |
| 4571 web_view_helper.InitializeAndLoad( | 4572 web_view_helper.InitializeAndLoad( |
| 4572 base_url_ + "context_notifications_test.html", true, &web_frame_client); | 4573 base_url_ + "context_notifications_test.html", true, &web_frame_client); |
| 4573 | 4574 |
| 4574 WebFrame* main_frame = web_view_helper.WebView()->MainFrame(); | 4575 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); |
| 4575 WebFrame* child_frame = main_frame->FirstChild(); | 4576 WebFrame* child_frame = main_frame->FirstChild(); |
| 4576 | 4577 |
| 4577 ASSERT_EQ(2u, create_notifications.size()); | 4578 ASSERT_EQ(2u, create_notifications.size()); |
| 4578 EXPECT_EQ(0u, release_notifications.size()); | 4579 EXPECT_EQ(0u, release_notifications.size()); |
| 4579 | 4580 |
| 4580 auto& first_create_notification = create_notifications[0]; | 4581 auto& first_create_notification = create_notifications[0]; |
| 4581 auto& second_create_notification = create_notifications[1]; | 4582 auto& second_create_notification = create_notifications[1]; |
| 4582 | 4583 |
| 4583 EXPECT_EQ(main_frame, first_create_notification->frame); | 4584 EXPECT_EQ(main_frame, first_create_notification->frame); |
| 4584 EXPECT_EQ(main_frame->MainWorldScriptContext(), | 4585 EXPECT_EQ(main_frame->MainWorldScriptContext(), |
| 4585 first_create_notification->context); | 4586 first_create_notification->context); |
| 4586 EXPECT_EQ(0, first_create_notification->world_id); | 4587 EXPECT_EQ(0, first_create_notification->world_id); |
| 4587 | 4588 |
| 4588 EXPECT_EQ(child_frame, second_create_notification->frame); | 4589 EXPECT_EQ(child_frame, second_create_notification->frame); |
| 4589 EXPECT_EQ(child_frame->MainWorldScriptContext(), | 4590 EXPECT_EQ(child_frame->ToWebLocalFrame()->MainWorldScriptContext(), |
| 4590 second_create_notification->context); | 4591 second_create_notification->context); |
| 4591 EXPECT_EQ(0, second_create_notification->world_id); | 4592 EXPECT_EQ(0, second_create_notification->world_id); |
| 4592 | 4593 |
| 4593 // Close the view. We should get two release notifications that are exactly | 4594 // Close the view. We should get two release notifications that are exactly |
| 4594 // the same as the create ones, in reverse order. | 4595 // the same as the create ones, in reverse order. |
| 4595 web_view_helper.Reset(); | 4596 web_view_helper.Reset(); |
| 4596 | 4597 |
| 4597 ASSERT_EQ(2u, release_notifications.size()); | 4598 ASSERT_EQ(2u, release_notifications.size()); |
| 4598 auto& first_release_notification = release_notifications[0]; | 4599 auto& first_release_notification = release_notifications[0]; |
| 4599 auto& second_release_notification = release_notifications[1]; | 4600 auto& second_release_notification = release_notifications[1]; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4628 | 4629 |
| 4629 // The two release notifications we got should be exactly the same as the | 4630 // The two release notifications we got should be exactly the same as the |
| 4630 // first two create notifications. | 4631 // first two create notifications. |
| 4631 for (size_t i = 0; i < release_notifications.size(); ++i) { | 4632 for (size_t i = 0; i < release_notifications.size(); ++i) { |
| 4632 EXPECT_TRUE(release_notifications[i]->Equals( | 4633 EXPECT_TRUE(release_notifications[i]->Equals( |
| 4633 create_notifications[create_notifications.size() - 3 - i].get())); | 4634 create_notifications[create_notifications.size() - 3 - i].get())); |
| 4634 } | 4635 } |
| 4635 | 4636 |
| 4636 // The last two create notifications should be for the current frames and | 4637 // The last two create notifications should be for the current frames and |
| 4637 // context. | 4638 // context. |
| 4638 WebFrame* main_frame = web_view_helper.WebView()->MainFrame(); | 4639 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl(); |
| 4639 WebFrame* child_frame = main_frame->FirstChild(); | 4640 WebFrame* child_frame = main_frame->FirstChild(); |
| 4640 auto& first_refresh_notification = create_notifications[2]; | 4641 auto& first_refresh_notification = create_notifications[2]; |
| 4641 auto& second_refresh_notification = create_notifications[3]; | 4642 auto& second_refresh_notification = create_notifications[3]; |
| 4642 | 4643 |
| 4643 EXPECT_EQ(main_frame, first_refresh_notification->frame); | 4644 EXPECT_EQ(main_frame, first_refresh_notification->frame); |
| 4644 EXPECT_EQ(main_frame->MainWorldScriptContext(), | 4645 EXPECT_EQ(main_frame->MainWorldScriptContext(), |
| 4645 first_refresh_notification->context); | 4646 first_refresh_notification->context); |
| 4646 EXPECT_EQ(0, first_refresh_notification->world_id); | 4647 EXPECT_EQ(0, first_refresh_notification->world_id); |
| 4647 | 4648 |
| 4648 EXPECT_EQ(child_frame, second_refresh_notification->frame); | 4649 EXPECT_EQ(child_frame, second_refresh_notification->frame); |
| 4649 EXPECT_EQ(child_frame->MainWorldScriptContext(), | 4650 EXPECT_EQ(child_frame->ToWebLocalFrame()->MainWorldScriptContext(), |
| 4650 second_refresh_notification->context); | 4651 second_refresh_notification->context); |
| 4651 EXPECT_EQ(0, second_refresh_notification->world_id); | 4652 EXPECT_EQ(0, second_refresh_notification->world_id); |
| 4652 } | 4653 } |
| 4653 | 4654 |
| 4654 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) { | 4655 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) { |
| 4655 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 4656 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 4656 v8::HandleScope handle_scope(isolate); | 4657 v8::HandleScope handle_scope(isolate); |
| 4657 | 4658 |
| 4658 RegisterMockedHttpURLLoad("context_notifications_test.html"); | 4659 RegisterMockedHttpURLLoad("context_notifications_test.html"); |
| 4659 RegisterMockedHttpURLLoad("context_notifications_test_frame.html"); | 4660 RegisterMockedHttpURLLoad("context_notifications_test_frame.html"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4678 isolated_world_id, &script_source, num_sources); | 4679 isolated_world_id, &script_source, num_sources); |
| 4679 | 4680 |
| 4680 // We should now have a new create notification. | 4681 // We should now have a new create notification. |
| 4681 ASSERT_EQ(1u, create_notifications.size()); | 4682 ASSERT_EQ(1u, create_notifications.size()); |
| 4682 auto& notification = create_notifications[0]; | 4683 auto& notification = create_notifications[0]; |
| 4683 ASSERT_EQ(isolated_world_id, notification->world_id); | 4684 ASSERT_EQ(isolated_world_id, notification->world_id); |
| 4684 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); | 4685 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); |
| 4685 | 4686 |
| 4686 // We don't have an API to enumarate isolated worlds for a frame, but we can | 4687 // We don't have an API to enumarate isolated worlds for a frame, but we can |
| 4687 // at least assert that the context we got is *not* the main world's context. | 4688 // at least assert that the context we got is *not* the main world's context. |
| 4688 ASSERT_NE(web_view_helper.WebView()->MainFrame()->MainWorldScriptContext(), | 4689 ASSERT_NE( |
| 4689 v8::Local<v8::Context>::New(isolate, notification->context)); | 4690 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(), |
| 4691 v8::Local<v8::Context>::New(isolate, notification->context)); |
| 4690 | 4692 |
| 4691 web_view_helper.Reset(); | 4693 web_view_helper.Reset(); |
| 4692 | 4694 |
| 4693 // We should have gotten three release notifications (one for each of the | 4695 // We should have gotten three release notifications (one for each of the |
| 4694 // frames, plus one for the isolated context). | 4696 // frames, plus one for the isolated context). |
| 4695 ASSERT_EQ(3u, release_notifications.size()); | 4697 ASSERT_EQ(3u, release_notifications.size()); |
| 4696 | 4698 |
| 4697 // And one of them should be exactly the same as the create notification for | 4699 // And one of them should be exactly the same as the create notification for |
| 4698 // the isolated context. | 4700 // the isolated context. |
| 4699 int match_count = 0; | 4701 int match_count = 0; |
| (...skipping 5232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9932 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height); | 9934 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height); |
| 9933 client_.screen_info_.available_rect = client_.screen_info_.rect; | 9935 client_.screen_info_.available_rect = client_.screen_info_.rect; |
| 9934 web_view_helper_.Resize(size); | 9936 web_view_helper_.Resize(size); |
| 9935 EXPECT_EQ(expected_size, DumpSize("test")); | 9937 EXPECT_EQ(expected_size, DumpSize("test")); |
| 9936 } | 9938 } |
| 9937 | 9939 |
| 9938 String DumpSize(const String& id) { | 9940 String DumpSize(const String& id) { |
| 9939 String code = "dumpSize('" + id + "')"; | 9941 String code = "dumpSize('" + id + "')"; |
| 9940 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 9942 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 9941 ScriptExecutionCallbackHelper callback_helper( | 9943 ScriptExecutionCallbackHelper callback_helper( |
| 9942 web_view_helper_.WebView()->MainFrame()->MainWorldScriptContext()); | 9944 web_view_helper_.WebView()->MainFrameImpl()->MainWorldScriptContext()); |
| 9943 web_view_helper_.WebView() | 9945 web_view_helper_.WebView() |
| 9944 ->MainFrameImpl() | 9946 ->MainFrameImpl() |
| 9945 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)), | 9947 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)), |
| 9946 false, &callback_helper); | 9948 false, &callback_helper); |
| 9947 RunPendingTasks(); | 9949 RunPendingTasks(); |
| 9948 EXPECT_TRUE(callback_helper.DidComplete()); | 9950 EXPECT_TRUE(callback_helper.DidComplete()); |
| 9949 return callback_helper.StringValue(); | 9951 return callback_helper.StringValue(); |
| 9950 } | 9952 } |
| 9951 | 9953 |
| 9952 FixedLayoutTestWebViewClient client_; | 9954 FixedLayoutTestWebViewClient client_; |
| (...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12181 if (obj->IsText()) { | 12183 if (obj->IsText()) { |
| 12182 LayoutText* layout_text = ToLayoutText(obj); | 12184 LayoutText* layout_text = ToLayoutText(obj); |
| 12183 text = layout_text->GetText(); | 12185 text = layout_text->GetText(); |
| 12184 break; | 12186 break; |
| 12185 } | 12187 } |
| 12186 } | 12188 } |
| 12187 EXPECT_EQ("foo alt", text.Utf8()); | 12189 EXPECT_EQ("foo alt", text.Utf8()); |
| 12188 } | 12190 } |
| 12189 | 12191 |
| 12190 } // namespace blink | 12192 } // namespace blink |
| OLD | NEW |