Created
February 23, 2010 22:01
-
-
Save olleolleolle/312770 to your computer and use it in GitHub Desktop.
Avoiding redeclaring variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/editor.js | |
| =================================================================== | |
| --- /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/editor.js (revision 8426) | |
| +++ /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/editor.js (working copy) | |
| @@ -130,7 +130,7 @@ | |
| setTimeout("editor.showLoadErrors()", 500); | |
| this.registerRecorder(); | |
| -} | |
| +}; | |
| Editor.checkTimestamp = function() { | |
| editor.log.debug('checkTimestamp'); | |
| @@ -417,7 +417,7 @@ | |
| Editor.prototype.getPathAndUpdateBaseURL = function(window) { | |
| if (!window || !window.location) return [null, null]; | |
| var path = window.location.href; | |
| - var regexp = new RegExp(/^(https?:\/\/[^/:]+(:\d+)?)\/.*/); | |
| + var regexp = new RegExp("/^(https?:\/\/[^/:]+(:\d+)?)\/.*/"); | |
| var base = ''; | |
| var result = regexp.exec(path); | |
| if (result && "true" != this.getOptions().recordAbsoluteURL) { | |
| @@ -535,7 +535,7 @@ | |
| //resultBox.inputField.scrollTop = resultBox.inputField.scrollHeight - resultBox.inputField.clientHeight; | |
| this.clearLastCommand(); | |
| this.lastWindow = window; | |
| - var command = new Command(command, target, value); | |
| + command = new Command(command, target, value); | |
| // bind to the href attribute instead of to window.document.location, which | |
| // is an object reference | |
| command.lastURL = window.document.location.href; | |
| @@ -899,7 +899,10 @@ | |
| } | |
| Editor.prototype.getAutoCompleteSearchParam = function(id) { | |
| - var textbox = document.getElementById(id); | |
| + var textbox; | |
| + if (id) { | |
| + textbox = document.getElementById(id); | |
| + } | |
| if (!this.autoCompleteSearchParams) | |
| this.autoCompleteSearchParams = {}; | |
| if (this.autoCompleteSearchParams[id]) { | |
| @@ -910,7 +913,9 @@ | |
| param += Math.floor(Math.random()*36).toString(36); | |
| } | |
| this.autoCompleteSearchParams[id] = param; | |
| - textbox.searchParam = param; | |
| + if (textbox) { | |
| + textbox.searchParam = param; | |
| + } | |
| return param; | |
| } | |
| } | |
| @@ -928,7 +933,7 @@ | |
| } | |
| Editor.prototype.getInterval = function() { | |
| - return parseInt(document.getElementById("speedSlider").getAttribute("curpos")); | |
| + return parseInt(document.getElementById("speedSlider").getAttribute("curpos"), 10); | |
| } | |
| Editor.prototype.initMenus = function() { | |
| @@ -1036,11 +1041,12 @@ | |
| + uiElement.description.escapeHTML2().formatAsHTML() + '</div>' | |
| + '<dl class="target-arg-list">'; | |
| // arguments | |
| + var defaultValuesDisplay; | |
| for (i = 0; i < uiElement.args.length; ++i) { | |
| var arg = uiElement.args[i]; | |
| try { | |
| var defaultValues = arg.getDefaultValues(); | |
| - var defaultValuesDisplay = defaultValues.slice(0, 5).join(', ') | |
| + defaultValuesDisplay = defaultValues.slice(0, 5).join(', ') | |
| .escapeHTML2(); | |
| var defaultValuesHide = defaultValues.slice(5).join(', '); | |
| if (defaultValues.length > 5) { | |
| @@ -1050,7 +1056,7 @@ | |
| defaultValuesDisplay = '[ ' + defaultValuesDisplay + ' ]'; | |
| } | |
| catch (e) { | |
| - var defaultValuesDisplay = 'default values dynamically constructed'; | |
| + defaultValuesDisplay = 'default values dynamically constructed'; | |
| } | |
| html += '<dt class="target-arg-name">' | |
| + arg.name.escapeHTML2() + '</dt><dd class="target-arg-description">' | |
| @@ -1274,7 +1280,7 @@ | |
| Editor.LogView.prototype.onAppendEntry = function(entry) { | |
| var levels = { debug: 0, info: 1, warn: 2, error: 3 }; | |
| var entryValue = levels[entry.level]; | |
| - var filterValue = parseInt(this.filterValue); | |
| + var filterValue = parseInt(this.filterValue, 10); | |
| if (filterValue <= entryValue) { | |
| if (!this.isHidden()) { | |
| var newEntry = this.view.contentDocument.createElement('li'); | |
| Index: /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/selenium/scripts/selenium-testrunner-original.js | |
| =================================================================== | |
| --- /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/selenium/scripts/selenium-testrunner-original.js (revision 8426) | |
| +++ /Users/olle/opensource/js/selenium-read-only/ide/src/extension/content/selenium/scripts/selenium-testrunner-original.js (working copy) | |
| @@ -105,7 +105,7 @@ | |
| var testCaseLoaded = fnBind(function(){this.testCaseLoaded=true;},this); | |
| var testNumber = 0; | |
| if (this.controlPanel.getTestNumber() != null){ | |
| - var testNumber = this.controlPanel.getTestNumber() - 1; | |
| + testNumber = this.controlPanel.getTestNumber() - 1; | |
| } | |
| this.getTestSuite().getSuiteRows()[testNumber].loadTestCase(testCaseLoaded); | |
| } | |
| @@ -634,8 +634,9 @@ | |
| var tables = sel$A(this.suiteDocument.getElementsByTagName("table")); | |
| var testTable = tables[0]; | |
| if (!testTable) return; | |
| + var rowElement; | |
| for (rowNum = 1; rowNum < testTable.rows.length; rowNum++) { | |
| - var rowElement = testTable.rows[rowNum]; | |
| + rowElement = testTable.rows[rowNum]; | |
| result.push(new HtmlTestSuiteRow(rowElement, testFrame, this)); | |
| } | |
| @@ -643,7 +644,7 @@ | |
| for (var tableNum = 1; tableNum < sel$A(this.suiteDocument.getElementsByTagName("table")).length; tableNum++) { | |
| testTable = tables[tableNum]; | |
| for (rowNum = 1; rowNum < testTable.rows.length; rowNum++) { | |
| - var rowElement = testTable.rows[rowNum]; | |
| + rowElement = testTable.rows[rowNum]; | |
| new HtmlTestSuiteRow(rowElement, testFrame, this); | |
| } | |
| } | |
| @@ -658,7 +659,7 @@ | |
| }, | |
| unselectCurrentRow: function() { | |
| - var currentRow = this.getCurrentRow() | |
| + var currentRow = this.getCurrentRow(); | |
| if (currentRow) { | |
| currentRow.unselect(); | |
| } | |
| @@ -676,7 +677,10 @@ | |
| }, | |
| _startCurrentTestCase: function() { | |
| - this.getCurrentRow().loadTestCase(fnBind(htmlTestRunner.startTest, htmlTestRunner)); | |
| + var currentRow = this.getCurrentRow(); | |
| + if (currentRow) { | |
| + currentRow.loadTestCase(fnBind(htmlTestRunner.startTest, htmlTestRunner)); | |
| + } | |
| }, | |
| _onTestSuiteComplete: function() { | |
| @@ -686,7 +690,10 @@ | |
| updateSuiteWithResultOfPreviousTest: function() { | |
| if (this.currentRowInSuite >= 0) { | |
| - this.getCurrentRow().saveTestResults(); | |
| + var currentRow = this.getCurrentRow(); | |
| + if (currentRow) { | |
| + currentRow.saveTestResults(); | |
| + } | |
| } | |
| }, | |
| @@ -1300,7 +1307,7 @@ | |
| * try to read API doc from the function definitions here. | |
| */ | |
| Selenium.prototype._doSetSpeed = function(value) { | |
| - var milliseconds = parseInt(value); | |
| + var milliseconds = parseInt(value, 10); | |
| if (milliseconds < 0) milliseconds = 0; | |
| htmlTestRunner.controlPanel.speedController.setValue(milliseconds); | |
| htmlTestRunner.controlPanel.setRunInterval(milliseconds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment