Skip to content

Commit c9e9245

Browse files
committed
Adding support to submit cleaned diagnostic information to a gist and stop hiding errors so that we can fix them faster
1 parent 8e072aa commit c9e9245

File tree

6 files changed

+173
-1
lines changed

6 files changed

+173
-1
lines changed

Diff for: ide/main/src/content/editor.js

+16
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,20 @@ Editor.prototype.resetWindow = function () {
686686
}
687687
}
688688
};
689+
Editor.prototype.submitDiagInfo = function(){
690+
this.health.runDiagnostics();
691+
var data = {
692+
data: this.health.getJSON()
693+
};
694+
window.openDialog("chrome://selenium-ide/content/health/diag-info.xul", "diagInfo", "chrome,modal,resizable", data);
695+
if (data.data.length > 0) {
696+
GitHub.createGist("Selenium IDE diagnostic information", data).done(function(url){
697+
alert("Gist created with diagnostic information.\nPlease update the issue on https://code.google.com/p/selenium/issues/ with this url.\nURL: " + url);
698+
}, function(response, success, status){
699+
alert("Gist creation failed with status " + status + "\nResponse:-\n" + (response || ''));
700+
});
701+
}
702+
};
689703

690704
//Samit: Enh: Introduced experimental features to enable or disable experimental and unstable features
691705
Editor.prototype.updateExperimentalFeatures = function (show) {
@@ -1034,12 +1048,14 @@ Editor.prototype.loadExtensions = function () {
10341048
this.showAlert(Editor.getFormattedString('ide.extensions.failed', [error.toString()]));
10351049
}
10361050
}
1051+
var health = this.health;
10371052
var pluginManager = this.pluginManager;
10381053
pluginManager.getEnabledIDEExtensions().forEach(function (plugin) {
10391054
for (var i = 0; i < plugin.code.length; i++) {
10401055
try {
10411056
ExtensionsLoader.loadSubScript(subScriptLoader, plugin.code[i], window);
10421057
} catch (error) {
1058+
health.addException('editor', 'plugin: ' + plugin.id, error);
10431059
pluginManager.setPluginError(plugin.id, plugin.code[i], error);
10441060
break;
10451061
}

Diff for: ide/main/src/content/health/diag-info.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var diagInfo = window.arguments[0];
2+
3+
function init() {
4+
_loadDiagInfo();
5+
}
6+
7+
function submitInfo() {
8+
if (!document.getElementById('consent').checked) {
9+
alert("The diagnostic information will be submitted only if you provide your consent through the check box");
10+
return false;
11+
}
12+
return true;
13+
}
14+
15+
function cancelSubmit() {
16+
diagInfo.data = "";
17+
return true;
18+
}
19+
20+
function _loadDiagInfo() {
21+
document.getElementById('diag').value = diagInfo.data;
22+
}
23+
24+
function mask() {
25+
var maskText = document.getElementById('mask');
26+
diagInfo.data = diagInfo.data.replace(maskText.value, '*****', 'g');
27+
maskText.value = "";
28+
_loadDiagInfo();
29+
}
30+

Diff for: ide/main/src/content/health/diag-info.xul

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
2+
<!--
3+
Copyright 2014 Samit Badle
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<!DOCTYPE dialog [
18+
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
19+
%browserDTD;
20+
]>
21+
<dialog buttons="accept,cancel"
22+
id="selenium-ide-diag-info"
23+
title="Diagnostic Information"
24+
width="520"
25+
height="600"
26+
onload="init()"
27+
ondialogaccept="return submitInfo();"
28+
ondialogcancel="return cancelSubmit();"
29+
buttonlabelaccept="Submit"
30+
defaultButton=""
31+
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
32+
33+
<script type="application/x-javascript" src="chrome://selenium-ide/content/browser/mozilla/prompt-service.js"/>
34+
<script type="application/x-javascript" src="chrome://selenium-ide/content/health/diag-info.js"/>
35+
<vbox flex="1">
36+
<groupbox flex="1">
37+
<caption label="Diagnostic Information"/>
38+
<textbox id="diag" flex="1" multiline="true" readonly="true"/>
39+
</groupbox>
40+
<description>
41+
Sometimes the diagnostic information can contain sensitive information like passwords contained in error messages. Please check and replace all sensitive information by replacing it with ***** using the text box below.
42+
</description>
43+
<hbox align="center">
44+
<textbox id="mask" multiline="false" flex="1"/>
45+
<button id="mask-button" label="Replace" tooltiptext="Mask sensitive information" oncommand="mask()"/>
46+
</hbox>
47+
<separator class="groove-thin"/>
48+
<description>
49+
The information will be sent to a public server.
50+
</description>
51+
<hbox align="center">
52+
<checkbox id="consent" label="I consent that this information can be made available publicly"/>
53+
</hbox>
54+
</vbox>
55+
</dialog>

Diff for: ide/main/src/content/preferences.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ SeleniumIDE.Preferences.DEFAULT_OPTIONS = {
169169
//Internal data
170170
pluginsData: "[]",
171171
currentVersion: "",
172-
showHealthAlerts: "false",
172+
showHealthAlerts: "true",
173173
lastSavedTestCase: "",
174174
lastSavedTestSuite: ""
175175
};

Diff for: ide/main/src/content/selenium-ide-common.xul

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ limitations under the License.
5757
<script type="application/x-javascript" src="chrome://selenium-ide/content/storedHistory.js"/>
5858
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/deferred.js"/>
5959
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/http.js"/>
60+
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/gist.js"/>
6061
<script type="application/x-javascript" src="chrome://selenium-ide/content/browser/mozilla/prompt-service.js"/>
6162
<script type="application/x-javascript" src="chrome://selenium-ide/content/editor.js"/>
6263
<script type="application/x-javascript" src="chrome://selenium-ide/content/sidebar-editor.js"/>
@@ -241,6 +242,8 @@ limitations under the License.
241242
<menuseparator/>
242243
<menuitem label="&helpReportIssue.label;" oncommand="openTabOrWindow('https://code.google.com/p/selenium/issues/entry?template=Defect report from user&amp;labels=Component-IDE,Priority-Medium,Type-Defect')"/>
243244
<menuitem label="&helpSearchIssues.label;" oncommand="openTabOrWindow('https://code.google.com/p/selenium/issues/list?can=1&amp;q=&amp;sort=-id&amp;colspec=ID+Stars+Type+Status+Priority+Owner+Summary&amp;cells=tiles')"/>
245+
<menuitem label="&helpSubmitDiagInfo.label;" oncommand="window.editor.submitDiagInfo();"/>
246+
<menuseparator/>
244247
<menuitem label="&helpReleaseNotes.label;" oncommand="openTabOrWindow('http://code.google.com/p/selenium/wiki/SeIDEReleaseNotes')"/>
245248
<menuitem label="&helpBlog.label;" oncommand="openTabOrWindow('http://seleniumhq.wordpress.com/')"/>
246249
<menuitem label="&helpWebsite.label;" oncommand="openTabOrWindow('http://seleniumhq.org/')"/>

Diff for: ide/main/src/content/utils/gist.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2015 Samit Badle
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Creating public gists on GitHub
19+
*/
20+
function GitHub() {
21+
}
22+
23+
/**
24+
* Create a gist with the given description, content and optionally a filename and returns a deferred that gives the url of the created gist
25+
*
26+
* @param description description of the gist
27+
* @param content content of the gist
28+
* @param [filename] optional filename for the content
29+
* @returns {Deferred} deferred which on success provides the gist url
30+
*/
31+
GitHub.createGist = function(description, content, filename) {
32+
var files = {};
33+
files[filename || 'file'] = content;
34+
return this.createGistWithFiles(description, files);
35+
};
36+
37+
/**
38+
* Create a gist with the given description and a set of files and returns a deferred that gives the url of the created gist
39+
*
40+
* @param description description of the gist
41+
* @param {object.<string,string>} files an object with each key is the filename and value is the content
42+
* @returns {Deferred} deferred which on success provides the gist url
43+
*/
44+
GitHub.createGistWithFiles = function(description, files) {
45+
var gistFiles = {};
46+
for (var file in files) {
47+
gistFiles[file] = {
48+
content: files[file]
49+
};
50+
}
51+
var data = {
52+
description: description,
53+
public: true,
54+
files: gistFiles
55+
};
56+
return new Deferred(function(deferred) {
57+
HTTP.post('https://api.github.com/gists', data, {}, function(response, success, status) {
58+
if (status == 201 && response) {
59+
var result = JSON.parse(response);
60+
if (result.html_url) {
61+
deferred.resolve(result.html_url);
62+
return;
63+
}
64+
}
65+
deferred.reject(response, success, status);
66+
});
67+
});
68+
};

0 commit comments

Comments
 (0)