summaryrefslogtreecommitdiffstats
path: root/tests/quicktestbrowser
diff options
context:
space:
mode:
Diffstat (limited to 'tests/quicktestbrowser')
-rw-r--r--tests/quicktestbrowser/ApplicationRoot.qml25
-rw-r--r--tests/quicktestbrowser/BrowserDialog.qml2
-rw-r--r--tests/quicktestbrowser/BrowserWindow.qml46
3 files changed, 42 insertions, 31 deletions
diff --git a/tests/quicktestbrowser/ApplicationRoot.qml b/tests/quicktestbrowser/ApplicationRoot.qml
index b16ee0078..71737694d 100644
--- a/tests/quicktestbrowser/ApplicationRoot.qml
+++ b/tests/quicktestbrowser/ApplicationRoot.qml
@@ -39,9 +39,19 @@
****************************************************************************/
import QtQuick 2.1
+import QtWebEngine 1.1
QtObject {
id: root
+
+ property QtObject testProfile: WebEngineProfile {
+ storageName: "Test"
+ }
+
+ property QtObject otrProfile: WebEngineProfile {
+ offTheRecord: true
+ }
+
property Component browserWindowComponent: BrowserWindow {
applicationRoot: root
onClosing: destroy()
@@ -49,10 +59,19 @@ QtObject {
property Component browserDialogComponent: BrowserDialog {
onClosing: destroy()
}
- function createWindow() { return browserWindowComponent.createObject(root) }
- function createDialog() { return browserDialogComponent.createObject(root) }
+ function createWindow(profile) {
+ var newWindow = browserWindowComponent.createObject(root)
+ newWindow.currentWebView.profile = profile
+ profile.downloadRequested.connect(newWindow.onDownloadRequested)
+ return newWindow
+ }
+ function createDialog(profile) {
+ var newDialog = browserDialogComponent.createObject(root)
+ newDialog.currentWebView.profile = profile
+ return newDialog
+ }
function load(url) {
- var browserWindow = createWindow()
+ var browserWindow = createWindow(testProfile)
browserWindow.currentWebView.url = url
}
}
diff --git a/tests/quicktestbrowser/BrowserDialog.qml b/tests/quicktestbrowser/BrowserDialog.qml
index 302833083..6202d02f7 100644
--- a/tests/quicktestbrowser/BrowserDialog.qml
+++ b/tests/quicktestbrowser/BrowserDialog.qml
@@ -40,7 +40,7 @@
import QtQuick 2.1
import QtQuick.Window 2.2
-import QtWebEngine 1.0
+import QtWebEngine 1.1
Window {
property alias currentWebView: webView
diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml
index 6dfe36761..e626f00c7 100644
--- a/tests/quicktestbrowser/BrowserWindow.qml
+++ b/tests/quicktestbrowser/BrowserWindow.qml
@@ -79,22 +79,6 @@ ApplicationWindow {
property alias pluginsEnabled: pluginsEnabled.checked;
}
- WebEngineProfile {
- id: testProfile
- storageName: "Test"
- httpCacheType: httpDiskCacheEnabled.checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache;
- onDownloadRequested: {
- downloadView.visible = true
- downloadView.append(download)
- download.accept()
- }
- }
-
- WebEngineProfile {
- id: otrProfile
- offTheRecord: true
- }
-
// Make sure the Qt.WindowFullscreenButtonHint is set on OS X.
Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint
@@ -128,7 +112,7 @@ ApplicationWindow {
Action {
shortcut: "Ctrl+T"
onTriggered: {
- tabs.createEmptyTab()
+ tabs.createEmptyTab(currentWebView.profile)
tabs.currentIndex = tabs.count - 1
addressBar.forceActiveFocus();
addressBar.selectAll();
@@ -271,13 +255,15 @@ ApplicationWindow {
id: offTheRecordEnabled
text: "Off The Record"
checkable: true
- checked: false
+ checked: currentWebView.profile.offTheRecord
+ onToggled: currentWebView.profile = checked ? otrProfile : testProfile;
}
MenuItem {
id: httpDiskCacheEnabled
text: "HTTP Disk Cache"
- checkable: true
- checked: (testProfile.httpCacheType == WebEngineProfile.DiskHttpCache)
+ checkable: !currentWebView.profile.offTheRecord
+ checked: (currentWebView.profile.httpCacheType == WebEngineProfile.DiskHttpCache)
+ onToggled: currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache;
}
}
}
@@ -304,16 +290,17 @@ ApplicationWindow {
TabView {
id: tabs
- function createEmptyTab() {
+ function createEmptyTab(profile) {
var tab = addTab("", tabComponent)
// We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately.
tab.active = true
tab.title = Qt.binding(function() { return tab.item.title })
+ tab.item.webView.profile = profile
return tab
}
anchors.fill: parent
- Component.onCompleted: createEmptyTab()
+ Component.onCompleted: createEmptyTab(testProfile)
Component {
id: tabComponent
@@ -342,7 +329,6 @@ ApplicationWindow {
WebEngineView {
id: webEngineView
- profile: offTheRecordEnabled.checked ? otrProfile : testProfile
anchors {
fill: parent
@@ -383,17 +369,17 @@ ApplicationWindow {
if (!request.userInitiated)
print("Warning: Blocked a popup window.")
else if (request.destination == WebEngineView.NewViewInTab) {
- var tab = tabs.createEmptyTab()
+ var tab = tabs.createEmptyTab(currentWebView.profile)
tabs.currentIndex = tabs.count - 1
request.openIn(tab.item.webView)
} else if (request.destination == WebEngineView.NewViewInBackgroundTab) {
- var tab = tabs.createEmptyTab()
+ var tab = tabs.createEmptyTab(currentWebView.profile)
request.openIn(tab.item.webView)
} else if (request.destination == WebEngineView.NewViewInDialog) {
- var dialog = applicationRoot.createDialog()
+ var dialog = applicationRoot.createDialog(currentWebView.profile)
request.openIn(dialog.currentWebView)
} else {
- var window = applicationRoot.createWindow()
+ var window = applicationRoot.createWindow(currentWebView.profile)
request.openIn(window.currentWebView)
}
}
@@ -514,6 +500,12 @@ ApplicationWindow {
anchors.fill: parent
}
+ function onDownloadRequested(download) {
+ downloadView.visible = true
+ downloadView.append(download)
+ download.accept()
+ }
+
ZoomController {
id: zoomController
y: parent.mapFromItem(currentWebView, 0 , 0).y - 4