forked from mirrors/gecko-dev
		
	Bug 1614822 - Enable ESLint for testing/mochitest/tests/Harness_sanity/. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D62512 --HG-- extra : moz-landing-system : lando
This commit is contained in:
		
							parent
							
								
									8dc9ea96b7
								
							
						
					
					
						commit
						556504ff93
					
				
					 17 changed files with 55 additions and 40 deletions
				
			
		|  | @ -175,9 +175,6 @@ services/fxaccounts/FxAccountsPairingChannel.js | |||
| # Servo is imported. | ||||
| servo/ | ||||
| 
 | ||||
| # third party modules | ||||
| testing/mochitest/tests/Harness_sanity/ | ||||
| 
 | ||||
| # Test files that we don't want to lint (preprocessed, minified etc) | ||||
| testing/marionette/atom.js | ||||
| testing/mozbase/mozprofile/tests/files/prefs_with_comments.js | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ const mochitestTestPaths = [ | |||
|   "**/test/mochitest/", | ||||
|   "**/tests/mochitest/", | ||||
|   "testing/mochitest/tests/SimpleTest/", | ||||
|   "testing/mochitest/tests/Harness_sanity/", | ||||
| ]; | ||||
| 
 | ||||
| const chromeTestPaths = [ | ||||
|  |  | |||
|  | @ -1,10 +1,13 @@ | |||
| /* eslint-env mozilla/frame-script */ | ||||
| /* global assert */ | ||||
| 
 | ||||
| // Just receive 'foo' message and forward it back
 | ||||
| // as 'bar' message
 | ||||
| addMessageListener("foo", function (message) { | ||||
| addMessageListener("foo", function(message) { | ||||
|   sendAsyncMessage("bar", message); | ||||
| }); | ||||
| 
 | ||||
| addMessageListener("valid-assert", function (message) { | ||||
| addMessageListener("valid-assert", function(message) { | ||||
|   assert.ok(true, "valid assertion"); | ||||
|   assert.equal(1, 1, "another valid assertion"); | ||||
|   sendAsyncMessage("valid-assert-done"); | ||||
|  |  | |||
|  | @ -1,3 +1,5 @@ | |||
| addMessageListener("ImportTesting:IsModuleLoaded", function (msg) { | ||||
| /* eslint-env mozilla/frame-script */ | ||||
| 
 | ||||
| addMessageListener("ImportTesting:IsModuleLoaded", function(msg) { | ||||
|   sendAsyncMessage("ImportTesting:IsModuleLoadedReply", Cu.isModuleLoaded(msg)); | ||||
| }); | ||||
|  |  | |||
|  | @ -1,13 +1,15 @@ | |||
| const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||||
| /* eslint-env mozilla/frame-script */ | ||||
| 
 | ||||
| const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||||
| 
 | ||||
| var permChangedObs = { | ||||
|   observe: function(subject, topic, data) { | ||||
|     if (topic == 'perm-changed') { | ||||
|   observe(subject, topic, data) { | ||||
|     if (topic == "perm-changed") { | ||||
|       var permission = subject.QueryInterface(Ci.nsIPermission); | ||||
|       var msg = { op: data, type: permission.type }; | ||||
|       sendAsyncMessage('perm-changed', msg); | ||||
|     } | ||||
|       sendAsyncMessage("perm-changed", msg); | ||||
|     } | ||||
|   }, | ||||
| }; | ||||
| 
 | ||||
| Services.obs.addObserver(permChangedObs, 'perm-changed'); | ||||
| Services.obs.addObserver(permChangedObs, "perm-changed"); | ||||
|  |  | |||
|  | @ -54,6 +54,7 @@ async function starttest(){ | |||
| 
 | ||||
|   // Test an invalid pref | ||||
|   var retVal = null; | ||||
|   // eslint-disable-next-line mozilla/use-default-preference-values | ||||
|   try { | ||||
|     retVal = SpecialPowers.getBoolPref('extensions.checkCompat0123456789'); | ||||
|   } catch (ex) { | ||||
|  |  | |||
|  | @ -9,6 +9,9 @@ | |||
| 
 | ||||
| <pre id="test"> | ||||
| <script class="testbody" type="text/javascript"> | ||||
| /* eslint-env mozilla/frame-script */ | ||||
| /* global assert */ | ||||
| 
 | ||||
| SimpleTest.waitForExplicitFinish(); | ||||
| 
 | ||||
| var url = SimpleTest.getTestFileURL("SpecialPowersLoadChromeScript.js"); | ||||
|  |  | |||
|  | @ -9,6 +9,9 @@ | |||
| 
 | ||||
| <pre id="test"> | ||||
| <script class="testbody" type="text/javascript"> | ||||
| /* eslint-env mozilla/frame-script */ | ||||
| /* global assert */ | ||||
| 
 | ||||
| SimpleTest.waitForExplicitFinish(); | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ | |||
| 
 | ||||
| SimpleTest.waitForExplicitFinish(); | ||||
| 
 | ||||
| /* eslint-disable mozilla/use-services */ | ||||
| function loadPrivilegedScriptTest() { | ||||
|   function isMainProcess() { | ||||
|     return Cc["@mozilla.org/xre/app-info;1"]. | ||||
|  | @ -29,7 +30,7 @@ try { | |||
|   ok(false, "loadPrivilegedScript shoulde not throw"); | ||||
| } | ||||
| port.onmessage = (e) => { | ||||
|   is(contentProcessType, e.data['isMainProcess'], "content and the script should be in the same process"); | ||||
|   is(contentProcessType, e.data.isMainProcess, "content and the script should be in the same process"); | ||||
|   SimpleTest.finish(); | ||||
| }; | ||||
| </script> | ||||
|  |  | |||
|  | @ -71,15 +71,15 @@ add_task(async function() { | |||
|     }, | ||||
|     "SpecialPowers.spawn-subframe": () => { | ||||
|       return SpecialPowers.spawn(frame, [subframeSrc], async src => { | ||||
|         let frame = this.content.document.createElement("iframe"); | ||||
|         frame.src = src; | ||||
|         this.content.document.body.appendChild(frame); | ||||
|         let subFrame = this.content.document.createElement("iframe"); | ||||
|         subFrame.src = src; | ||||
|         this.content.document.body.appendChild(subFrame); | ||||
| 
 | ||||
|         await new Promise(resolve => { | ||||
|           frame.addEventListener("load", resolve, { once: true }); | ||||
|           subFrame.addEventListener("load", resolve, { once: true }); | ||||
|         }); | ||||
| 
 | ||||
|         await SpecialPowers.spawn(frame, [], () => { | ||||
|         await SpecialPowers.spawn(subFrame, [], () => { | ||||
|           Assert.equal(1, 2, "Thing"); | ||||
|           Assert.equal(1, 1, "Hmm"); | ||||
|           Assert.ok(true, "Yay."); | ||||
|  |  | |||
|  | @ -30,6 +30,7 @@ | |||
| 
 | ||||
|     is(result, "Hello there.", "Got correct element text from frame"); | ||||
| 
 | ||||
|     /* eslint-disable no-shadow */ | ||||
|     result = await SpecialPowers.spawn(frame, ["#hello"], selector => { | ||||
|       return SpecialPowers.spawn(content.parent, [selector], selector => { | ||||
|         let elem = content.document.querySelector(selector); | ||||
|  | @ -54,7 +55,7 @@ | |||
| 
 | ||||
|     is(result, "Hello there.", "Got correct element text from browsing context"); | ||||
| 
 | ||||
|     let line = 58; // Keep this in sync with the line number where the callback function starts. | ||||
|     let line = 59; // Keep this in sync with the line number where the callback function starts. | ||||
|     let callback = () => { | ||||
|       let e = new Error("Hello."); | ||||
|       return { filename: e.fileName, lineNumber: e.lineNumber }; | ||||
|  |  | |||
|  | @ -150,13 +150,13 @@ function starttest() { | |||
|                         { arg: "~", code: "Backquote", keyCode: KeyboardEvent.DOM_VK_BACK_QUOTE }, | ||||
|                         { arg: "<", code: "Comma", keyCode: KeyboardEvent.DOM_VK_COMMA }, | ||||
|                         { arg: ".", code: "Period", keyCode: KeyboardEvent.DOM_VK_PERIOD }]) { | ||||
|         let keydown, keyup; | ||||
|         let testKeydown, keyup; | ||||
|         $("testKeyEvent").focus(); | ||||
|         $("testKeyEvent").addEventListener("keydown", (e) => { keydown = e; }, {once: true}); | ||||
|         $("testKeyEvent").addEventListener("keydown", (e) => { testKeydown = e; }, {once: true}); | ||||
|         $("testKeyEvent").addEventListener("keyup", (e) => { keyup = e; }, {once: true}); | ||||
|         synthesizeKey(test.arg); | ||||
|         is(keydown.code, test.code, `Synthesizing "${test.arg}" should set code value of "keydown" to "${test.code}"`); | ||||
|         is(keydown.keyCode, test.keyCode, `Synthesizing "${test.arg}" should set keyCode value of "keydown" to "${test.keyCode}"`); | ||||
|         is(testKeydown.code, test.code, `Synthesizing "${test.arg}" should set code value of "keydown" to "${test.code}"`); | ||||
|         is(testKeydown.keyCode, test.keyCode, `Synthesizing "${test.arg}" should set keyCode value of "keydown" to "${test.keyCode}"`); | ||||
|         is(keyup.code, test.code, `Synthesizing "${test.arg}" key should set code value of "keyup" to "${test.code}"`); | ||||
|         is(keyup.keyCode, test.keyCode, `Synthesizing "${test.arg}" key should set keyCode value of "keyup" to "${test.keyCode}"`); | ||||
|         $("testKeyEvent").value = ""; | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| <script> | ||||
| ok(true, "a call to ok"); | ||||
| SimpleTest.expectUncaughtException(); | ||||
| // eslint-disable-next-line no-throw-literal | ||||
| throw "an uncaught exception"; | ||||
| </script> | ||||
| </body> | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ SimpleTest.waitForExplicitFinish(); | |||
| ok(true, "a call to ok"); | ||||
| SimpleTest.executeSoon(function() { | ||||
|   SimpleTest.expectUncaughtException(); | ||||
|   // eslint-disable-next-line no-throw-literal | ||||
|   throw "an uncaught exception"; | ||||
| }); | ||||
| SimpleTest.executeSoon(function() { | ||||
|  |  | |||
|  | @ -84,6 +84,7 @@ function starttest() { | |||
|             //expect and throw exception here. Otherwise, any code that follows the throw call will never be executed | ||||
|             SimpleTest.expectUncaughtException(); | ||||
|             //make sure we catch this error | ||||
|             // eslint-disable-next-line no-throw-literal | ||||
|             throw "i am an uncaught exception" | ||||
|           } | ||||
|         ); | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ | |||
| </head> | ||||
| <body> | ||||
| <script class="testbody" type="text/javascript"> | ||||
| for (pref of [1, 2]) { | ||||
| for (const pref of [1, 2]) { | ||||
|   try { | ||||
|     SpecialPowers.getBoolPref("simpletest.cleanup." + pref); | ||||
|     ok(false, "Cleanup function should have unset pref"); | ||||
|  |  | |||
|  | @ -14,13 +14,11 @@ var capturedFailures = []; | |||
| window.ok = function (cond, name) { | ||||
|   if (!captureFailure) { | ||||
|     SimpleTest.ok(cond, name); | ||||
|   } else { | ||||
|     if (cond) { | ||||
|   } else if (cond) { | ||||
|       SimpleTest.ok(false, `Expect a failure with "${name}"`); | ||||
|     } else { | ||||
|       capturedFailures.push(name); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| SimpleTest.waitForExplicitFinish(); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Mark Banner
						Mark Banner