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