Merge lp:~osomon/oxide/fix-crash-js-dialog into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1059
Proposed branch: lp:~osomon/oxide/fix-crash-js-dialog
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 86 lines (+54/-1)
3 files modified
qt/tests/qmltests/crash/tst_bug1450570.html (+7/-0)
qt/tests/qmltests/crash/tst_bug1450570.qml (+36/-0)
shared/browser/oxide_javascript_dialog.cc (+11/-1)
To merge this branch: bzr merge lp:~osomon/oxide/fix-crash-js-dialog
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+257956@code.launchpad.net

Commit message

Fix a crash when a JS dialog is dismissed twice (by calling accept() and then reject() on it).

To post a comment you must log in.
Revision history for this message
Chris Coulson (chrisccoulson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qt/tests/qmltests/crash/tst_bug1450570.html'
2--- qt/tests/qmltests/crash/tst_bug1450570.html 1970-01-01 00:00:00 +0000
3+++ qt/tests/qmltests/crash/tst_bug1450570.html 2015-04-30 19:24:04 +0000
4@@ -0,0 +1,7 @@
5+<html>
6+<body>
7+ <script>
8+ prompt("", "");
9+ </script>
10+</body>
11+</html>
12
13=== added file 'qt/tests/qmltests/crash/tst_bug1450570.qml'
14--- qt/tests/qmltests/crash/tst_bug1450570.qml 1970-01-01 00:00:00 +0000
15+++ qt/tests/qmltests/crash/tst_bug1450570.qml 2015-04-30 19:24:04 +0000
16@@ -0,0 +1,36 @@
17+import QtQuick 2.0
18+import QtTest 1.0
19+import com.canonical.Oxide 1.0
20+import com.canonical.Oxide.Testing 1.0
21+
22+TestWebView {
23+ id: webView
24+ focus: true
25+ width: 200
26+ height: 200
27+
28+ property bool promptDialogDestroyed: false
29+
30+ promptDialog: Item {
31+ Component.onCompleted: model.accept("")
32+ onVisibleChanged: {
33+ if (!visible) {
34+ model.reject()
35+ }
36+ }
37+ Component.onDestruction: promptDialogDestroyed = true
38+ }
39+
40+ TestCase {
41+ name: "bug1450570"
42+ when: windowShown
43+
44+ function test_bug1450570() {
45+ webView.url = "http://testsuite/tst_bug1450570.html";
46+ verify(webView.waitForLoadSucceeded(),
47+ "Timed out waiting for successful load");
48+
49+ tryCompare(webView, "promptDialogDestroyed", true);
50+ }
51+ }
52+}
53
54=== modified file 'shared/browser/oxide_javascript_dialog.cc'
55--- shared/browser/oxide_javascript_dialog.cc 2015-04-09 16:41:51 +0000
56+++ shared/browser/oxide_javascript_dialog.cc 2015-04-30 19:24:04 +0000
57@@ -1,5 +1,5 @@
58 // vim:expandtab:shiftwidth=2:tabstop=2:
59-// Copyright (C) 2014 Canonical Ltd.
60+// Copyright (C) 2014-2015 Canonical Ltd.
61
62 // This library is free software; you can redistribute it and/or
63 // modify it under the terms of the GNU Lesser General Public
64@@ -30,13 +30,23 @@
65 JavaScriptDialog::~JavaScriptDialog() {}
66
67 void JavaScriptDialog::Close(bool accept, const base::string16& user_input) {
68+ if (callback_.is_null()) {
69+ return;
70+ }
71+
72 callback_.Run(accept, user_input);
73+ callback_.Reset();
74 Hide();
75 JavaScriptDialogManager::GetInstance()->DialogClosed(web_contents_, this);
76 }
77
78 void JavaScriptDialog::Cancel() {
79+ if (callback_.is_null()) {
80+ return;
81+ }
82+
83 callback_.Run(false, base::string16());
84+ callback_.Reset();
85 Hide();
86 }
87

Subscribers

People subscribed via source and target branches