Commit 3445b6fa authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Do not expose DispatchBeforeUnload to layout tests

Instead of exposing internal methods to layout test through
TestRunner, we can just emulate user navigating away from the page.

Bug: 855189
Change-Id: I4cd08357e7929108ad7c9fe79f7f5eeec13e7888
Reviewed-on: https://chromium-review.googlesource.com/c/1334192Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608536}
parent fc230cd5
......@@ -292,7 +292,6 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void WaitForPolicyDelegate();
void WaitUntilDone();
void WaitUntilExternalURLLoad();
bool CallShouldCloseOnWebView();
bool DisableAutoResizeMode(int new_width, int new_height);
bool EnableAutoResizeMode(int min_width,
int min_height,
......@@ -406,8 +405,6 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("addOriginAccessAllowListEntry",
&TestRunnerBindings::AddOriginAccessAllowListEntry)
.SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay)
.SetMethod("callShouldCloseOnWebView",
&TestRunnerBindings::CallShouldCloseOnWebView)
.SetMethod("capturePixelsAsyncThen",
&TestRunnerBindings::CapturePixelsAsyncThen)
.SetMethod("clearAllDatabases", &TestRunnerBindings::ClearAllDatabases)
......@@ -746,12 +743,6 @@ bool TestRunnerBindings::IsCommandEnabled(const std::string& command) {
return false;
}
bool TestRunnerBindings::CallShouldCloseOnWebView() {
if (view_runner_)
return view_runner_->CallShouldCloseOnWebView();
return false;
}
void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme(
bool forbidden,
const std::string& scheme) {
......
......@@ -584,10 +584,6 @@ void TestRunnerForSpecificView::DidLosePointerLockInternal() {
web_view()->MainFrameWidget()->DidLosePointerLock();
}
bool TestRunnerForSpecificView::CallShouldCloseOnWebView() {
return GetLocalMainFrame()->DispatchBeforeUnloadEvent(false);
}
void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme(
bool forbidden,
const std::string& scheme) {
......
......@@ -203,7 +203,6 @@ class TestRunnerForSpecificView {
PointerLockWillFailSync,
} pointer_lock_planned_result_;
bool CallShouldCloseOnWebView();
void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
const std::string& scheme);
v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
......
......@@ -15,6 +15,8 @@
{
alert("beforeUnload");
window.onbeforeunload = null;
testRunner.notifyDone();
return false;
}
......@@ -22,9 +24,7 @@
{
if (window.testRunner) {
// Simulate an attempt to close the window
if (!testRunner.callShouldCloseOnWebView())
alert("Should have run the beforeUnload handler.");
testRunner.notifyDone();
location.href = "resources/notify-done.html";
}
}
</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment