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> { ...@@ -292,7 +292,6 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void WaitForPolicyDelegate(); void WaitForPolicyDelegate();
void WaitUntilDone(); void WaitUntilDone();
void WaitUntilExternalURLLoad(); void WaitUntilExternalURLLoad();
bool CallShouldCloseOnWebView();
bool DisableAutoResizeMode(int new_width, int new_height); bool DisableAutoResizeMode(int new_width, int new_height);
bool EnableAutoResizeMode(int min_width, bool EnableAutoResizeMode(int min_width,
int min_height, int min_height,
...@@ -406,8 +405,6 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( ...@@ -406,8 +405,6 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("addOriginAccessAllowListEntry", .SetMethod("addOriginAccessAllowListEntry",
&TestRunnerBindings::AddOriginAccessAllowListEntry) &TestRunnerBindings::AddOriginAccessAllowListEntry)
.SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay)
.SetMethod("callShouldCloseOnWebView",
&TestRunnerBindings::CallShouldCloseOnWebView)
.SetMethod("capturePixelsAsyncThen", .SetMethod("capturePixelsAsyncThen",
&TestRunnerBindings::CapturePixelsAsyncThen) &TestRunnerBindings::CapturePixelsAsyncThen)
.SetMethod("clearAllDatabases", &TestRunnerBindings::ClearAllDatabases) .SetMethod("clearAllDatabases", &TestRunnerBindings::ClearAllDatabases)
...@@ -746,12 +743,6 @@ bool TestRunnerBindings::IsCommandEnabled(const std::string& command) { ...@@ -746,12 +743,6 @@ bool TestRunnerBindings::IsCommandEnabled(const std::string& command) {
return false; return false;
} }
bool TestRunnerBindings::CallShouldCloseOnWebView() {
if (view_runner_)
return view_runner_->CallShouldCloseOnWebView();
return false;
}
void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme( void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme(
bool forbidden, bool forbidden,
const std::string& scheme) { const std::string& scheme) {
......
...@@ -584,10 +584,6 @@ void TestRunnerForSpecificView::DidLosePointerLockInternal() { ...@@ -584,10 +584,6 @@ void TestRunnerForSpecificView::DidLosePointerLockInternal() {
web_view()->MainFrameWidget()->DidLosePointerLock(); web_view()->MainFrameWidget()->DidLosePointerLock();
} }
bool TestRunnerForSpecificView::CallShouldCloseOnWebView() {
return GetLocalMainFrame()->DispatchBeforeUnloadEvent(false);
}
void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme( void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme(
bool forbidden, bool forbidden,
const std::string& scheme) { const std::string& scheme) {
......
...@@ -203,7 +203,6 @@ class TestRunnerForSpecificView { ...@@ -203,7 +203,6 @@ class TestRunnerForSpecificView {
PointerLockWillFailSync, PointerLockWillFailSync,
} pointer_lock_planned_result_; } pointer_lock_planned_result_;
bool CallShouldCloseOnWebView();
void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
const std::string& scheme); const std::string& scheme);
v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
{ {
alert("beforeUnload"); alert("beforeUnload");
window.onbeforeunload = null; window.onbeforeunload = null;
testRunner.notifyDone();
return false;
} }
...@@ -22,9 +24,7 @@ ...@@ -22,9 +24,7 @@
{ {
if (window.testRunner) { if (window.testRunner) {
// Simulate an attempt to close the window // Simulate an attempt to close the window
if (!testRunner.callShouldCloseOnWebView()) location.href = "resources/notify-done.html";
alert("Should have run the beforeUnload handler.");
testRunner.notifyDone();
} }
} }
</script> </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