summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2019-05-03 06:17:23 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2019-05-03 06:17:23 +0000
commitbb19758b5cc67d2450e9de696eb2562e73ea9599 (patch)
tree2437a7f0abf3a86cfa8289338b11b410c678229d
parentf7ae9e07c3c4e4fb9b799d039a3c785977a72000 (diff)
parent4181db05fc8f1c96d0bbf2e88a64e6d3bb11c6cf (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into refs/staging/5.13
-rw-r--r--dist/changes-5.12.379
-rw-r--r--examples/webenginewidgets/printme/data/data.qrc7
-rw-r--r--examples/webenginewidgets/printme/data/icon.svg24
-rw-r--r--examples/webenginewidgets/printme/data/index.html24
-rw-r--r--examples/webenginewidgets/printme/data/style.css72
-rw-r--r--examples/webenginewidgets/printme/doc/images/printme-example.pngbin0 -> 42074 bytes
-rw-r--r--examples/webenginewidgets/printme/doc/src/printme.qdoc98
-rw-r--r--examples/webenginewidgets/printme/main.cpp76
-rw-r--r--examples/webenginewidgets/printme/printhandler.cpp115
-rw-r--r--examples/webenginewidgets/printme/printhandler.h79
-rw-r--r--examples/webenginewidgets/printme/printme.pro9
-rw-r--r--examples/webenginewidgets/simplebrowser/browser.cpp13
-rw-r--r--examples/webenginewidgets/simplebrowser/browser.h2
-rw-r--r--examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc23
-rw-r--r--examples/webenginewidgets/webenginewidgets.pro7
-rw-r--r--mkspecs/features/configure.prf4
-rw-r--r--src/core/api/qwebengineurlscheme.cpp5
-rw-r--r--src/core/config/windows.pri2
-rw-r--r--src/core/printing/print_view_manager_qt.cpp28
-rw-r--r--src/core/profile_qt.cpp4
-rw-r--r--src/core/profile_qt.h2
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp7
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp2
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h1
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp49
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp6
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp46
27 files changed, 751 insertions, 33 deletions
diff --git a/dist/changes-5.12.3 b/dist/changes-5.12.3
new file mode 100644
index 000000000..344025378
--- /dev/null
+++ b/dist/changes-5.12.3
@@ -0,0 +1,79 @@
+Qt 5.12.3 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.12.0 through 5.12.2.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+https://doc.qt.io/qt-5/index.html
+
+The Qt version 5.12 series is binary compatible with the 5.11.x series.
+Applications compiled for 5.11 will continue to run with 5.12.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Qt 5.12.3 Changes *
+****************************************************************************
+
+Behavior Changes
+----------------
+
+ - [QTBUG-74490] Client side redirects are no longer reported as link clicked.
+
+Chromium
+--------
+
+ - Security fixes from Chromium up to version 73.0.3683.75, including:
+
+ * CVE-2019-5787
+ * CVE-2019-5789
+ * CVE-2019-5790
+ * CVE-2019-5791
+ * CVE-2019-5792
+ * CVE-2019-5793
+ * CVE-2019-5794
+ * CVE-2019-5795
+ * CVE-2019-5797
+ * CVE-2019-5802
+ * CVE-2019-5803
+ * Security issue 905509
+ * Security issue 906437
+ * Security issue 906652
+ * Security issue 906739
+ * Security issue 913212
+ * Security issue 914511
+ * Security issue 916874
+ * Security issue 917608
+ * Security issue 917707
+ * Security issue 919340
+ * Security issue 919572
+ * Security issue 924905
+ * Security issue 929088
+ * Security issue 931640
+ * Security issue 938251
+ * Security issue 933743
+
+
+General
+-------
+
+ - [QTBUG-73833] Fixed crash with dynamic_cast in event filter.
+ - [QTBUG-74021] Fixed crash on exit if the app leaked a page.
+ - [QTBUG-74116] Fixed crash on exit for rare QML setup.
+ - [QTBUG-74484] Fixed default style of media controls for audio playback.
+ - [QTBUG-74519] Fixed regression in setting background colors.
+ - [QTBUG-74659] Fixed quotes and other characters being escaped in tooltips.
+ - [QTBUG-74764] Fixed deduplication naming of 100+ downloads on Windows.
+
+
+Examples
+--------
+
+ - Quicknanobrowser status bubble hid correctly.
+ - Recipebrowser rendering and tabbing fixed.
diff --git a/examples/webenginewidgets/printme/data/data.qrc b/examples/webenginewidgets/printme/data/data.qrc
new file mode 100644
index 000000000..a9c76cc7e
--- /dev/null
+++ b/examples/webenginewidgets/printme/data/data.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>index.html</file>
+ <file>style.css</file>
+ <file>icon.svg</file>
+ </qresource>
+</RCC>
diff --git a/examples/webenginewidgets/printme/data/icon.svg b/examples/webenginewidgets/printme/data/icon.svg
new file mode 100644
index 000000000..b90ff26dd
--- /dev/null
+++ b/examples/webenginewidgets/printme/data/icon.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="94px" height="94px" viewBox="0 0 94 94" enable-background="new 0 0 94 94" xml:space="preserve">
+<g>
+ <circle fill="none" cx="47" cy="47" r="47"/>
+ <g>
+ <path fill="#46A2DA" d="M47,92.979c-11.779,0-23.559-4.484-32.526-13.451C-3.461,61.591-3.461,32.409,14.472,14.474
+ C32.41-3.463,61.592-3.461,79.526,14.473c17.935,17.936,17.935,47.119,0.002,65.054l-0.002,0.001
+ C70.559,88.495,58.779,92.979,47,92.979z"/>
+ </g>
+ <path fill="#80C342" d="M93,47C93,21.595,72.405,1,47,1C34.297,1,22.797,6.149,14.473,14.473l65.054,65.054
+ C87.851,71.203,93,59.703,93,47z"/>
+ <g>
+ <path fill="#46A2DA" d="M47,65c-4.808,0-9.328-1.873-12.728-5.272c-7.018-7.019-7.018-18.438,0-25.456
+ C37.672,30.873,42.192,29,47,29s9.328,1.873,12.728,5.272c7.018,7.019,7.018,18.438,0,25.456C56.328,63.127,51.808,65,47,65z"/>
+ <path fill="#FFFFFF" d="M62.248,59.919c6.671-7.858,6.312-19.644-1.105-27.061C57.237,28.953,52.118,27,47,27
+ c-5.118,0-10.237,1.953-14.142,5.858c-7.81,7.81-7.81,20.474,0,28.284C36.763,65.047,41.882,67,47,67
+ c4.379,0,8.752-1.441,12.372-4.3L77.88,81.209c0.989-0.895,1.935-1.837,2.843-2.814L62.248,59.919z M35.686,58.314
+ c-6.238-6.238-6.238-16.389,0-22.627C38.708,32.664,42.726,31,47,31c4.274,0,8.292,1.664,11.314,4.686
+ c6.238,6.238,6.238,16.389,0,22.627C55.292,61.336,51.274,63,47,63C42.726,63,38.708,61.336,35.686,58.314z"/>
+ </g>
+</g>
+</svg>
diff --git a/examples/webenginewidgets/printme/data/index.html b/examples/webenginewidgets/printme/data/index.html
new file mode 100644
index 000000000..cf286e85a
--- /dev/null
+++ b/examples/webenginewidgets/printme/data/index.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>PrintMe</title>
+ <link rel="stylesheet" type="text/css" href="style.css">
+ <script>
+ function printNow() {
+ window.print();
+ }
+ </script>
+ </head>
+ <body>
+ <form class="form">
+ <img class="logo" src="icon.svg" alt="qtwebengine">
+ <div class="header">
+ <h1>Hello Paper World!</h1>
+ <h2>Press Ctrl+p to print with print preview</h2>
+ <h2>Press Ctrl+Shift+p to print without print preview</h2>
+ <h2>Click the button to print using JavaScript</h2>
+ <p class="button" onclick="printNow()">Print Now</p>
+ </form>
+ </body>
+</html>
diff --git a/examples/webenginewidgets/printme/data/style.css b/examples/webenginewidgets/printme/data/style.css
new file mode 100644
index 000000000..cf6a2b7bf
--- /dev/null
+++ b/examples/webenginewidgets/printme/data/style.css
@@ -0,0 +1,72 @@
+html,body {
+ height:100%;
+ width:100%;
+ margin:0;
+}
+ body {
+ display:flex;
+}
+ .logo {
+ width: 75px;
+ height: 75px;
+ float: left;
+ margin: 20px 20px 0px 20px;
+ -webkit-animation:spin 8s linear infinite;
+}
+ @-webkit-keyframes spin {
+ 100% {
+ -webkit-transform: rotate(360deg);
+ }
+}
+ .header {
+ display: inline
+}
+ .form {
+ width: 480px;
+ height: 170px;
+ background: -webkit-linear-gradient(bottom, #ddd, #fff);
+ border: 1px solid #999;
+ border-radius: 12px;
+ color: #46a;
+ font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
+ font-size: 14px;
+ font-style: italic;
+ font-weight: bold;
+ margin: auto;
+ padding: 10px;
+ position: relative;
+ line-height: 26px;
+ text-decoration: none;
+ -webkit-box-shadow: 0px 0px 5px #444;
+}
+ h1 {
+ padding-left:40px;
+ color: #46a2da;
+}
+ h2 {
+ color: #80c342;
+ font-size: 13px;
+ margin-top: -20px;
+}
+ span {
+ margin-left: 20px;
+}
+ .button{
+ display: inline-block;
+ background: #46a2da;
+ width: 100px;
+ height: 30px;
+ padding: 0px;
+ text-align: center;
+ font-weight: bold;
+ color: #ffffff;
+ text-decoration: none;
+ border: 1px solid #999;
+ margin-left: 190px;
+}
+ .button:hover {
+ background-color: #46a200
+}
+ .button:active {
+ background-color: #3e8e41;
+}
diff --git a/examples/webenginewidgets/printme/doc/images/printme-example.png b/examples/webenginewidgets/printme/doc/images/printme-example.png
new file mode 100644
index 000000000..a636972fd
--- /dev/null
+++ b/examples/webenginewidgets/printme/doc/images/printme-example.png
Binary files differ
diff --git a/examples/webenginewidgets/printme/doc/src/printme.qdoc b/examples/webenginewidgets/printme/doc/src/printme.qdoc
new file mode 100644
index 000000000..d05d5147b
--- /dev/null
+++ b/examples/webenginewidgets/printme/doc/src/printme.qdoc
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example webenginewidgets/printme
+ \title WebEngine Widgets PrintMe Example
+ \ingroup webengine-widgetexamples
+ \brief Demonstrates how to print web pages using Qt WebEngine Widgets.
+
+ \image printme-example.png
+
+ \e PrintMe demonstrates how to use the \l{QWebEnginePage} and
+ \l{QPrintDialog} classes to print a web page. Further, it shows how
+ to implement print preview by using the \l{QPrintPreviewDialog} class.
+ For completeness, it also illustrates how to trigger a printing request
+ within JavaScript.
+
+ \include examples-run.qdocinc
+
+ \section1 Simple HTML Page
+
+ In this example, we create an internal HTML page that is added as a resource
+ collection file (.qrc). The page shows only a small HTML message box that
+ explains how to trigger printing by using keyboard shortcuts or clicking a
+ button. The button has the JavaScript \c{onclick} event attribute that calls
+ the JavaScript \c{window.print()} function.
+
+ \quotefromfile webenginewidgets/printme/data/index.html
+ \skipto <html
+ \printuntil html>
+
+ \section1 Main Function
+
+ In the \c main function, we first instantiate a QWebEngineView and set the
+ URL to our internal HTML page. Next, we create a \c PrintHandler instance
+ and pass the requested page. For convenience, we also create keyboard
+ shortcuts that can be used to call a print dialog or print preview dialog.
+
+ \quotefromfile webenginewidgets/printme/main.cpp
+ \skipto QWebEngineView view
+ \printto return
+
+ \section1 Print Handler
+
+ In the \c{PrintHandler} function, we first implement \c{printPreview()},
+ where we instantiate \l{QPrinter} together with \l{QPrintPreviewDialog}.
+ We need the \l{QPrintPreviewDialog::paintRequested} handle to generate a
+ set of preview pages.
+
+ \quotefromfile webenginewidgets/printme/printhandler.cpp
+ \skipto PrintHandler::printPreview(
+ \printuntil /^\}/
+
+ Now we can implement the \c{PrintHandler::printDocument()} slot, which is
+ called in response to the \l{QPrintPreviewDialog::paintRequested} signal.
+
+ \quotefromfile webenginewidgets/printme/printhandler.cpp
+ \skipto PrintHandler::printDocument(
+ \printuntil /^\}/
+
+ To do actual painting on a printer, we call the \l{QWebEnginePage::print()}
+ function. Because this call blocks the main event loop, we need to create
+ a local one. We begin the local event loop by calling
+ \l{QEventLoop::exec()}. When the local event loop terminates,
+ we check for \c{result} and report any errors that occurred.
+
+ The last function we implement, \c{PrintHandler::print()}, is trivial,
+ because it simply opens \l{QPrintDialog} and calls the previously
+ implemented \c{PrintHandler::printDocument()}.
+
+ \quotefromfile webenginewidgets/printme/printhandler.cpp
+ \skipto PrintHandler::print(
+ \printuntil /^\}/
+*/
diff --git a/examples/webenginewidgets/printme/main.cpp b/examples/webenginewidgets/printme/main.cpp
new file mode 100644
index 000000000..e4d6d9dc8
--- /dev/null
+++ b/examples/webenginewidgets/printme/main.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "printhandler.h"
+#include <QApplication>
+#include <QShortcut>
+#include <QWebEngineView>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QApplication app(argc, argv);
+
+ QWebEngineView view;
+ view.setUrl(QUrl(QStringLiteral("qrc:/index.html")));
+ view.resize(1024, 750);
+ view.show();
+
+ PrintHandler handler;
+ handler.setPage(view.page());
+
+ auto printPreviewShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_P), &view);
+ auto printShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P), &view);
+
+ QObject::connect(printPreviewShortCut, &QShortcut::activated, &handler, &PrintHandler::printPreview);
+ QObject::connect(printShortCut, &QShortcut::activated, &handler, &PrintHandler::print);
+
+ return app.exec();
+}
diff --git a/examples/webenginewidgets/printme/printhandler.cpp b/examples/webenginewidgets/printme/printhandler.cpp
new file mode 100644
index 000000000..d8c4fc177
--- /dev/null
+++ b/examples/webenginewidgets/printme/printhandler.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "printhandler.h"
+#include <QEventLoop>
+#include <QPrintDialog>
+#include <QPrinter>
+#include <QPainter>
+#include <QPrintPreviewDialog>
+#include <QWebEnginePage>
+
+PrintHandler::PrintHandler(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+void PrintHandler::setPage(QWebEnginePage *page)
+{
+ Q_ASSERT(!m_page);
+ m_page = page;
+ connect(m_page, &QWebEnginePage::printRequested, this, &PrintHandler::printPreview);
+}
+
+void PrintHandler::print()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ QPrintDialog dialog(&printer, m_page->view());
+ if (dialog.exec() != QDialog::Accepted)
+ return;
+ printDocument(&printer);
+}
+
+void PrintHandler::printDocument(QPrinter *printer)
+{
+ QEventLoop loop;
+ bool result;
+ auto printPreview = [&](bool success) { result = success; loop.quit(); };
+ m_page->print(printer, std::move(printPreview));
+ loop.exec();
+ if (!result) {
+ QPainter painter;
+ if (painter.begin(printer)) {
+ QFont font = painter.font();
+ font.setPixelSize(20);
+ painter.setFont(font);
+ painter.drawText(QPointF(10,25),
+ QStringLiteral("Could not generate print preview."));
+
+ painter.end();
+ }
+ }
+}
+
+void PrintHandler::printPreview()
+{
+ if (!m_page)
+ return;
+ if (m_inPrintPreview)
+ return;
+ m_inPrintPreview = true;
+ QPrinter printer;
+ QPrintPreviewDialog preview(&printer, m_page->view());
+ connect(&preview, &QPrintPreviewDialog::paintRequested,
+ this, &PrintHandler::printDocument);
+ preview.exec();
+ m_inPrintPreview = false;
+}
diff --git a/examples/webenginewidgets/printme/printhandler.h b/examples/webenginewidgets/printme/printhandler.h
new file mode 100644
index 000000000..69b71f4a8
--- /dev/null
+++ b/examples/webenginewidgets/printme/printhandler.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PRINTHANDLER_H
+#define PRINTHANDLER_H
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+class QPainter;
+class QPrinter;
+class QWebEnginePage;
+QT_END_NAMESPACE
+
+class PrintHandler : public QObject
+{
+ Q_OBJECT
+public:
+ PrintHandler(QObject *parent = nullptr);
+ void setPage(QWebEnginePage *page);
+
+public slots:
+ void print();
+ void printPreview();
+ void printDocument(QPrinter *printer);
+
+private:
+ QWebEnginePage *m_page = nullptr;
+ bool m_inPrintPreview = false;
+};
+
+#endif // PRINTHANDLER_H
diff --git a/examples/webenginewidgets/printme/printme.pro b/examples/webenginewidgets/printme/printme.pro
new file mode 100644
index 000000000..15b3959d5
--- /dev/null
+++ b/examples/webenginewidgets/printme/printme.pro
@@ -0,0 +1,9 @@
+QT += webenginewidgets printsupport
+
+HEADERS = printhandler.h
+SOURCES = main.cpp \
+ printhandler.cpp
+RESOURCES = data/data.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/printme
+INSTALLS += target
diff --git a/examples/webenginewidgets/simplebrowser/browser.cpp b/examples/webenginewidgets/simplebrowser/browser.cpp
index 5c6dbd35e..68458b2a4 100644
--- a/examples/webenginewidgets/simplebrowser/browser.cpp
+++ b/examples/webenginewidgets/simplebrowser/browser.cpp
@@ -51,8 +51,6 @@
#include "browser.h"
#include "browserwindow.h"
-#include <QWebEngineProfile>
-
Browser::Browser()
{
// Quit application if the download manager window is the only remaining window
@@ -61,14 +59,17 @@ Browser::Browser()
QObject::connect(
QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested,
&m_downloadManagerWidget, &DownloadManagerWidget::downloadRequested);
- QObject::connect(
- &m_otrProfile, &QWebEngineProfile::downloadRequested,
- &m_downloadManagerWidget, &DownloadManagerWidget::downloadRequested);
}
BrowserWindow *Browser::createWindow(bool offTheRecord)
{
- auto profile = offTheRecord ? &m_otrProfile : QWebEngineProfile::defaultProfile();
+ if (offTheRecord && !m_otrProfile) {
+ m_otrProfile.reset(new QWebEngineProfile);
+ QObject::connect(
+ m_otrProfile.get(), &QWebEngineProfile::downloadRequested,
+ &m_downloadManagerWidget, &DownloadManagerWidget::downloadRequested);
+ }
+ auto profile = offTheRecord ? m_otrProfile.get() : QWebEngineProfile::defaultProfile();
auto mainWindow = new BrowserWindow(this, profile, false);
m_windows.append(mainWindow);
QObject::connect(mainWindow, &QObject::destroyed, [this, mainWindow]() {
diff --git a/examples/webenginewidgets/simplebrowser/browser.h b/examples/webenginewidgets/simplebrowser/browser.h
index fbc8465d2..4c17121df 100644
--- a/examples/webenginewidgets/simplebrowser/browser.h
+++ b/examples/webenginewidgets/simplebrowser/browser.h
@@ -73,6 +73,6 @@ public:
private:
QVector<BrowserWindow*> m_windows;
DownloadManagerWidget m_downloadManagerWidget;
- QWebEngineProfile m_otrProfile;
+ QScopedPointer<QWebEngineProfile> m_otrProfile;
};
#endif // BROWSER_H
diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
index b5ad13626..251ca5ad8 100644
--- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
+++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
@@ -270,7 +270,7 @@
Implementing private browsing is quite easy using \QWE. All one has
to do is to create a new \l{QWebEngineProfile} and use it in the
\l{QWebEnginePage} instead of the default profile. In the example this new
- profile is created and owned by the \c Browser object:
+ profile is owned by the \c Browser object:
\quotefromfile webenginewidgets/simplebrowser/browser.h
\skipto /^class Browser$/
@@ -285,15 +285,24 @@
\printline m_otrProfile
\printline /^\};$/
- The default constructor for \l{QWebEngineProfile} already puts it in
- \e{off-the-record} mode. All that is left to do is to pass the appropriate
- profile down to the appropriate \l QWebEnginePage objects. The \c Browser
- object will hand to each new \c BrowserWindow either the global default
- profile (see \l{QWebEngineProfile::defaultProfile}) or its own
- off-the-record profile:
+ Required profile for \e{private browsing} is created together with its
+ first window. The default constructor for \l{QWebEngineProfile} already
+ puts it in \e{off-the-record} mode.
\quotefromfile webenginewidgets/simplebrowser/browser.cpp
+
\skipto Browser::createWindow
+ \printuntil m_otrProfile.reset
+ \dots
+
+ All that is left to do is to pass the appropriate profile down to the
+ appropriate \l QWebEnginePage objects. The \c Browser object will hand to
+ each new \c BrowserWindow either the global default profile
+ (see \l{QWebEngineProfile::defaultProfile}) or one shared
+ \e{off-the-record} profile instance:
+
+ \dots
+ \skipto m_otrProfile.get
\printuntil mainWindow = new BrowserWindow
\skipto return mainWindow
\printuntil /^\}/
diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro
index 20c7ead50..0d47aac80 100644
--- a/examples/webenginewidgets/webenginewidgets.pro
+++ b/examples/webenginewidgets/webenginewidgets.pro
@@ -1,5 +1,5 @@
include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
-QT_FOR_CONFIG += webenginecore
+QT_FOR_CONFIG += webenginecore webenginecore-private
TEMPLATE=subdirs
@@ -7,7 +7,6 @@ SUBDIRS += \
minimal \
contentmanipulation \
cookiebrowser \
- html2pdf \
simplebrowser \
stylesheetbrowser \
videoplayer \
@@ -16,6 +15,10 @@ SUBDIRS += \
qtConfig(webengine-geolocation): SUBDIRS += maps
qtConfig(webengine-webchannel): SUBDIRS += markdowneditor
+qtConfig(webengine-printing-and-pdf) {
+ SUBDIRS += printme html2pdf
+}
+
qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
SUBDIRS += spellchecker
} else {
diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf
index d7d382a4f..42e5b40c9 100644
--- a/mkspecs/features/configure.prf
+++ b/mkspecs/features/configure.prf
@@ -4,6 +4,10 @@ load(functions)
load(platform)
defineTest(runConfigure) {
+ !qtHaveModule(gui) {
+ skipBuild("QtWebEngine requires QtGui.")
+ return(false)
+ }
!exists(src/3rdparty/chromium) {
skipBuild("Submodule qtwebengine-chromium does not exist. Run 'git submodule update --init'.")
diff --git a/src/core/api/qwebengineurlscheme.cpp b/src/core/api/qwebengineurlscheme.cpp
index 9b04f46c5..9cc5b5056 100644
--- a/src/core/api/qwebengineurlscheme.cpp
+++ b/src/core/api/qwebengineurlscheme.cpp
@@ -378,6 +378,11 @@ void QWebEngineUrlScheme::registerScheme(const QWebEngineUrlScheme &scheme)
return;
}
+ if (url::IsStandard(scheme.d->name.data(), url::Component(0, scheme.d->name.size()))) {
+ qWarning() << "QWebEngineUrlScheme::registerScheme: Scheme" << scheme.name() << "is a standard scheme";
+ return;
+ }
+
if (g_schemesLocked) {
qWarning() << "QWebEngineUrlScheme::registerScheme: Too late to register scheme" << scheme.name();
return;
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index b934ea475..429e4e45f 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -71,6 +71,8 @@ msvc:contains(QT_ARCH, "i386"):!usingMSVC32BitCrossCompiler() {
msvc {
equals(MSVC_VER, 15.0) {
MSVS_VERSION = 2017
+ } else: equals(MSVC_VER, 16.0) {
+ MSVS_VERSION = 2019
} else {
error("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine")
}
diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp
index 2bf11990a..b6a2b42ec 100644
--- a/src/core/printing/print_view_manager_qt.cpp
+++ b/src/core/printing/print_view_manager_qt.cpp
@@ -151,21 +151,12 @@ static base::DictionaryValue *createPrintSettingsFromQPageLayout(const QPageLayo
bool useCustomMargins)
{
base::DictionaryValue *printSettings = createPrintSettings();
-
- //Set page size attributes, chromium expects these in micrometers
- QRectF pageSizeInMillimeter = pageLayout.pageSize().rect(QPageSize::Millimeter);
- if (!useCustomMargins) {
- // QPrinter will extend this size with its margins
- QMarginsF margins = pageLayout.margins(QPageLayout::Millimeter);
- pageSizeInMillimeter = pageSizeInMillimeter.marginsRemoved(margins);
- }
- std::unique_ptr<base::DictionaryValue> sizeDict(new base::DictionaryValue);
- sizeDict->SetInteger(printing::kSettingMediaSizeWidthMicrons, pageSizeInMillimeter.width() * kMicronsToMillimeter);
- sizeDict->SetInteger(printing::kSettingMediaSizeHeightMicrons, pageSizeInMillimeter.height() * kMicronsToMillimeter);
- printSettings->Set(printing::kSettingMediaSize, std::move(sizeDict));
+ QRectF pageSizeInMillimeter;
if (useCustomMargins) {
// Apply page margins when printing to PDF
+ pageSizeInMillimeter = pageLayout.pageSize().rect(QPageSize::Millimeter);
+
QMargins pageMarginsInPoints = pageLayout.marginsPoints();
std::unique_ptr<base::DictionaryValue> marginsDict(new base::DictionaryValue);
marginsDict->SetInteger(printing::kSettingMarginTop, pageMarginsInPoints.top());
@@ -175,12 +166,23 @@ static base::DictionaryValue *createPrintSettingsFromQPageLayout(const QPageLayo
printSettings->Set(printing::kSettingMarginsCustom, std::move(marginsDict));
printSettings->SetInteger(printing::kSettingMarginsType, printing::CUSTOM_MARGINS);
+
+ // pageSizeInMillimeter is in portrait orientation. Transpose it if necessary.
+ printSettings->SetBoolean(printing::kSettingLandscape, pageLayout.orientation() == QPageLayout::Landscape);
} else {
// QPrinter will handle margins
+ pageSizeInMillimeter = pageLayout.paintRect(QPageLayout::Millimeter);
printSettings->SetInteger(printing::kSettingMarginsType, printing::NO_MARGINS);
+
+ // pageSizeInMillimeter already contains the orientation.
+ printSettings->SetBoolean(printing::kSettingLandscape, false);
}
- printSettings->SetBoolean(printing::kSettingLandscape, pageLayout.orientation() == QPageLayout::Landscape);
+ //Set page size attributes, chromium expects these in micrometers
+ std::unique_ptr<base::DictionaryValue> sizeDict(new base::DictionaryValue);
+ sizeDict->SetInteger(printing::kSettingMediaSizeWidthMicrons, pageSizeInMillimeter.width() * kMicronsToMillimeter);
+ sizeDict->SetInteger(printing::kSettingMediaSizeHeightMicrons, pageSizeInMillimeter.height() * kMicronsToMillimeter);
+ printSettings->Set(printing::kSettingMediaSize, std::move(sizeDict));
return printSettings;
}
diff --git a/src/core/profile_qt.cpp b/src/core/profile_qt.cpp
index 14a39de49..5977a28a8 100644
--- a/src/core/profile_qt.cpp
+++ b/src/core/profile_qt.cpp
@@ -246,7 +246,9 @@ content::BackgroundSyncController* ProfileQt::GetBackgroundSyncController()
content::BrowsingDataRemoverDelegate *ProfileQt::GetBrowsingDataRemoverDelegate()
{
- return new BrowsingDataRemoverDelegateQt();
+ if (!m_removerDelegate)
+ m_removerDelegate.reset(new BrowsingDataRemoverDelegateQt);
+ return m_removerDelegate.get();
}
content::PermissionControllerDelegate *ProfileQt::GetPermissionControllerDelegate()
diff --git a/src/core/profile_qt.h b/src/core/profile_qt.h
index 5a602f56a..704c5a6e4 100644
--- a/src/core/profile_qt.h
+++ b/src/core/profile_qt.h
@@ -60,6 +60,7 @@ class ExtensionSystemQt;
namespace QtWebEngineCore {
+class BrowsingDataRemoverDelegateQt;
class ProfileAdapter;
class PermissionManagerQt;
class SSLHostStateDelegateQt;
@@ -130,6 +131,7 @@ private:
friend class ContentBrowserClientQt;
friend class WebContentsAdapter;
scoped_refptr<net::URLRequestContextGetter> m_urlRequestContextGetter;
+ std::unique_ptr<BrowsingDataRemoverDelegateQt> m_removerDelegate;
std::unique_ptr<PermissionManagerQt> m_permissionManager;
std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate;
std::unique_ptr<PrefService> m_prefService;
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 9c6749f39..4c0a7a21f 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -715,6 +715,13 @@ void QWebEnginePagePrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView
view->d_func()->pageChanged(oldPage, page);
if (oldWidget != widget)
view->d_func()->widgetChanged(oldWidget, widget);
+
+ // At this point m_ownsPage should still refer to oldPage,
+ // it is only set for the new page after binding.
+ if (view->d_func()->m_ownsPage) {
+ delete oldPage;
+ view->d_func()->m_ownsPage = false;
+ }
}
}
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 91fc86cdf..6c08df343 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -126,6 +126,7 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje
QWebEngineViewPrivate::QWebEngineViewPrivate()
: page(0)
, m_dragEntered(false)
+ , m_ownsPage(false)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
@@ -176,6 +177,7 @@ QWebEnginePage* QWebEngineView::page() const
if (!d->page) {
QWebEngineView *that = const_cast<QWebEngineView*>(this);
that->setPage(new QWebEnginePage(that));
+ d->m_ownsPage = true;
}
return d->page;
}
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index 28fb883aa..7848e0cf3 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -77,6 +77,7 @@ public:
QWebEnginePage *page;
bool m_dragEntered;
+ mutable bool m_ownsPage;
};
#ifndef QT_NO_ACCESSIBILITY
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index 61d16bc8a..c1307c5e6 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -172,6 +172,7 @@ private Q_SLOTS:
void cleanupTestCase();
void jsUrlCanon();
+ void jsUrlRelative();
void jsUrlOrigin();
void subdirWithAccess();
void subdirWithoutAccess();
@@ -281,6 +282,54 @@ void tst_Origins::jsUrlCanon()
QVariant(QSL("hostportanduserinformationsyntax://a:b@foo/bar")));
}
+// Test relative URL resolution.
+void tst_Origins::jsUrlRelative()
+{
+ QVERIFY(load(QSL("about:blank")));
+
+ // Schemes with hosts, like http, work as expected.
+ QCOMPARE(eval(QSL("new URL('bar', 'http://foo').href")), QVariant(QSL("http://foo/bar")));
+ QCOMPARE(eval(QSL("new URL('baz', 'http://foo/bar').href")), QVariant(QSL("http://foo/baz")));
+ QCOMPARE(eval(QSL("new URL('baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/bar/baz")));
+ QCOMPARE(eval(QSL("new URL('/baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz")));
+ QCOMPARE(eval(QSL("new URL('./baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/bar/baz")));
+ QCOMPARE(eval(QSL("new URL('../baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz")));
+ QCOMPARE(eval(QSL("new URL('../../baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz")));
+ QCOMPARE(eval(QSL("new URL('//baz', 'http://foo/bar/').href")), QVariant(QSL("http://baz/")));
+
+ // In the case of schemes without hosts, relative URLs only work if the URL
+ // starts with a single slash -- and canonicalization does not guarantee
+ // this. The following cases all fail with TypeErrors.
+ QCOMPARE(eval(QSL("new URL('bar', 'tst:foo').href")), QVariant());
+ QCOMPARE(eval(QSL("new URL('baz', 'tst:foo/bar').href")), QVariant());
+ QCOMPARE(eval(QSL("new URL('bar', 'tst://foo').href")), QVariant());
+ QCOMPARE(eval(QSL("new URL('bar', 'tst:///foo').href")), QVariant());
+
+ // However, registered custom schemes have been patched to allow relative
+ // URLs even without an initial slash.
+ QCOMPARE(eval(QSL("new URL('bar', 'qrc:foo').href")), QVariant(QSL("qrc:bar")));
+ QCOMPARE(eval(QSL("new URL('baz', 'qrc:foo/bar').href")), QVariant(QSL("qrc:foo/baz")));
+ QCOMPARE(eval(QSL("new URL('bar', 'qrc://foo').href")), QVariant());
+ QCOMPARE(eval(QSL("new URL('bar', 'qrc:///foo').href")), QVariant());
+
+ // With a slash it works the same as http except 'foo' is part of the path and not the host.
+ QCOMPARE(eval(QSL("new URL('bar', 'qrc:/foo').href")), QVariant(QSL("qrc:/bar")));
+ QCOMPARE(eval(QSL("new URL('bar', 'qrc:/foo/').href")), QVariant(QSL("qrc:/foo/bar")));
+ QCOMPARE(eval(QSL("new URL('baz', 'qrc:/foo/bar').href")), QVariant(QSL("qrc:/foo/baz")));
+ QCOMPARE(eval(QSL("new URL('baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/bar/baz")));
+ QCOMPARE(eval(QSL("new URL('/baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz")));
+ QCOMPARE(eval(QSL("new URL('./baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/bar/baz")));
+ QCOMPARE(eval(QSL("new URL('../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/baz")));
+ QCOMPARE(eval(QSL("new URL('../../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz")));
+ QCOMPARE(eval(QSL("new URL('../../../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz")));
+
+ // If the relative URL begins with >= 2 slashes, then the scheme is treated
+ // not as a Syntax::Path scheme but as a Syntax::HostPortAndUserInformation
+ // scheme.
+ QCOMPARE(eval(QSL("new URL('//baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc://baz/")));
+ QCOMPARE(eval(QSL("new URL('///baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc://baz/")));
+}
+
// Test origin serialization in Blink, implemented by blink::KURL and
// blink::SecurityOrigin as opposed to GURL and url::Origin.
void tst_Origins::jsUrlOrigin()
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index ebd25e892..ff073799c 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -213,9 +213,8 @@ public:
void requestStarted(QWebEngineUrlRequestJob *job)
{
- QBuffer *buffer = new QBuffer;
+ QBuffer *buffer = new QBuffer(job);
buffer->setData(job->requestUrl().toString().toUtf8());
- connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater);
m_buffers.append(buffer);
job->reply("text/plain;charset=utf-8", buffer);
}
@@ -634,14 +633,15 @@ void tst_QWebEngineProfile::initiator()
void tst_QWebEngineProfile::qtbug_71895()
{
QWebEngineView view;
+ QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool)));
view.setUrl(QUrl("https://www.qt.io"));
view.show();
- QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool)));
view.page()->profile()->clearHttpCache();
view.page()->profile()->setHttpCacheType(QWebEngineProfile::NoCache);
view.page()->profile()->cookieStore()->deleteAllCookies();
view.page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000);
+ QVERIFY(loadSpy.front().front().toBool());
}
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 16a3d32b6..74adbaba9 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -196,6 +196,10 @@ private Q_SLOTS:
void deletePage();
void closeOpenerTab();
void switchPage();
+ void setPageDeletesImplicitPage();
+ void setViewDeletesImplicitPage();
+ void setPagePreservesExplicitPage();
+ void setViewPreservesExplicitPage();
};
// This will be called before the first test function is executed.
@@ -3197,5 +3201,47 @@ void tst_QWebEngineView::switchPage()
QTRY_COMPARE(webView.grab().toImage().pixelColor(QPoint(150,150)), Qt::black);
}
+void tst_QWebEngineView::setPageDeletesImplicitPage()
+{
+ QWebEngineView view;
+ QPointer<QWebEnginePage> implicitPage = view.page();
+ QWebEnginePage explicitPage;
+ view.setPage(&explicitPage);
+ QCOMPARE(view.page(), &explicitPage);
+ QVERIFY(!implicitPage); // should be deleted
+}
+
+void tst_QWebEngineView::setViewDeletesImplicitPage()
+{
+ QWebEngineView view;
+ QPointer<QWebEnginePage> implicitPage = view.page();
+ QWebEnginePage explicitPage;
+ explicitPage.setView(&view);
+ QCOMPARE(view.page(), &explicitPage);
+ QVERIFY(!implicitPage); // should be deleted
+}
+
+void tst_QWebEngineView::setPagePreservesExplicitPage()
+{
+ QWebEngineView view;
+ QPointer<QWebEnginePage> explicitPage1 = new QWebEnginePage(&view);
+ QPointer<QWebEnginePage> explicitPage2 = new QWebEnginePage(&view);
+ view.setPage(explicitPage1.data());
+ view.setPage(explicitPage2.data());
+ QCOMPARE(view.page(), explicitPage2.data());
+ QVERIFY(explicitPage1); // should not be deleted
+}
+
+void tst_QWebEngineView::setViewPreservesExplicitPage()
+{
+ QWebEngineView view;
+ QPointer<QWebEnginePage> explicitPage1 = new QWebEnginePage(&view);
+ QPointer<QWebEnginePage> explicitPage2 = new QWebEnginePage(&view);
+ explicitPage1->setView(&view);
+ explicitPage2->setView(&view);
+ QCOMPARE(view.page(), explicitPage2.data());
+ QVERIFY(explicitPage1); // should not be deleted
+}
+
QTEST_MAIN(tst_QWebEngineView)
#include "tst_qwebengineview.moc"