Skip to content

Commit

Permalink
Adding support to submit cleaned diagnostic information to a gist and…
Browse files Browse the repository at this point in the history
… stop hiding errors so that we can fix them faster
  • Loading branch information
samitbadle committed Mar 9, 2015
1 parent 8e072aa commit c9e9245
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ide/main/src/content/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,20 @@ Editor.prototype.resetWindow = function () {
}
}
};
Editor.prototype.submitDiagInfo = function(){
this.health.runDiagnostics();
var data = {
data: this.health.getJSON()
};
window.openDialog("chrome://selenium-ide/content/health/diag-info.xul", "diagInfo", "chrome,modal,resizable", data);
if (data.data.length > 0) {
GitHub.createGist("Selenium IDE diagnostic information", data).done(function(url){
alert("Gist created with diagnostic information.\nPlease update the issue on https://code.google.com/p/selenium/issues/ with this url.\nURL: " + url);
}, function(response, success, status){
alert("Gist creation failed with status " + status + "\nResponse:-\n" + (response || ''));
});
}
};

//Samit: Enh: Introduced experimental features to enable or disable experimental and unstable features
Editor.prototype.updateExperimentalFeatures = function (show) {
Expand Down Expand Up @@ -1034,12 +1048,14 @@ Editor.prototype.loadExtensions = function () {
this.showAlert(Editor.getFormattedString('ide.extensions.failed', [error.toString()]));
}
}
var health = this.health;
var pluginManager = this.pluginManager;
pluginManager.getEnabledIDEExtensions().forEach(function (plugin) {
for (var i = 0; i < plugin.code.length; i++) {
try {
ExtensionsLoader.loadSubScript(subScriptLoader, plugin.code[i], window);
} catch (error) {
health.addException('editor', 'plugin: ' + plugin.id, error);
pluginManager.setPluginError(plugin.id, plugin.code[i], error);
break;
}
Expand Down
30 changes: 30 additions & 0 deletions ide/main/src/content/health/diag-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var diagInfo = window.arguments[0];

function init() {
_loadDiagInfo();
}

function submitInfo() {
if (!document.getElementById('consent').checked) {
alert("The diagnostic information will be submitted only if you provide your consent through the check box");
return false;
}
return true;
}

function cancelSubmit() {
diagInfo.data = "";
return true;
}

function _loadDiagInfo() {
document.getElementById('diag').value = diagInfo.data;
}

function mask() {
var maskText = document.getElementById('mask');
diagInfo.data = diagInfo.data.replace(maskText.value, '*****', 'g');
maskText.value = "";
_loadDiagInfo();
}

55 changes: 55 additions & 0 deletions ide/main/src/content/health/diag-info.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<!--
Copyright 2014 Samit Badle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE dialog [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
%browserDTD;
]>
<dialog buttons="accept,cancel"
id="selenium-ide-diag-info"
title="Diagnostic Information"
width="520"
height="600"
onload="init()"
ondialogaccept="return submitInfo();"
ondialogcancel="return cancelSubmit();"
buttonlabelaccept="Submit"
defaultButton=""
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/x-javascript" src="chrome://selenium-ide/content/browser/mozilla/prompt-service.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/health/diag-info.js"/>
<vbox flex="1">
<groupbox flex="1">
<caption label="Diagnostic Information"/>
<textbox id="diag" flex="1" multiline="true" readonly="true"/>
</groupbox>
<description>
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.
</description>
<hbox align="center">
<textbox id="mask" multiline="false" flex="1"/>
<button id="mask-button" label="Replace" tooltiptext="Mask sensitive information" oncommand="mask()"/>
</hbox>
<separator class="groove-thin"/>
<description>
The information will be sent to a public server.
</description>
<hbox align="center">
<checkbox id="consent" label="I consent that this information can be made available publicly"/>
</hbox>
</vbox>
</dialog>
2 changes: 1 addition & 1 deletion ide/main/src/content/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ SeleniumIDE.Preferences.DEFAULT_OPTIONS = {
//Internal data
pluginsData: "[]",
currentVersion: "",
showHealthAlerts: "false",
showHealthAlerts: "true",
lastSavedTestCase: "",
lastSavedTestSuite: ""
};
Expand Down
3 changes: 3 additions & 0 deletions ide/main/src/content/selenium-ide-common.xul
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ limitations under the License.
<script type="application/x-javascript" src="chrome://selenium-ide/content/storedHistory.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/deferred.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/http.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/utils/gist.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/browser/mozilla/prompt-service.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/editor.js"/>
<script type="application/x-javascript" src="chrome://selenium-ide/content/sidebar-editor.js"/>
Expand Down Expand Up @@ -241,6 +242,8 @@ limitations under the License.
<menuseparator/>
<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')"/>
<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')"/>
<menuitem label="&helpSubmitDiagInfo.label;" oncommand="window.editor.submitDiagInfo();"/>
<menuseparator/>
<menuitem label="&helpReleaseNotes.label;" oncommand="openTabOrWindow('http://code.google.com/p/selenium/wiki/SeIDEReleaseNotes')"/>
<menuitem label="&helpBlog.label;" oncommand="openTabOrWindow('http://seleniumhq.wordpress.com/')"/>
<menuitem label="&helpWebsite.label;" oncommand="openTabOrWindow('http://seleniumhq.org/')"/>
Expand Down
68 changes: 68 additions & 0 deletions ide/main/src/content/utils/gist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2015 Samit Badle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Creating public gists on GitHub
*/
function GitHub() {
}

/**
* Create a gist with the given description, content and optionally a filename and returns a deferred that gives the url of the created gist
*
* @param description description of the gist
* @param content content of the gist
* @param [filename] optional filename for the content
* @returns {Deferred} deferred which on success provides the gist url
*/
GitHub.createGist = function(description, content, filename) {
var files = {};
files[filename || 'file'] = content;
return this.createGistWithFiles(description, files);
};

/**
* Create a gist with the given description and a set of files and returns a deferred that gives the url of the created gist
*
* @param description description of the gist
* @param {object.<string,string>} files an object with each key is the filename and value is the content
* @returns {Deferred} deferred which on success provides the gist url
*/
GitHub.createGistWithFiles = function(description, files) {
var gistFiles = {};
for (var file in files) {
gistFiles[file] = {
content: files[file]
};
}
var data = {
description: description,
public: true,
files: gistFiles
};
return new Deferred(function(deferred) {
HTTP.post('https://api.github.com/gists', data, {}, function(response, success, status) {
if (status == 201 && response) {
var result = JSON.parse(response);
if (result.html_url) {
deferred.resolve(result.html_url);
return;
}
}
deferred.reject(response, success, status);
});
});
};

0 comments on commit c9e9245

Please sign in to comment.