Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2923053002: Move MainWorldScriptContext accessor/method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Rebasing... Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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 3949 matching lines...) Expand 10 before | Expand all | Expand 10 after
4565 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> 4566 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>>
4566 create_notifications; 4567 create_notifications;
4567 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>> 4568 Vector<std::unique_ptr<ContextLifetimeTestWebFrameClient::Notification>>
4568 release_notifications; 4569 release_notifications;
4569 ContextLifetimeTestMainFrameClient web_frame_client(create_notifications, 4570 ContextLifetimeTestMainFrameClient web_frame_client(create_notifications,
4570 release_notifications); 4571 release_notifications);
4571 FrameTestHelpers::WebViewHelper web_view_helper; 4572 FrameTestHelpers::WebViewHelper web_view_helper;
4572 web_view_helper.InitializeAndLoad( 4573 web_view_helper.InitializeAndLoad(
4573 base_url_ + "context_notifications_test.html", true, &web_frame_client); 4574 base_url_ + "context_notifications_test.html", true, &web_frame_client);
4574 4575
4575 WebFrame* main_frame = web_view_helper.WebView()->MainFrame(); 4576 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl();
4576 WebFrame* child_frame = main_frame->FirstChild(); 4577 WebFrame* child_frame = main_frame->FirstChild();
4577 4578
4578 ASSERT_EQ(2u, create_notifications.size()); 4579 ASSERT_EQ(2u, create_notifications.size());
4579 EXPECT_EQ(0u, release_notifications.size()); 4580 EXPECT_EQ(0u, release_notifications.size());
4580 4581
4581 auto& first_create_notification = create_notifications[0]; 4582 auto& first_create_notification = create_notifications[0];
4582 auto& second_create_notification = create_notifications[1]; 4583 auto& second_create_notification = create_notifications[1];
4583 4584
4584 EXPECT_EQ(main_frame, first_create_notification->frame); 4585 EXPECT_EQ(main_frame, first_create_notification->frame);
4585 EXPECT_EQ(main_frame->MainWorldScriptContext(), 4586 EXPECT_EQ(main_frame->MainWorldScriptContext(),
4586 first_create_notification->context); 4587 first_create_notification->context);
4587 EXPECT_EQ(0, first_create_notification->world_id); 4588 EXPECT_EQ(0, first_create_notification->world_id);
4588 4589
4589 EXPECT_EQ(child_frame, second_create_notification->frame); 4590 EXPECT_EQ(child_frame, second_create_notification->frame);
4590 EXPECT_EQ(child_frame->MainWorldScriptContext(), 4591 EXPECT_EQ(child_frame->ToWebLocalFrame()->MainWorldScriptContext(),
4591 second_create_notification->context); 4592 second_create_notification->context);
4592 EXPECT_EQ(0, second_create_notification->world_id); 4593 EXPECT_EQ(0, second_create_notification->world_id);
4593 4594
4594 // Close the view. We should get two release notifications that are exactly 4595 // Close the view. We should get two release notifications that are exactly
4595 // the same as the create ones, in reverse order. 4596 // the same as the create ones, in reverse order.
4596 web_view_helper.Reset(); 4597 web_view_helper.Reset();
4597 4598
4598 ASSERT_EQ(2u, release_notifications.size()); 4599 ASSERT_EQ(2u, release_notifications.size());
4599 auto& first_release_notification = release_notifications[0]; 4600 auto& first_release_notification = release_notifications[0];
4600 auto& second_release_notification = release_notifications[1]; 4601 auto& second_release_notification = release_notifications[1];
(...skipping 28 matching lines...) Expand all
4629 4630
4630 // The two release notifications we got should be exactly the same as the 4631 // The two release notifications we got should be exactly the same as the
4631 // first two create notifications. 4632 // first two create notifications.
4632 for (size_t i = 0; i < release_notifications.size(); ++i) { 4633 for (size_t i = 0; i < release_notifications.size(); ++i) {
4633 EXPECT_TRUE(release_notifications[i]->Equals( 4634 EXPECT_TRUE(release_notifications[i]->Equals(
4634 create_notifications[create_notifications.size() - 3 - i].get())); 4635 create_notifications[create_notifications.size() - 3 - i].get()));
4635 } 4636 }
4636 4637
4637 // The last two create notifications should be for the current frames and 4638 // The last two create notifications should be for the current frames and
4638 // context. 4639 // context.
4639 WebFrame* main_frame = web_view_helper.WebView()->MainFrame(); 4640 WebLocalFrameBase* main_frame = web_view_helper.WebView()->MainFrameImpl();
4640 WebFrame* child_frame = main_frame->FirstChild(); 4641 WebFrame* child_frame = main_frame->FirstChild();
4641 auto& first_refresh_notification = create_notifications[2]; 4642 auto& first_refresh_notification = create_notifications[2];
4642 auto& second_refresh_notification = create_notifications[3]; 4643 auto& second_refresh_notification = create_notifications[3];
4643 4644
4644 EXPECT_EQ(main_frame, first_refresh_notification->frame); 4645 EXPECT_EQ(main_frame, first_refresh_notification->frame);
4645 EXPECT_EQ(main_frame->MainWorldScriptContext(), 4646 EXPECT_EQ(main_frame->MainWorldScriptContext(),
4646 first_refresh_notification->context); 4647 first_refresh_notification->context);
4647 EXPECT_EQ(0, first_refresh_notification->world_id); 4648 EXPECT_EQ(0, first_refresh_notification->world_id);
4648 4649
4649 EXPECT_EQ(child_frame, second_refresh_notification->frame); 4650 EXPECT_EQ(child_frame, second_refresh_notification->frame);
4650 EXPECT_EQ(child_frame->MainWorldScriptContext(), 4651 EXPECT_EQ(child_frame->ToWebLocalFrame()->MainWorldScriptContext(),
4651 second_refresh_notification->context); 4652 second_refresh_notification->context);
4652 EXPECT_EQ(0, second_refresh_notification->world_id); 4653 EXPECT_EQ(0, second_refresh_notification->world_id);
4653 } 4654 }
4654 4655
4655 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) { 4656 TEST_P(ParameterizedWebFrameTest, ContextNotificationsIsolatedWorlds) {
4656 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 4657 v8::Isolate* isolate = v8::Isolate::GetCurrent();
4657 v8::HandleScope handle_scope(isolate); 4658 v8::HandleScope handle_scope(isolate);
4658 4659
4659 RegisterMockedHttpURLLoad("context_notifications_test.html"); 4660 RegisterMockedHttpURLLoad("context_notifications_test.html");
4660 RegisterMockedHttpURLLoad("context_notifications_test_frame.html"); 4661 RegisterMockedHttpURLLoad("context_notifications_test_frame.html");
(...skipping 18 matching lines...) Expand all
4679 isolated_world_id, &script_source, num_sources); 4680 isolated_world_id, &script_source, num_sources);
4680 4681
4681 // We should now have a new create notification. 4682 // We should now have a new create notification.
4682 ASSERT_EQ(1u, create_notifications.size()); 4683 ASSERT_EQ(1u, create_notifications.size());
4683 auto& notification = create_notifications[0]; 4684 auto& notification = create_notifications[0];
4684 ASSERT_EQ(isolated_world_id, notification->world_id); 4685 ASSERT_EQ(isolated_world_id, notification->world_id);
4685 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame); 4686 ASSERT_EQ(web_view_helper.WebView()->MainFrame(), notification->frame);
4686 4687
4687 // We don't have an API to enumarate isolated worlds for a frame, but we can 4688 // We don't have an API to enumarate isolated worlds for a frame, but we can
4688 // at least assert that the context we got is *not* the main world's context. 4689 // at least assert that the context we got is *not* the main world's context.
4689 ASSERT_NE(web_view_helper.WebView()->MainFrame()->MainWorldScriptContext(), 4690 ASSERT_NE(
4690 v8::Local<v8::Context>::New(isolate, notification->context)); 4691 web_view_helper.WebView()->MainFrameImpl()->MainWorldScriptContext(),
4692 v8::Local<v8::Context>::New(isolate, notification->context));
4691 4693
4692 web_view_helper.Reset(); 4694 web_view_helper.Reset();
4693 4695
4694 // We should have gotten three release notifications (one for each of the 4696 // We should have gotten three release notifications (one for each of the
4695 // frames, plus one for the isolated context). 4697 // frames, plus one for the isolated context).
4696 ASSERT_EQ(3u, release_notifications.size()); 4698 ASSERT_EQ(3u, release_notifications.size());
4697 4699
4698 // And one of them should be exactly the same as the create notification for 4700 // And one of them should be exactly the same as the create notification for
4699 // the isolated context. 4701 // the isolated context.
4700 int match_count = 0; 4702 int match_count = 0;
(...skipping 5232 matching lines...) Expand 10 before | Expand all | Expand 10 after
9933 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height); 9935 client_.screen_info_.rect = WebRect(0, 0, size.width, size.height);
9934 client_.screen_info_.available_rect = client_.screen_info_.rect; 9936 client_.screen_info_.available_rect = client_.screen_info_.rect;
9935 web_view_helper_.Resize(size); 9937 web_view_helper_.Resize(size);
9936 EXPECT_EQ(expected_size, DumpSize("test")); 9938 EXPECT_EQ(expected_size, DumpSize("test"));
9937 } 9939 }
9938 9940
9939 String DumpSize(const String& id) { 9941 String DumpSize(const String& id) {
9940 String code = "dumpSize('" + id + "')"; 9942 String code = "dumpSize('" + id + "')";
9941 v8::HandleScope scope(v8::Isolate::GetCurrent()); 9943 v8::HandleScope scope(v8::Isolate::GetCurrent());
9942 ScriptExecutionCallbackHelper callback_helper( 9944 ScriptExecutionCallbackHelper callback_helper(
9943 web_view_helper_.WebView()->MainFrame()->MainWorldScriptContext()); 9945 web_view_helper_.WebView()->MainFrameImpl()->MainWorldScriptContext());
9944 web_view_helper_.WebView() 9946 web_view_helper_.WebView()
9945 ->MainFrameImpl() 9947 ->MainFrameImpl()
9946 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)), 9948 ->RequestExecuteScriptAndReturnValue(WebScriptSource(WebString(code)),
9947 false, &callback_helper); 9949 false, &callback_helper);
9948 RunPendingTasks(); 9950 RunPendingTasks();
9949 EXPECT_TRUE(callback_helper.DidComplete()); 9951 EXPECT_TRUE(callback_helper.DidComplete());
9950 return callback_helper.StringValue(); 9952 return callback_helper.StringValue();
9951 } 9953 }
9952 9954
9953 FixedLayoutTestWebViewClient client_; 9955 FixedLayoutTestWebViewClient client_;
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after
12217 if (obj->IsText()) { 12219 if (obj->IsText()) {
12218 LayoutText* layout_text = ToLayoutText(obj); 12220 LayoutText* layout_text = ToLayoutText(obj);
12219 text = layout_text->GetText(); 12221 text = layout_text->GetText();
12220 break; 12222 break;
12221 } 12223 }
12222 } 12224 }
12223 EXPECT_EQ("foo alt", text.Utf8()); 12225 EXPECT_EQ("foo alt", text.Utf8());
12224 } 12226 }
12225 12227
12226 } // namespace blink 12228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698