| Index: components/test_runner/test_runner.cc
|
| diff --git a/components/test_runner/test_runner.cc b/components/test_runner/test_runner.cc
|
| index f97ed57d0d2e1aca28beb48b09d9b7ee7b35da8b..50fee91ba1ef1f843b882f2cd94ff8f74facf9f0 100644
|
| --- a/components/test_runner/test_runner.cc
|
| +++ b/components/test_runner/test_runner.cc
|
| @@ -101,12 +101,14 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
|
| public:
|
| static gin::WrapperInfo kWrapperInfo;
|
|
|
| - static void Install(base::WeakPtr<TestRunner> controller,
|
| - WebFrame* frame);
|
| + static void Install(base::WeakPtr<TestRunner> test_runner,
|
| + base::WeakPtr<TestRunnerForSpecificView> view_test_runner,
|
| + WebLocalFrame* frame);
|
|
|
| private:
|
| explicit TestRunnerBindings(
|
| - base::WeakPtr<TestRunner> controller);
|
| + base::WeakPtr<TestRunner> test_runner,
|
| + base::WeakPtr<TestRunnerForSpecificView> view_test_runner);
|
| ~TestRunnerBindings() override;
|
|
|
| // gin::Wrappable:
|
| @@ -292,6 +294,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
|
| int WindowCount();
|
|
|
| base::WeakPtr<TestRunner> runner_;
|
| + base::WeakPtr<TestRunnerForSpecificView> view_runner_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings);
|
| };
|
| @@ -300,8 +303,10 @@ gin::WrapperInfo TestRunnerBindings::kWrapperInfo = {
|
| gin::kEmbedderNativeGin};
|
|
|
| // static
|
| -void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner,
|
| - WebFrame* frame) {
|
| +void TestRunnerBindings::Install(
|
| + base::WeakPtr<TestRunner> test_runner,
|
| + base::WeakPtr<TestRunnerForSpecificView> view_test_runner,
|
| + WebLocalFrame* frame) {
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| v8::HandleScope handle_scope(isolate);
|
| v8::Local<v8::Context> context = frame->mainWorldScriptContext();
|
| @@ -310,7 +315,8 @@ void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner,
|
|
|
| v8::Context::Scope context_scope(context);
|
|
|
| - TestRunnerBindings* wrapped = new TestRunnerBindings(runner);
|
| + TestRunnerBindings* wrapped =
|
| + new TestRunnerBindings(test_runner, view_test_runner);
|
| gin::Handle<TestRunnerBindings> bindings =
|
| gin::CreateHandle(isolate, wrapped);
|
| if (bindings.IsEmpty())
|
| @@ -325,8 +331,10 @@ void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner,
|
| global->Set(gin::StringToV8(isolate, names[i].c_str()), v8_bindings);
|
| }
|
|
|
| -TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner)
|
| - : runner_(runner) {}
|
| +TestRunnerBindings::TestRunnerBindings(
|
| + base::WeakPtr<TestRunner> runner,
|
| + base::WeakPtr<TestRunnerForSpecificView> view_runner)
|
| + : runner_(runner), view_runner_(view_runner) {}
|
|
|
| TestRunnerBindings::~TestRunnerBindings() {}
|
|
|
| @@ -679,58 +687,59 @@ void TestRunnerBindings::ResetTestHelperControllers() {
|
|
|
| void TestRunnerBindings::SetTabKeyCyclesThroughElements(
|
| bool tab_key_cycles_through_elements) {
|
| - if (runner_)
|
| - runner_->SetTabKeyCyclesThroughElements(tab_key_cycles_through_elements);
|
| + if (view_runner_)
|
| + view_runner_->SetTabKeyCyclesThroughElements(
|
| + tab_key_cycles_through_elements);
|
| }
|
|
|
| void TestRunnerBindings::ExecCommand(gin::Arguments* args) {
|
| - if (runner_)
|
| - runner_->ExecCommand(args);
|
| + if (view_runner_)
|
| + view_runner_->ExecCommand(args);
|
| }
|
|
|
| bool TestRunnerBindings::IsCommandEnabled(const std::string& command) {
|
| - if (runner_)
|
| - return runner_->IsCommandEnabled(command);
|
| + if (view_runner_)
|
| + return view_runner_->IsCommandEnabled(command);
|
| return false;
|
| }
|
|
|
| bool TestRunnerBindings::CallShouldCloseOnWebView() {
|
| - if (runner_)
|
| - return runner_->CallShouldCloseOnWebView();
|
| + if (view_runner_)
|
| + return view_runner_->CallShouldCloseOnWebView();
|
| return false;
|
| }
|
|
|
| void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme(
|
| bool forbidden, const std::string& scheme) {
|
| - if (runner_)
|
| - runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
|
| + if (view_runner_)
|
| + view_runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
|
| }
|
|
|
| v8::Local<v8::Value>
|
| TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue(
|
| int world_id, const std::string& script) {
|
| - if (!runner_ || world_id <= 0 || world_id >= (1 << 29))
|
| + if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29))
|
| return v8::Local<v8::Value>();
|
| - return runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id,
|
| - script);
|
| + return view_runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id,
|
| + script);
|
| }
|
|
|
| void TestRunnerBindings::EvaluateScriptInIsolatedWorld(
|
| int world_id, const std::string& script) {
|
| - if (runner_ && world_id > 0 && world_id < (1 << 29))
|
| - runner_->EvaluateScriptInIsolatedWorld(world_id, script);
|
| + if (view_runner_ && world_id > 0 && world_id < (1 << 29))
|
| + view_runner_->EvaluateScriptInIsolatedWorld(world_id, script);
|
| }
|
|
|
| void TestRunnerBindings::SetIsolatedWorldSecurityOrigin(
|
| int world_id, v8::Local<v8::Value> origin) {
|
| - if (runner_)
|
| - runner_->SetIsolatedWorldSecurityOrigin(world_id, origin);
|
| + if (view_runner_)
|
| + view_runner_->SetIsolatedWorldSecurityOrigin(world_id, origin);
|
| }
|
|
|
| void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy(
|
| int world_id, const std::string& policy) {
|
| - if (runner_)
|
| - runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy);
|
| + if (view_runner_)
|
| + view_runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy);
|
| }
|
|
|
| void TestRunnerBindings::AddOriginAccessWhitelistEntry(
|
| @@ -760,14 +769,14 @@ void TestRunnerBindings::RemoveOriginAccessWhitelistEntry(
|
| }
|
|
|
| bool TestRunnerBindings::HasCustomPageSizeStyle(int page_index) {
|
| - if (runner_)
|
| - return runner_->HasCustomPageSizeStyle(page_index);
|
| + if (view_runner_)
|
| + return view_runner_->HasCustomPageSizeStyle(page_index);
|
| return false;
|
| }
|
|
|
| void TestRunnerBindings::ForceRedSelectionColors() {
|
| - if (runner_)
|
| - runner_->ForceRedSelectionColors();
|
| + if (view_runner_)
|
| + view_runner_->ForceRedSelectionColors();
|
| }
|
|
|
| void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) {
|
| @@ -778,14 +787,14 @@ void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) {
|
| bool TestRunnerBindings::FindString(
|
| const std::string& search_text,
|
| const std::vector<std::string>& options_array) {
|
| - if (runner_)
|
| - return runner_->FindString(search_text, options_array);
|
| + if (view_runner_)
|
| + return view_runner_->FindString(search_text, options_array);
|
| return false;
|
| }
|
|
|
| std::string TestRunnerBindings::SelectionAsMarkup() {
|
| - if (runner_)
|
| - return runner_->SelectionAsMarkup();
|
| + if (view_runner_)
|
| + return view_runner_->SelectionAsMarkup();
|
| return std::string();
|
| }
|
|
|
| @@ -795,13 +804,13 @@ void TestRunnerBindings::SetTextSubpixelPositioning(bool value) {
|
| }
|
|
|
| void TestRunnerBindings::SetPageVisibility(const std::string& new_visibility) {
|
| - if (runner_)
|
| - runner_->SetPageVisibility(new_visibility);
|
| + if (view_runner_)
|
| + view_runner_->SetPageVisibility(new_visibility);
|
| }
|
|
|
| void TestRunnerBindings::SetTextDirection(const std::string& direction_name) {
|
| - if (runner_)
|
| - runner_->SetTextDirection(direction_name);
|
| + if (view_runner_)
|
| + view_runner_->SetTextDirection(direction_name);
|
| }
|
|
|
| void TestRunnerBindings::UseUnfortunateSynchronousResizeMode() {
|
| @@ -939,28 +948,28 @@ void TestRunnerBindings::DisableMockScreenOrientation() {
|
| }
|
|
|
| void TestRunnerBindings::DidAcquirePointerLock() {
|
| - if (runner_)
|
| - runner_->DidAcquirePointerLock();
|
| + if (view_runner_)
|
| + view_runner_->DidAcquirePointerLock();
|
| }
|
|
|
| void TestRunnerBindings::DidNotAcquirePointerLock() {
|
| - if (runner_)
|
| - runner_->DidNotAcquirePointerLock();
|
| + if (view_runner_)
|
| + view_runner_->DidNotAcquirePointerLock();
|
| }
|
|
|
| void TestRunnerBindings::DidLosePointerLock() {
|
| - if (runner_)
|
| - runner_->DidLosePointerLock();
|
| + if (view_runner_)
|
| + view_runner_->DidLosePointerLock();
|
| }
|
|
|
| void TestRunnerBindings::SetPointerLockWillFailSynchronously() {
|
| - if (runner_)
|
| - runner_->SetPointerLockWillFailSynchronously();
|
| + if (view_runner_)
|
| + view_runner_->SetPointerLockWillFailSynchronously();
|
| }
|
|
|
| void TestRunnerBindings::SetPointerLockWillRespondAsynchronously() {
|
| - if (runner_)
|
| - runner_->SetPointerLockWillRespondAsynchronously();
|
| + if (view_runner_)
|
| + view_runner_->SetPointerLockWillRespondAsynchronously();
|
| }
|
|
|
| void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) {
|
| @@ -1207,8 +1216,8 @@ void TestRunnerBindings::DumpNavigationPolicy() {
|
| }
|
|
|
| void TestRunnerBindings::DumpPageImportanceSignals() {
|
| - if (runner_)
|
| - runner_->DumpPageImportanceSignals();
|
| + if (view_runner_)
|
| + view_runner_->DumpPageImportanceSignals();
|
| }
|
|
|
| void TestRunnerBindings::ShowWebInspector(gin::Arguments* args) {
|
| @@ -1262,8 +1271,8 @@ void TestRunnerBindings::SetAlwaysAcceptCookies(bool accept) {
|
| }
|
|
|
| void TestRunnerBindings::SetWindowIsKey(bool value) {
|
| - if (runner_)
|
| - runner_->SetWindowIsKey(value);
|
| + if (view_runner_)
|
| + view_runner_->SetWindowIsKey(value);
|
| }
|
|
|
| std::string TestRunnerBindings::PathToLocalResource(const std::string& path) {
|
| @@ -1274,45 +1283,45 @@ std::string TestRunnerBindings::PathToLocalResource(const std::string& path) {
|
|
|
| void TestRunnerBindings::SetBackingScaleFactor(
|
| double value, v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->SetBackingScaleFactor(value, callback);
|
| + if (view_runner_)
|
| + view_runner_->SetBackingScaleFactor(value, callback);
|
| }
|
|
|
| void TestRunnerBindings::EnableUseZoomForDSF(
|
| v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->EnableUseZoomForDSF(callback);
|
| + if (view_runner_)
|
| + view_runner_->EnableUseZoomForDSF(callback);
|
| }
|
|
|
| void TestRunnerBindings::SetColorProfile(
|
| const std::string& name, v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->SetColorProfile(name, callback);
|
| + if (view_runner_)
|
| + view_runner_->SetColorProfile(name, callback);
|
| }
|
|
|
| void TestRunnerBindings::SetBluetoothFakeAdapter(
|
| const std::string& adapter_name,
|
| v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->SetBluetoothFakeAdapter(adapter_name, callback);
|
| + if (view_runner_)
|
| + view_runner_->SetBluetoothFakeAdapter(adapter_name, callback);
|
| }
|
|
|
| void TestRunnerBindings::SetBluetoothManualChooser(bool enable) {
|
| - if (runner_)
|
| - runner_->SetBluetoothManualChooser(enable);
|
| + if (view_runner_)
|
| + view_runner_->SetBluetoothManualChooser(enable);
|
| }
|
|
|
| void TestRunnerBindings::GetBluetoothManualChooserEvents(
|
| v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - return runner_->GetBluetoothManualChooserEvents(callback);
|
| + if (view_runner_)
|
| + return view_runner_->GetBluetoothManualChooserEvents(callback);
|
| }
|
|
|
| void TestRunnerBindings::SendBluetoothManualChooserEvent(
|
| const std::string& event,
|
| const std::string& argument) {
|
| - if (runner_)
|
| - runner_->SendBluetoothManualChooserEvent(event, argument);
|
| + if (view_runner_)
|
| + view_runner_->SendBluetoothManualChooserEvent(event, argument);
|
| }
|
|
|
| void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) {
|
| @@ -1367,41 +1376,41 @@ void TestRunnerBindings::AddMockCredentialManagerError(
|
| }
|
|
|
| void TestRunnerBindings::AddWebPageOverlay() {
|
| - if (runner_)
|
| - runner_->AddWebPageOverlay();
|
| + if (view_runner_)
|
| + view_runner_->AddWebPageOverlay();
|
| }
|
|
|
| void TestRunnerBindings::RemoveWebPageOverlay() {
|
| - if (runner_)
|
| - runner_->RemoveWebPageOverlay();
|
| + if (view_runner_)
|
| + view_runner_->RemoveWebPageOverlay();
|
| }
|
|
|
| void TestRunnerBindings::LayoutAndPaintAsync() {
|
| - if (runner_)
|
| - runner_->LayoutAndPaintAsync();
|
| + if (view_runner_)
|
| + view_runner_->LayoutAndPaintAsync();
|
| }
|
|
|
| void TestRunnerBindings::LayoutAndPaintAsyncThen(
|
| v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->LayoutAndPaintAsyncThen(callback);
|
| + if (view_runner_)
|
| + view_runner_->LayoutAndPaintAsyncThen(callback);
|
| }
|
|
|
| void TestRunnerBindings::GetManifestThen(v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->GetManifestThen(callback);
|
| + if (view_runner_)
|
| + view_runner_->GetManifestThen(callback);
|
| }
|
|
|
| void TestRunnerBindings::CapturePixelsAsyncThen(
|
| v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->CapturePixelsAsyncThen(callback);
|
| + if (view_runner_)
|
| + view_runner_->CapturePixelsAsyncThen(callback);
|
| }
|
|
|
| void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen(
|
| int x, int y, v8::Local<v8::Function> callback) {
|
| - if (runner_)
|
| - runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
|
| + if (view_runner_)
|
| + view_runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
|
| }
|
|
|
| void TestRunnerBindings::SetCustomTextOutput(const std::string& output) {
|
| @@ -1411,12 +1420,8 @@ void TestRunnerBindings::SetCustomTextOutput(const std::string& output) {
|
|
|
| void TestRunnerBindings::SetViewSourceForFrame(const std::string& name,
|
| bool enabled) {
|
| - if (runner_ && runner_->web_view_) {
|
| - WebFrame* target_frame =
|
| - runner_->web_view_->findFrameByName(WebString::fromUTF8(name));
|
| - if (target_frame)
|
| - target_frame->enableViewSourceMode(enabled);
|
| - }
|
| + if (view_runner_)
|
| + view_runner_->SetViewSourceForFrame(name, enabled);
|
| }
|
|
|
| void TestRunnerBindings::SetGeofencingMockProvider(bool service_available) {
|
| @@ -1450,11 +1455,11 @@ void TestRunnerBindings::DispatchBeforeInstallPromptEvent(
|
| int request_id,
|
| const std::vector<std::string>& event_platforms,
|
| v8::Local<v8::Function> callback) {
|
| - if (!runner_)
|
| + if (!view_runner_)
|
| return;
|
|
|
| - return runner_->DispatchBeforeInstallPromptEvent(request_id, event_platforms,
|
| - callback);
|
| + return view_runner_->DispatchBeforeInstallPromptEvent(
|
| + request_id, event_platforms, callback);
|
| }
|
|
|
| void TestRunnerBindings::ResolveBeforeInstallPromptPromise(
|
| @@ -1467,9 +1472,9 @@ void TestRunnerBindings::ResolveBeforeInstallPromptPromise(
|
| }
|
|
|
| void TestRunnerBindings::RunIdleTasks(v8::Local<v8::Function> callback) {
|
| - if (!runner_)
|
| + if (!view_runner_)
|
| return;
|
| - runner_->RunIdleTasks(callback);
|
| + view_runner_->RunIdleTasks(callback);
|
| }
|
|
|
| std::string TestRunnerBindings::PlatformName() {
|
| @@ -1504,13 +1509,13 @@ void TestRunnerBindings::SetInterceptPostMessage(bool value) {
|
| }
|
|
|
| void TestRunnerBindings::ForceNextWebGLContextCreationToFail() {
|
| - if (runner_)
|
| - runner_->ForceNextWebGLContextCreationToFail();
|
| + if (view_runner_)
|
| + view_runner_->ForceNextWebGLContextCreationToFail();
|
| }
|
|
|
| void TestRunnerBindings::ForceNextDrawingBufferCreationToFail() {
|
| - if (runner_)
|
| - runner_->ForceNextDrawingBufferCreationToFail();
|
| + if (view_runner_)
|
| + view_runner_->ForceNextDrawingBufferCreationToFail();
|
| }
|
|
|
| void TestRunnerBindings::NotImplemented(const gin::Arguments& args) {
|
| @@ -1529,8 +1534,8 @@ void TestRunner::WorkQueue::ProcessWorkSoon() {
|
|
|
| if (!queue_.empty()) {
|
| // We delay processing queued work to avoid recursion problems.
|
| - controller_->PostTask(base::Bind(&TestRunner::WorkQueue::ProcessWork,
|
| - weak_factory_.GetWeakPtr()));
|
| + controller_->delegate_->PostTask(new WebCallbackTask(base::Bind(
|
| + &TestRunner::WorkQueue::ProcessWork, weak_factory_.GetWeakPtr())));
|
| } else if (!controller_->layout_test_runtime_flags_.wait_until_done()) {
|
| controller_->delegate_->TestFinished();
|
| }
|
| @@ -1587,8 +1592,11 @@ TestRunner::TestRunner(TestInterfaces* interfaces)
|
|
|
| TestRunner::~TestRunner() {}
|
|
|
| -void TestRunner::Install(WebFrame* frame) {
|
| - TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame);
|
| +void TestRunner::Install(
|
| + WebLocalFrame* frame,
|
| + base::WeakPtr<TestRunnerForSpecificView> view_test_runner) {
|
| + TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner,
|
| + frame);
|
| }
|
|
|
| void TestRunner::SetDelegate(WebTestDelegate* delegate) {
|
| @@ -1604,22 +1612,6 @@ void TestRunner::SetWebView(WebView* webView) {
|
| }
|
|
|
| void TestRunner::Reset() {
|
| - if (web_view_) {
|
| - web_view_->setZoomLevel(0);
|
| - web_view_->setTextZoomFactor(1);
|
| - web_view_->setTabKeyCyclesThroughElements(true);
|
| -#if !defined(OS_MACOSX) && !defined(OS_WIN)
|
| - // (Constants copied because we can't depend on the header that defined
|
| - // them from this file.)
|
| - web_view_->setSelectionColors(
|
| - 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
|
| -#endif
|
| - web_view_->setVisibilityState(WebPageVisibilityStateVisible, true);
|
| - web_view_->mainFrame()->enableViewSourceMode(false);
|
| -
|
| - web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
|
| - }
|
| -
|
| top_loading_frame_ = nullptr;
|
| layout_test_runtime_flags_.Reset();
|
| mock_screen_orientation_client_->ResetData();
|
| @@ -1667,9 +1659,6 @@ void TestRunner::Reset() {
|
|
|
| SetUseMockTheme(true);
|
|
|
| - pointer_locked_ = false;
|
| - pointer_lock_planned_result_ = PointerLockWillSucceed;
|
| -
|
| weak_factory_.InvalidateWeakPtrs();
|
| work_queue_.Reset();
|
|
|
| @@ -1683,22 +1672,24 @@ void TestRunner::SetTestIsRunning(bool running) {
|
| test_is_running_ = running;
|
| }
|
|
|
| -void TestRunner::PostTask(const base::Closure& callback) {
|
| - delegate_->PostTask(new WebCallbackTask(callback));
|
| +void TestRunnerForSpecificView::PostTask(const base::Closure& callback) {
|
| + delegate()->PostTask(new WebCallbackTask(callback));
|
| }
|
|
|
| -void TestRunner::PostDelayedTask(long long delay,
|
| - const base::Closure& callback) {
|
| - delegate_->PostDelayedTask(new WebCallbackTask(callback), delay);
|
| +void TestRunnerForSpecificView::PostDelayedTask(long long delay,
|
| + const base::Closure& callback) {
|
| + delegate()->PostDelayedTask(new WebCallbackTask(callback), delay);
|
| }
|
|
|
| -void TestRunner::PostV8Callback(const v8::Local<v8::Function>& callback) {
|
| - PostTask(base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(),
|
| +void TestRunnerForSpecificView::PostV8Callback(
|
| + const v8::Local<v8::Function>& callback) {
|
| + PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
|
| + weak_factory_.GetWeakPtr(),
|
| v8::UniquePersistent<v8::Function>(
|
| blink::mainThreadIsolate(), callback)));
|
| }
|
|
|
| -void TestRunner::PostV8CallbackWithArgs(
|
| +void TestRunnerForSpecificView::PostV8CallbackWithArgs(
|
| v8::UniquePersistent<v8::Function> callback,
|
| int argc,
|
| v8::Local<v8::Value> argv[]) {
|
| @@ -1708,26 +1699,24 @@ void TestRunner::PostV8CallbackWithArgs(
|
| v8::UniquePersistent<v8::Value>(blink::mainThreadIsolate(), argv[i]));
|
| }
|
|
|
| - PostTask(base::Bind(&TestRunner::InvokeV8CallbackWithArgs,
|
| + PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8CallbackWithArgs,
|
| weak_factory_.GetWeakPtr(), std::move(callback),
|
| std::move(args)));
|
| }
|
|
|
| -void TestRunner::InvokeV8Callback(
|
| +void TestRunnerForSpecificView::InvokeV8Callback(
|
| const v8::UniquePersistent<v8::Function>& callback) {
|
| std::vector<v8::UniquePersistent<v8::Value>> empty_args;
|
| InvokeV8CallbackWithArgs(callback, std::move(empty_args));
|
| }
|
|
|
| -void TestRunner::InvokeV8CallbackWithArgs(
|
| +void TestRunnerForSpecificView::InvokeV8CallbackWithArgs(
|
| const v8::UniquePersistent<v8::Function>& callback,
|
| const std::vector<v8::UniquePersistent<v8::Value>>& args) {
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| v8::HandleScope handle_scope(isolate);
|
|
|
| - if (!web_view_)
|
| - return;
|
| - WebFrame* frame = web_view_->mainFrame();
|
| + WebFrame* frame = web_view()->mainFrame();
|
| v8::Local<v8::Context> context = frame->mainWorldScriptContext();
|
| if (context.IsEmpty())
|
| return;
|
| @@ -1743,13 +1732,14 @@ void TestRunner::InvokeV8CallbackWithArgs(
|
| local_args.size(), local_args.data());
|
| }
|
|
|
| -base::Closure TestRunner::CreateClosureThatPostsV8Callback(
|
| +base::Closure TestRunnerForSpecificView::CreateClosureThatPostsV8Callback(
|
| const v8::Local<v8::Function>& callback) {
|
| - return base::Bind(
|
| - &TestRunner::PostTask, weak_factory_.GetWeakPtr(),
|
| - base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(),
|
| - v8::UniquePersistent<v8::Function>(blink::mainThreadIsolate(),
|
| - callback)));
|
| + return base::Bind(&TestRunnerForSpecificView::PostTask,
|
| + weak_factory_.GetWeakPtr(),
|
| + base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
|
| + weak_factory_.GetWeakPtr(),
|
| + v8::UniquePersistent<v8::Function>(
|
| + blink::mainThreadIsolate(), callback)));
|
| }
|
|
|
| bool TestRunner::shouldDumpEditingCallbacks() const {
|
| @@ -1833,7 +1823,7 @@ void TestRunner::DumpPixelsAsync(
|
| return;
|
| }
|
|
|
| - test_runner::DumpPixelsAsync(web_view_, layout_test_runtime_flags_,
|
| + test_runner::DumpPixelsAsync(web_view, layout_test_runtime_flags_,
|
| delegate_->GetDeviceScaleFactorForTest(),
|
| callback);
|
| }
|
| @@ -1870,6 +1860,8 @@ bool TestRunner::shouldDumpPingLoaderCallbacks() const {
|
| }
|
|
|
| void TestRunner::setShouldEnableViewSource(bool value) {
|
| + // TODO(lukasza): This flag should be 1) replicated across OOPIFs and
|
| + // 2) applied to all views, not just the main window view.
|
| web_view_->mainFrame()->enableViewSourceMode(value);
|
| }
|
|
|
| @@ -1981,11 +1973,13 @@ bool TestRunner::shouldDumpResourcePriorities() const {
|
| return layout_test_runtime_flags_.dump_resource_priorities();
|
| }
|
|
|
| -bool TestRunner::RequestPointerLock() {
|
| +bool TestRunnerForSpecificView::RequestPointerLock() {
|
| switch (pointer_lock_planned_result_) {
|
| case PointerLockWillSucceed:
|
| - PostDelayedTask(0, base::Bind(&TestRunner::DidAcquirePointerLockInternal,
|
| - weak_factory_.GetWeakPtr()));
|
| + PostDelayedTask(
|
| + 0,
|
| + base::Bind(&TestRunnerForSpecificView::DidAcquirePointerLockInternal,
|
| + weak_factory_.GetWeakPtr()));
|
| return true;
|
| case PointerLockWillRespondAsync:
|
| DCHECK(!pointer_locked_);
|
| @@ -1999,12 +1993,13 @@ bool TestRunner::RequestPointerLock() {
|
| }
|
| }
|
|
|
| -void TestRunner::RequestPointerUnlock() {
|
| - PostDelayedTask(0, base::Bind(&TestRunner::DidLosePointerLockInternal,
|
| - weak_factory_.GetWeakPtr()));
|
| +void TestRunnerForSpecificView::RequestPointerUnlock() {
|
| + PostDelayedTask(
|
| + 0, base::Bind(&TestRunnerForSpecificView::DidLosePointerLockInternal,
|
| + weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| -bool TestRunner::isPointerLocked() {
|
| +bool TestRunnerForSpecificView::isPointerLocked() {
|
| return pointer_locked_;
|
| }
|
|
|
| @@ -2175,12 +2170,12 @@ void TestRunner::ResetTestHelperControllers() {
|
| test_interfaces_->ResetTestHelperControllers();
|
| }
|
|
|
| -void TestRunner::SetTabKeyCyclesThroughElements(
|
| +void TestRunnerForSpecificView::SetTabKeyCyclesThroughElements(
|
| bool tab_key_cycles_through_elements) {
|
| - web_view_->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements);
|
| + web_view()->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements);
|
| }
|
|
|
| -void TestRunner::ExecCommand(gin::Arguments* args) {
|
| +void TestRunnerForSpecificView::ExecCommand(gin::Arguments* args) {
|
| std::string command;
|
| args->GetNext(&command);
|
|
|
| @@ -2193,49 +2188,53 @@ void TestRunner::ExecCommand(gin::Arguments* args) {
|
| }
|
|
|
| // Note: webkit's version does not return the boolean, so neither do we.
|
| - web_view_->focusedFrame()->executeCommand(WebString::fromUTF8(command),
|
| - WebString::fromUTF8(value));
|
| + web_view()->focusedFrame()->executeCommand(WebString::fromUTF8(command),
|
| + WebString::fromUTF8(value));
|
| }
|
|
|
| -bool TestRunner::IsCommandEnabled(const std::string& command) {
|
| - return web_view_->focusedFrame()->isCommandEnabled(
|
| +bool TestRunnerForSpecificView::IsCommandEnabled(const std::string& command) {
|
| + return web_view()->focusedFrame()->isCommandEnabled(
|
| WebString::fromUTF8(command));
|
| }
|
|
|
| -bool TestRunner::CallShouldCloseOnWebView() {
|
| - return web_view_->mainFrame()->dispatchBeforeUnloadEvent();
|
| +bool TestRunnerForSpecificView::CallShouldCloseOnWebView() {
|
| + return web_view()->mainFrame()->dispatchBeforeUnloadEvent();
|
| }
|
|
|
| -void TestRunner::SetDomainRelaxationForbiddenForURLScheme(
|
| - bool forbidden, const std::string& scheme) {
|
| - web_view_->setDomainRelaxationForbidden(forbidden,
|
| - WebString::fromUTF8(scheme));
|
| +void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme(
|
| + bool forbidden,
|
| + const std::string& scheme) {
|
| + web_view()->setDomainRelaxationForbidden(forbidden,
|
| + WebString::fromUTF8(scheme));
|
| }
|
|
|
| -v8::Local<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue(
|
| +v8::Local<v8::Value>
|
| +TestRunnerForSpecificView::EvaluateScriptInIsolatedWorldAndReturnValue(
|
| int world_id,
|
| const std::string& script) {
|
| WebVector<v8::Local<v8::Value>> values;
|
| WebScriptSource source(WebString::fromUTF8(script));
|
| // This relies on the iframe focusing itself when it loads. This is a bit
|
| // sketchy, but it seems to be what other tests do.
|
| - web_view_->focusedFrame()->executeScriptInIsolatedWorld(
|
| - world_id, &source, 1, 1, &values);
|
| + web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
|
| + 1, &values);
|
| // Since only one script was added, only one result is expected
|
| if (values.size() == 1 && !values[0].IsEmpty())
|
| return values[0];
|
| return v8::Local<v8::Value>();
|
| }
|
|
|
| -void TestRunner::EvaluateScriptInIsolatedWorld(int world_id,
|
| - const std::string& script) {
|
| +void TestRunnerForSpecificView::EvaluateScriptInIsolatedWorld(
|
| + int world_id,
|
| + const std::string& script) {
|
| WebScriptSource source(WebString::fromUTF8(script));
|
| - web_view_->focusedFrame()->executeScriptInIsolatedWorld(
|
| - world_id, &source, 1, 1);
|
| + web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
|
| + 1);
|
| }
|
|
|
| -void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id,
|
| - v8::Local<v8::Value> origin) {
|
| +void TestRunnerForSpecificView::SetIsolatedWorldSecurityOrigin(
|
| + int world_id,
|
| + v8::Local<v8::Value> origin) {
|
| if (!(origin->IsString() || !origin->IsNull()))
|
| return;
|
|
|
| @@ -2244,14 +2243,14 @@ void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id,
|
| web_origin = WebSecurityOrigin::createFromString(
|
| V8StringToWebString(origin.As<v8::String>()));
|
| }
|
| - web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id,
|
| - web_origin);
|
| + web_view()->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id,
|
| + web_origin);
|
| }
|
|
|
| -void TestRunner::SetIsolatedWorldContentSecurityPolicy(
|
| +void TestRunnerForSpecificView::SetIsolatedWorldContentSecurityPolicy(
|
| int world_id,
|
| const std::string& policy) {
|
| - web_view_->focusedFrame()->setIsolatedWorldContentSecurityPolicy(
|
| + web_view()->focusedFrame()->setIsolatedWorldContentSecurityPolicy(
|
| world_id, WebString::fromUTF8(policy));
|
| }
|
|
|
| @@ -2287,15 +2286,16 @@ void TestRunner::RemoveOriginAccessWhitelistEntry(
|
| allow_destination_subdomains);
|
| }
|
|
|
| -bool TestRunner::HasCustomPageSizeStyle(int page_index) {
|
| - WebFrame* frame = web_view_->mainFrame();
|
| +bool TestRunnerForSpecificView::HasCustomPageSizeStyle(int page_index) {
|
| + WebFrame* frame = web_view()->mainFrame();
|
| if (!frame)
|
| return false;
|
| return frame->hasCustomPageSizeStyle(page_index);
|
| }
|
|
|
| -void TestRunner::ForceRedSelectionColors() {
|
| - web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0);
|
| +void TestRunnerForSpecificView::ForceRedSelectionColors() {
|
| + web_view()->setSelectionColors(
|
| + 0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0);
|
| }
|
|
|
| void TestRunner::InsertStyleSheet(const std::string& source_code) {
|
| @@ -2303,8 +2303,9 @@ void TestRunner::InsertStyleSheet(const std::string& source_code) {
|
| WebString::fromUTF8(source_code));
|
| }
|
|
|
| -bool TestRunner::FindString(const std::string& search_text,
|
| - const std::vector<std::string>& options_array) {
|
| +bool TestRunnerForSpecificView::FindString(
|
| + const std::string& search_text,
|
| + const std::vector<std::string>& options_array) {
|
| WebFindOptions find_options;
|
| bool wrap_around = false;
|
| find_options.matchCase = true;
|
| @@ -2325,15 +2326,15 @@ bool TestRunner::FindString(const std::string& search_text,
|
| wrap_around = true;
|
| }
|
|
|
| - WebLocalFrame* frame = web_view_->mainFrame()->toWebLocalFrame();
|
| + WebLocalFrame* frame = web_view()->mainFrame()->toWebLocalFrame();
|
| const bool find_result = frame->find(0, WebString::fromUTF8(search_text),
|
| find_options, wrap_around, 0);
|
| frame->stopFinding(false);
|
| return find_result;
|
| }
|
|
|
| -std::string TestRunner::SelectionAsMarkup() {
|
| - return web_view_->mainFrame()->selectionAsMarkup().utf8();
|
| +std::string TestRunnerForSpecificView::SelectionAsMarkup() {
|
| + return web_view()->mainFrame()->selectionAsMarkup().utf8();
|
| }
|
|
|
| void TestRunner::SetTextSubpixelPositioning(bool value) {
|
| @@ -2344,16 +2345,18 @@ void TestRunner::SetTextSubpixelPositioning(bool value) {
|
| #endif
|
| }
|
|
|
| -void TestRunner::SetPageVisibility(const std::string& new_visibility) {
|
| +void TestRunnerForSpecificView::SetPageVisibility(
|
| + const std::string& new_visibility) {
|
| if (new_visibility == "visible")
|
| - web_view_->setVisibilityState(WebPageVisibilityStateVisible, false);
|
| + web_view()->setVisibilityState(WebPageVisibilityStateVisible, false);
|
| else if (new_visibility == "hidden")
|
| - web_view_->setVisibilityState(WebPageVisibilityStateHidden, false);
|
| + web_view()->setVisibilityState(WebPageVisibilityStateHidden, false);
|
| else if (new_visibility == "prerender")
|
| - web_view_->setVisibilityState(WebPageVisibilityStatePrerender, false);
|
| + web_view()->setVisibilityState(WebPageVisibilityStatePrerender, false);
|
| }
|
|
|
| -void TestRunner::SetTextDirection(const std::string& direction_name) {
|
| +void TestRunnerForSpecificView::SetTextDirection(
|
| + const std::string& direction_name) {
|
| // Map a direction name to a WebTextDirection value.
|
| WebTextDirection direction;
|
| if (direction_name == "auto")
|
| @@ -2365,7 +2368,7 @@ void TestRunner::SetTextDirection(const std::string& direction_name) {
|
| else
|
| return;
|
|
|
| - web_view_->setTextDirection(direction);
|
| + web_view()->setTextDirection(direction);
|
| }
|
|
|
| void TestRunner::UseUnfortunateSynchronousResizeMode() {
|
| @@ -2501,10 +2504,14 @@ void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) {
|
| orientation = WebScreenOrientationLandscapeSecondary;
|
| }
|
|
|
| - // TODO(lukasza): This is broken for OOPIFs.
|
| - WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame();
|
| - mock_screen_orientation_client_->UpdateDeviceOrientation(
|
| - main_frame, orientation);
|
| + for (WebTestProxyBase* window : test_interfaces_->GetWindowList()) {
|
| + WebFrame* main_frame = window->web_view()->mainFrame();
|
| + // TODO(lukasza): Need to make this work for remote frames.
|
| + if (main_frame->isWebLocalFrame()) {
|
| + mock_screen_orientation_client_->UpdateDeviceOrientation(
|
| + main_frame->toWebLocalFrame(), orientation);
|
| + }
|
| + }
|
| }
|
|
|
| void TestRunner::DisableMockScreenOrientation() {
|
| @@ -2520,23 +2527,23 @@ void TestRunner::DidCloseChooser() {
|
| DCHECK_LE(0, chooser_count_);
|
| }
|
|
|
| -void TestRunner::DidAcquirePointerLock() {
|
| +void TestRunnerForSpecificView::DidAcquirePointerLock() {
|
| DidAcquirePointerLockInternal();
|
| }
|
|
|
| -void TestRunner::DidNotAcquirePointerLock() {
|
| +void TestRunnerForSpecificView::DidNotAcquirePointerLock() {
|
| DidNotAcquirePointerLockInternal();
|
| }
|
|
|
| -void TestRunner::DidLosePointerLock() {
|
| +void TestRunnerForSpecificView::DidLosePointerLock() {
|
| DidLosePointerLockInternal();
|
| }
|
|
|
| -void TestRunner::SetPointerLockWillFailSynchronously() {
|
| +void TestRunnerForSpecificView::SetPointerLockWillFailSynchronously() {
|
| pointer_lock_planned_result_ = PointerLockWillFailSync;
|
| }
|
|
|
| -void TestRunner::SetPointerLockWillRespondAsynchronously() {
|
| +void TestRunnerForSpecificView::SetPointerLockWillRespondAsynchronously() {
|
| pointer_lock_planned_result_ = PointerLockWillRespondAsync;
|
| }
|
|
|
| @@ -2627,7 +2634,9 @@ void TestRunner::SetAcceptLanguages(const std::string& accept_languages) {
|
|
|
| layout_test_runtime_flags_.set_accept_languages(accept_languages);
|
| OnLayoutTestRuntimeFlagsChanged();
|
| - web_view_->acceptLanguagesChanged();
|
| +
|
| + for (WebTestProxyBase* window : test_interfaces_->GetWindowList())
|
| + window->web_view()->acceptLanguagesChanged();
|
| }
|
|
|
| void TestRunner::SetPluginsEnabled(bool enabled) {
|
| @@ -2847,9 +2856,9 @@ void TestRunner::DumpNavigationPolicy() {
|
| OnLayoutTestRuntimeFlagsChanged();
|
| }
|
|
|
| -void TestRunner::DumpPageImportanceSignals() {
|
| +void TestRunnerForSpecificView::DumpPageImportanceSignals() {
|
| blink::WebPageImportanceSignals* signals =
|
| - web_view_->pageImportanceSignals();
|
| + web_view()->pageImportanceSignals();
|
| if (!signals)
|
| return;
|
|
|
| @@ -2859,8 +2868,8 @@ void TestRunner::DumpPageImportanceSignals() {
|
| " issuedNonGetFetchFromScript: %s\n",
|
| signals->hadFormInteraction() ? "true" : "false",
|
| signals->issuedNonGetFetchFromScript() ? "true" : "false");
|
| - if (delegate_)
|
| - delegate_->PrintMessage(message);
|
| + if (delegate())
|
| + delegate()->PrintMessage(message);
|
| }
|
|
|
| void TestRunner::CloseWebInspector() {
|
| @@ -2893,8 +2902,9 @@ void TestRunner::SetAlwaysAcceptCookies(bool accept) {
|
| delegate_->SetAcceptAllCookies(accept);
|
| }
|
|
|
| -void TestRunner::SetWindowIsKey(bool value) {
|
| - SetFocus(web_view_, value);
|
| +void TestRunnerForSpecificView::SetWindowIsKey(bool value) {
|
| + web_test_proxy_base_->test_interfaces()->GetTestRunner()->SetFocus(web_view(),
|
| + value);
|
| }
|
|
|
| void TestRunner::SetFocus(blink::WebView* web_view, bool focus) {
|
| @@ -2916,45 +2926,50 @@ std::string TestRunner::PathToLocalResource(const std::string& path) {
|
| return delegate_->PathToLocalResource(path);
|
| }
|
|
|
| -void TestRunner::SetBackingScaleFactor(double value,
|
| - v8::Local<v8::Function> callback) {
|
| - delegate_->SetDeviceScaleFactor(value);
|
| +void TestRunnerForSpecificView::SetBackingScaleFactor(
|
| + double value,
|
| + v8::Local<v8::Function> callback) {
|
| + delegate()->SetDeviceScaleFactor(value);
|
| PostV8Callback(callback);
|
| }
|
|
|
| -void TestRunner::EnableUseZoomForDSF(v8::Local<v8::Function> callback) {
|
| - delegate_->EnableUseZoomForDSF();
|
| +void TestRunnerForSpecificView::EnableUseZoomForDSF(
|
| + v8::Local<v8::Function> callback) {
|
| + delegate()->EnableUseZoomForDSF();
|
| PostV8Callback(callback);
|
| }
|
|
|
| -void TestRunner::SetColorProfile(const std::string& name,
|
| - v8::Local<v8::Function> callback) {
|
| - delegate_->SetDeviceColorProfile(name);
|
| +void TestRunnerForSpecificView::SetColorProfile(
|
| + const std::string& name,
|
| + v8::Local<v8::Function> callback) {
|
| + delegate()->SetDeviceColorProfile(name);
|
| PostV8Callback(callback);
|
| }
|
|
|
| -void TestRunner::SetBluetoothFakeAdapter(const std::string& adapter_name,
|
| - v8::Local<v8::Function> callback) {
|
| - delegate_->SetBluetoothFakeAdapter(
|
| +void TestRunnerForSpecificView::SetBluetoothFakeAdapter(
|
| + const std::string& adapter_name,
|
| + v8::Local<v8::Function> callback) {
|
| + delegate()->SetBluetoothFakeAdapter(
|
| adapter_name, CreateClosureThatPostsV8Callback(callback));
|
| }
|
|
|
| -void TestRunner::SetBluetoothManualChooser(bool enable) {
|
| - delegate_->SetBluetoothManualChooser(enable);
|
| +void TestRunnerForSpecificView::SetBluetoothManualChooser(bool enable) {
|
| + delegate()->SetBluetoothManualChooser(enable);
|
| }
|
|
|
| -void TestRunner::GetBluetoothManualChooserEvents(
|
| +void TestRunnerForSpecificView::GetBluetoothManualChooserEvents(
|
| v8::Local<v8::Function> callback) {
|
| - return delegate_->GetBluetoothManualChooserEvents(
|
| - base::Bind(&TestRunner::GetBluetoothManualChooserEventsCallback,
|
| - weak_factory_.GetWeakPtr(),
|
| - base::Passed(v8::UniquePersistent<v8::Function>(
|
| - blink::mainThreadIsolate(), callback))));
|
| + return delegate()->GetBluetoothManualChooserEvents(base::Bind(
|
| + &TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback,
|
| + weak_factory_.GetWeakPtr(),
|
| + base::Passed(v8::UniquePersistent<v8::Function>(
|
| + blink::mainThreadIsolate(), callback))));
|
| }
|
|
|
| -void TestRunner::SendBluetoothManualChooserEvent(const std::string& event,
|
| - const std::string& argument) {
|
| - delegate_->SendBluetoothManualChooserEvent(event, argument);
|
| +void TestRunnerForSpecificView::SendBluetoothManualChooserEvent(
|
| + const std::string& event,
|
| + const std::string& argument) {
|
| + delegate()->SendBluetoothManualChooserEvent(event, argument);
|
| }
|
|
|
| void TestRunner::SetGeofencingMockProvider(bool service_available) {
|
| @@ -2976,16 +2991,17 @@ void TestRunner::SetPermission(const std::string& name,
|
| delegate_->SetPermission(name, value, origin, embedding_origin);
|
| }
|
|
|
| -void TestRunner::DispatchBeforeInstallPromptEvent(
|
| +void TestRunnerForSpecificView::DispatchBeforeInstallPromptEvent(
|
| int request_id,
|
| const std::vector<std::string>& event_platforms,
|
| v8::Local<v8::Function> callback) {
|
| - delegate_->DispatchBeforeInstallPromptEvent(
|
| + delegate()->DispatchBeforeInstallPromptEvent(
|
| request_id, event_platforms,
|
| - base::Bind(&TestRunner::DispatchBeforeInstallPromptCallback,
|
| - weak_factory_.GetWeakPtr(),
|
| - base::Passed(v8::UniquePersistent<v8::Function>(
|
| - blink::mainThreadIsolate(), callback))));
|
| + base::Bind(
|
| + &TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback,
|
| + weak_factory_.GetWeakPtr(),
|
| + base::Passed(v8::UniquePersistent<v8::Function>(
|
| + blink::mainThreadIsolate(), callback))));
|
| }
|
|
|
| void TestRunner::ResolveBeforeInstallPromptPromise(
|
| @@ -2996,9 +3012,8 @@ void TestRunner::ResolveBeforeInstallPromptPromise(
|
| test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform);
|
| }
|
|
|
| -void TestRunner::RunIdleTasks(v8::Local<v8::Function> callback) {
|
| - delegate_->RunIdleTasks(
|
| - CreateClosureThatPostsV8Callback(callback));
|
| +void TestRunnerForSpecificView::RunIdleTasks(v8::Local<v8::Function> callback) {
|
| + delegate()->RunIdleTasks(CreateClosureThatPostsV8Callback(callback));
|
| }
|
|
|
| void TestRunner::SetPOSIXLocale(const std::string& locale) {
|
| @@ -3044,55 +3059,45 @@ void TestRunner::AddMockCredentialManagerError(const std::string& error) {
|
| credential_manager_client_->SetError(error);
|
| }
|
|
|
| -void TestRunner::AddWebPageOverlay() {
|
| - if (web_view_)
|
| - web_view_->setPageOverlayColor(SK_ColorCYAN);
|
| +void TestRunnerForSpecificView::AddWebPageOverlay() {
|
| + web_view()->setPageOverlayColor(SK_ColorCYAN);
|
| }
|
|
|
| -void TestRunner::RemoveWebPageOverlay() {
|
| - if (web_view_)
|
| - web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
|
| +void TestRunnerForSpecificView::RemoveWebPageOverlay() {
|
| + web_view()->setPageOverlayColor(SK_ColorTRANSPARENT);
|
| }
|
|
|
| -void TestRunner::LayoutAndPaintAsync() {
|
| - test_runner::LayoutAndPaintAsyncThen(web_view_, base::Closure());
|
| +void TestRunnerForSpecificView::LayoutAndPaintAsync() {
|
| + test_runner::LayoutAndPaintAsyncThen(web_view(), base::Closure());
|
| }
|
|
|
| -void TestRunner::LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback) {
|
| +void TestRunnerForSpecificView::LayoutAndPaintAsyncThen(
|
| + v8::Local<v8::Function> callback) {
|
| test_runner::LayoutAndPaintAsyncThen(
|
| - web_view_, CreateClosureThatPostsV8Callback(callback));
|
| + web_view(), CreateClosureThatPostsV8Callback(callback));
|
| }
|
|
|
| -void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) {
|
| +void TestRunnerForSpecificView::GetManifestThen(
|
| + v8::Local<v8::Function> callback) {
|
| v8::UniquePersistent<v8::Function> persistent_callback(
|
| blink::mainThreadIsolate(), callback);
|
|
|
| - if (!web_view_) {
|
| - WebURLResponse response;
|
| - response.setHTTPStatusCode(404);
|
| - GetManifestCallback(std::move(persistent_callback), response, "");
|
| - return;
|
| - }
|
| -
|
| - delegate_->FetchManifest(
|
| - web_view_, web_view_->mainFrame()->document().manifestURL(),
|
| - base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(),
|
| + delegate()->FetchManifest(
|
| + web_view(), web_view()->mainFrame()->document().manifestURL(),
|
| + base::Bind(&TestRunnerForSpecificView::GetManifestCallback,
|
| + weak_factory_.GetWeakPtr(),
|
| base::Passed(std::move(persistent_callback))));
|
| }
|
|
|
| -void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) {
|
| +void TestRunnerForSpecificView::CapturePixelsAsyncThen(
|
| + v8::Local<v8::Function> callback) {
|
| v8::UniquePersistent<v8::Function> persistent_callback(
|
| blink::mainThreadIsolate(), callback);
|
|
|
| - if (!web_view_) {
|
| - CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
|
| - return;
|
| - }
|
| -
|
| - DumpPixelsAsync(
|
| - web_view_,
|
| - base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(),
|
| - base::Passed(std::move(persistent_callback))));
|
| + web_test_proxy_base_->test_interfaces()->GetTestRunner()->DumpPixelsAsync(
|
| + web_view(), base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
|
| + weak_factory_.GetWeakPtr(),
|
| + base::Passed(std::move(persistent_callback))));
|
| }
|
|
|
| void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
|
| @@ -3104,50 +3109,43 @@ void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
|
| layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking();
|
| }
|
|
|
| -void TestRunner::ForceNextWebGLContextCreationToFail() {
|
| - if (web_view_)
|
| - web_view_->forceNextWebGLContextCreationToFail();
|
| +void TestRunnerForSpecificView::ForceNextWebGLContextCreationToFail() {
|
| + web_view()->forceNextWebGLContextCreationToFail();
|
| }
|
|
|
| -void TestRunner::ForceNextDrawingBufferCreationToFail() {
|
| - if (web_view_)
|
| - web_view_->forceNextDrawingBufferCreationToFail();
|
| +void TestRunnerForSpecificView::ForceNextDrawingBufferCreationToFail() {
|
| + web_view()->forceNextDrawingBufferCreationToFail();
|
| }
|
|
|
| -void TestRunner::CopyImageAtAndCapturePixelsAsyncThen(
|
| - int x, int y, v8::Local<v8::Function> callback) {
|
| +void TestRunnerForSpecificView::CopyImageAtAndCapturePixelsAsyncThen(
|
| + int x,
|
| + int y,
|
| + v8::Local<v8::Function> callback) {
|
| v8::UniquePersistent<v8::Function> persistent_callback(
|
| blink::mainThreadIsolate(), callback);
|
|
|
| - if (!web_view_) {
|
| - CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
|
| - return;
|
| - }
|
| -
|
| CopyImageAtAndCapturePixels(
|
| - web_view_, x, y,
|
| - base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(),
|
| + web_view(), x, y,
|
| + base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
|
| + weak_factory_.GetWeakPtr(),
|
| base::Passed(std::move(persistent_callback))));
|
| }
|
|
|
| -void TestRunner::GetManifestCallback(
|
| +void TestRunnerForSpecificView::GetManifestCallback(
|
| v8::UniquePersistent<v8::Function> callback,
|
| const blink::WebURLResponse& response,
|
| const std::string& data) {
|
| PostV8CallbackWithArgs(std::move(callback), 0, nullptr);
|
| }
|
|
|
| -void TestRunner::CapturePixelsCallback(
|
| +void TestRunnerForSpecificView::CapturePixelsCallback(
|
| v8::UniquePersistent<v8::Function> callback,
|
| const SkBitmap& snapshot) {
|
| - if (!web_view_)
|
| - return;
|
| -
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| v8::HandleScope handle_scope(isolate);
|
|
|
| v8::Local<v8::Context> context =
|
| - web_view_->mainFrame()->mainWorldScriptContext();
|
| + web_view()->mainFrame()->mainWorldScriptContext();
|
| if (context.IsEmpty())
|
| return;
|
|
|
| @@ -3184,17 +3182,14 @@ void TestRunner::CapturePixelsCallback(
|
| PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv);
|
| }
|
|
|
| -void TestRunner::DispatchBeforeInstallPromptCallback(
|
| +void TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback(
|
| v8::UniquePersistent<v8::Function> callback,
|
| bool canceled) {
|
| - if (!web_view_)
|
| - return;
|
| -
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| v8::HandleScope handle_scope(isolate);
|
|
|
| v8::Local<v8::Context> context =
|
| - web_view_->mainFrame()->mainWorldScriptContext();
|
| + web_view()->mainFrame()->mainWorldScriptContext();
|
| if (context.IsEmpty())
|
| return;
|
|
|
| @@ -3205,17 +3200,14 @@ void TestRunner::DispatchBeforeInstallPromptCallback(
|
| PostV8CallbackWithArgs(std::move(callback), 1, &arg);
|
| }
|
|
|
| -void TestRunner::GetBluetoothManualChooserEventsCallback(
|
| +void TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback(
|
| v8::UniquePersistent<v8::Function> callback,
|
| const std::vector<std::string>& events) {
|
| - if (!web_view_)
|
| - return;
|
| -
|
| // Build the V8 context.
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| v8::HandleScope handle_scope(isolate);
|
| v8::Local<v8::Context> context =
|
| - web_view_->mainFrame()->mainWorldScriptContext();
|
| + web_view()->mainFrame()->mainWorldScriptContext();
|
| if (context.IsEmpty())
|
| return;
|
| v8::Context::Scope context_scope(context);
|
| @@ -3267,28 +3259,80 @@ void TestRunner::CompleteNotifyDone() {
|
| OnLayoutTestRuntimeFlagsChanged();
|
| }
|
|
|
| -void TestRunner::DidAcquirePointerLockInternal() {
|
| +void TestRunnerForSpecificView::DidAcquirePointerLockInternal() {
|
| pointer_locked_ = true;
|
| - web_view_->didAcquirePointerLock();
|
| + web_view()->didAcquirePointerLock();
|
|
|
| // Reset planned result to default.
|
| pointer_lock_planned_result_ = PointerLockWillSucceed;
|
| }
|
|
|
| -void TestRunner::DidNotAcquirePointerLockInternal() {
|
| +void TestRunnerForSpecificView::DidNotAcquirePointerLockInternal() {
|
| DCHECK(!pointer_locked_);
|
| pointer_locked_ = false;
|
| - web_view_->didNotAcquirePointerLock();
|
| + web_view()->didNotAcquirePointerLock();
|
|
|
| // Reset planned result to default.
|
| pointer_lock_planned_result_ = PointerLockWillSucceed;
|
| }
|
|
|
| -void TestRunner::DidLosePointerLockInternal() {
|
| +void TestRunnerForSpecificView::DidLosePointerLockInternal() {
|
| bool was_locked = pointer_locked_;
|
| pointer_locked_ = false;
|
| if (was_locked)
|
| - web_view_->didLosePointerLock();
|
| + web_view()->didLosePointerLock();
|
| +}
|
| +
|
| +TestRunnerForSpecificView::TestRunnerForSpecificView(
|
| + WebTestProxyBase* web_test_proxy_base)
|
| + : web_test_proxy_base_(web_test_proxy_base), weak_factory_(this) {
|
| + Reset();
|
| +}
|
| +
|
| +TestRunnerForSpecificView::~TestRunnerForSpecificView() {}
|
| +
|
| +void TestRunnerForSpecificView::Install(blink::WebLocalFrame* frame) {
|
| + web_test_proxy_base_->test_interfaces()->GetTestRunner()->Install(
|
| + frame, weak_factory_.GetWeakPtr());
|
| +}
|
| +
|
| +void TestRunnerForSpecificView::Reset() {
|
| + pointer_locked_ = false;
|
| + pointer_lock_planned_result_ = PointerLockWillSucceed;
|
| +
|
| + if (web_view() && web_view()->mainFrame()) {
|
| + RemoveWebPageOverlay();
|
| + SetTabKeyCyclesThroughElements(true);
|
| +
|
| +#if !defined(OS_MACOSX) && !defined(OS_WIN)
|
| + // (Constants copied because we can't depend on the header that defined
|
| + // them from this file.)
|
| + web_view()->setSelectionColors(
|
| + 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
|
| +#endif
|
| + web_view()->setVisibilityState(WebPageVisibilityStateVisible, true);
|
| + if (web_view()->mainFrame()->isWebLocalFrame()) {
|
| + web_view()->mainFrame()->enableViewSourceMode(false);
|
| + web_view()->setTextZoomFactor(1);
|
| + web_view()->setZoomLevel(0);
|
| + }
|
| + }
|
| +}
|
| +
|
| +void TestRunnerForSpecificView::SetViewSourceForFrame(const std::string& name,
|
| + bool enabled) {
|
| + WebFrame* target_frame =
|
| + web_view()->findFrameByName(WebString::fromUTF8(name));
|
| + if (target_frame)
|
| + target_frame->enableViewSourceMode(enabled);
|
| +}
|
| +
|
| +blink::WebView* TestRunnerForSpecificView::web_view() {
|
| + return web_test_proxy_base_->web_view();
|
| +}
|
| +
|
| +WebTestDelegate* TestRunnerForSpecificView::delegate() {
|
| + return web_test_proxy_base_->delegate();
|
| }
|
|
|
| } // namespace test_runner
|
|
|