From 5d9a5a8c009a722f06051940345dc849612195bc Mon Sep 17 00:00:00 2001 From: tasak Date: Mon, 26 Oct 2015 20:29:45 -0700 Subject: Should not finish tests while printing. Reported by cluster-fuzz: https://cluster-fuzz.appspot.com/testcase?key=6475256993153024 While blink::LocalDOMWindow::print, content_shell might finish loading some resource (mainly ImageResource). In this case, - test_runner::WebTestProxyBase::DidFinishResourceLoad will be invoked. - test_runner::WebTestProxyBase::CheckOne will be invoked. - Since all pending resources were loaded, will start CaptureDump. - blink::LocalFrame::setPrinting will be invoked. So we should not do CaptureDump while printing. BUG=539689 TEST=third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash.html Review URL: https://codereview.chromium.org/1411243006 Cr-Commit-Position: refs/heads/master@{#356233} --- components/test_runner/web_test_proxy.cc | 3 ++- .../finish-loading-while-printing-crash-expected.html | 5 +++++ .../printing/finish-loading-while-printing-crash.html | 19 +++++++++++++++++++ third_party/WebKit/Source/web/WebLocalFrameImpl.h | 1 + third_party/WebKit/public/web/WebLocalFrame.h | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash-expected.html create mode 100644 third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash.html diff --git a/components/test_runner/web_test_proxy.cc b/components/test_runner/web_test_proxy.cc index be90a68..227f6ef 100644 --- a/components/test_runner/web_test_proxy.cc +++ b/components/test_runner/web_test_proxy.cc @@ -1351,7 +1351,8 @@ void WebTestProxyBase::CheckDone(blink::WebLocalFrame* frame, if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) return; if (reason != MainResourceLoadFailed && - (frame->isResourceLoadInProgress() || frame->isLoading())) + (frame->isResourceLoadInProgress() || frame->isLoading() || + frame->isPrinting())) return; test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); } diff --git a/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash-expected.html b/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash-expected.html new file mode 100644 index 0000000..0e3344e --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash-expected.html @@ -0,0 +1,5 @@ + + + + diff --git a/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash.html b/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash.html new file mode 100644 index 0000000..b65a8d8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/printing/finish-loading-while-printing-crash.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.h b/third_party/WebKit/Source/web/WebLocalFrameImpl.h index afb6358..7d89f79 100644 --- a/third_party/WebKit/Source/web/WebLocalFrameImpl.h +++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.h @@ -186,6 +186,7 @@ public: void printEnd() override; bool isPrintScalingDisabledForPlugin(const WebNode&) override; bool getPrintPresetOptionsForPlugin(const WebNode&, WebPrintPresetOptions*) override; + bool isPrinting() const override { return !!m_printContext; } bool hasCustomPageSizeStyle(int pageIndex) override; bool isPageBoxVisible(int pageIndex) override; void pageSizeAndMarginsInPixels( diff --git a/third_party/WebKit/public/web/WebLocalFrame.h b/third_party/WebKit/public/web/WebLocalFrame.h index e2bfa20..4939c93 100644 --- a/third_party/WebKit/public/web/WebLocalFrame.h +++ b/third_party/WebKit/public/web/WebLocalFrame.h @@ -117,6 +117,8 @@ public: // Returns true on success and sets the out parameter to the print preset options for the document. virtual bool getPrintPresetOptionsForPlugin(const WebNode&, WebPrintPresetOptions*) = 0; + // Returns true if not printing this frame. + virtual bool isPrinting() const = 0; // Scripting -------------------------------------------------------------- -- cgit v1.1