Bug 1451659 - Automated ESLint fixes for devtools/client/shadereditor/. r=jdescottes

MozReview-Commit-ID: FsfexjcuSfZ

--HG--
extra : rebase_source : 026d20487326657c8042de10ea9d01aaa48fc3db
This commit is contained in:
Mark Banner 2018-04-05 08:14:04 +01:00
parent 34a483b76d
commit 72de2a4acf
15 changed files with 65 additions and 67 deletions

View file

@ -28,7 +28,7 @@ ShaderEditorPanel.prototype = {
* @return object
* A promise that is resolved when the Shader Editor completes opening.
*/
open: function () {
open: function() {
let targetPromise;
// Local debugging needs to make the target remote.
@ -61,7 +61,7 @@ ShaderEditorPanel.prototype = {
return this._toolbox.target;
},
destroy: function () {
destroy: function() {
// Make sure this panel is not already destroyed.
if (this._destroyer) {
return this._destroyer;

View file

@ -88,7 +88,7 @@ var EventsHandler = {
/**
* Listen for events emitted by the current tab target.
*/
initialize: function () {
initialize: function() {
this._onHostChanged = this._onHostChanged.bind(this);
this._onTabNavigated = this._onTabNavigated.bind(this);
this._onTabWillNavigate = this._onTabWillNavigate.bind(this);
@ -105,7 +105,7 @@ var EventsHandler = {
/**
* Remove events emitted by the current tab target.
*/
destroy: function () {
destroy: function() {
gToolbox.off("host-changed", this._onHostChanged);
gTarget.off("will-navigate", this._onTabWillNavigate);
gTarget.off("navigate", this._onTabNavigated);
@ -123,7 +123,7 @@ var EventsHandler = {
/**
* Handles a host change event on the parent toolbox.
*/
_onHostChanged: function () {
_onHostChanged: function() {
if (gToolbox.hostType == "side") {
$("#shaders-pane").removeAttribute("height");
}
@ -154,7 +154,7 @@ var EventsHandler = {
/**
* Called for each location change in the debugged tab.
*/
_onTabNavigated: function () {
_onTabNavigated: function() {
// Manually retrieve the list of program actors known to the server,
// because the backend won't emit "program-linked" notifications
// in the case of a bfcache navigation (since no new programs are
@ -165,7 +165,7 @@ var EventsHandler = {
/**
* Called every time a program was linked in the debugged tab.
*/
_onProgramLinked: function (programActor) {
_onProgramLinked: function(programActor) {
this._addProgram(programActor);
window.emit(EVENTS.NEW_PROGRAM);
},
@ -173,7 +173,7 @@ var EventsHandler = {
/**
* Callback for the front's getPrograms() method.
*/
_onProgramsAdded: function (programActors) {
_onProgramsAdded: function(programActors) {
programActors.forEach(this._addProgram);
window.emit(EVENTS.PROGRAMS_ADDED);
},
@ -181,7 +181,7 @@ var EventsHandler = {
/**
* Adds a program to the shaders list and unhides any modal notices.
*/
_addProgram: function (programActor) {
_addProgram: function(programActor) {
$("#waiting-notice").hidden = true;
$("#reload-notice").hidden = true;
$("#content").hidden = false;
@ -196,7 +196,7 @@ var ShadersListView = extend(WidgetMethods, {
/**
* Initialization function, called when the tool is started.
*/
initialize: function () {
initialize: function() {
this.widget = new SideMenuWidget(this._pane = $("#shaders-pane"), {
showArrows: true,
showItemCheckboxes: true
@ -216,7 +216,7 @@ var ShadersListView = extend(WidgetMethods, {
/**
* Destruction function, called when the tool is closed.
*/
destroy: function () {
destroy: function() {
this.widget.removeEventListener("select", this._onProgramSelect);
this.widget.removeEventListener("check", this._onProgramCheck);
this.widget.removeEventListener("mouseover", this._onProgramMouseOver, true);
@ -229,7 +229,7 @@ var ShadersListView = extend(WidgetMethods, {
* @param object programActor
* The program actor coming from the active thread.
*/
addProgram: function (programActor) {
addProgram: function(programActor) {
if (this.hasProgram(programActor)) {
return;
}
@ -276,14 +276,14 @@ var ShadersListView = extend(WidgetMethods, {
* @param boolean
* True if the program was added, false otherwise.
*/
hasProgram: function (programActor) {
hasProgram: function(programActor) {
return !!this.attachments.filter(e => e.programActor == programActor).length;
},
/**
* The select listener for the programs container.
*/
_onProgramSelect: function ({ detail: sourceItem }) {
_onProgramSelect: function({ detail: sourceItem }) {
if (!sourceItem) {
return;
}
@ -318,7 +318,7 @@ var ShadersListView = extend(WidgetMethods, {
/**
* The check listener for the programs container.
*/
_onProgramCheck: function ({ detail: { checked }, target }) {
_onProgramCheck: function({ detail: { checked }, target }) {
let sourceItem = this.getItemForElement(target);
let attachment = sourceItem.attachment;
attachment.isBlackBoxed = !checked;
@ -328,7 +328,7 @@ var ShadersListView = extend(WidgetMethods, {
/**
* The mouseover listener for the programs container.
*/
_onProgramMouseOver: function (e) {
_onProgramMouseOver: function(e) {
let sourceItem = this.getItemForElement(e.target, { noSiblings: true });
if (sourceItem && !sourceItem.attachment.isBlackBoxed) {
sourceItem.attachment.programActor.highlight(HIGHLIGHT_TINT);
@ -343,7 +343,7 @@ var ShadersListView = extend(WidgetMethods, {
/**
* The mouseout listener for the programs container.
*/
_onProgramMouseOut: function (e) {
_onProgramMouseOut: function(e) {
let sourceItem = this.getItemForElement(e.target, { noSiblings: true });
if (sourceItem && !sourceItem.attachment.isBlackBoxed) {
sourceItem.attachment.programActor.unhighlight();
@ -363,7 +363,7 @@ var ShadersEditorsView = {
/**
* Initialization function, called when the tool is started.
*/
initialize: function () {
initialize: function() {
XPCOMUtils.defineLazyGetter(this, "_editorPromises", () => new Map());
this._vsFocused = this._onFocused.bind(this, "vs", "fs");
this._fsFocused = this._onFocused.bind(this, "fs", "vs");
@ -393,14 +393,14 @@ var ShadersEditorsView = {
* @return object
* A promise resolving upon completion of text setting.
*/
setText: function (sources) {
setText: function(sources) {
let view = this;
function setTextAndClearHistory(editor, text) {
editor.setText(text);
editor.clearHistory();
}
return (async function () {
return (async function() {
await view._toggleListeners("off");
await promise.all([
view._getEditor("vs").then(e => setTextAndClearHistory(e, sources.vs)),
@ -419,7 +419,7 @@ var ShadersEditorsView = {
* @return object
* Returns a promise that resolves to an editor instance
*/
_getEditor: function (type) {
_getEditor: function(type) {
if (this._editorPromises.has(type)) {
return this._editorPromises.get(type);
}
@ -450,7 +450,7 @@ var ShadersEditorsView = {
* @return object
* A promise resolving upon completion of toggling the listeners.
*/
_toggleListeners: function (flag) {
_toggleListeners: function(flag) {
return promise.all(["vs", "fs"].map(type => {
return this._getEditor(type).then(editor => {
editor[flag]("focus", this["_" + type + "Focused"]);
@ -467,7 +467,7 @@ var ShadersEditorsView = {
* @param string focused
* The corresponding shader type for the other editor (e.g. "fs").
*/
_onFocused: function (focused, unfocused) {
_onFocused: function(focused, unfocused) {
$("#" + focused + "-editor-label").setAttribute("selected", "");
$("#" + unfocused + "-editor-label").removeAttribute("selected");
},
@ -478,7 +478,7 @@ var ShadersEditorsView = {
* @param string type
* The corresponding shader type for the focused editor (e.g. "vs").
*/
_onChanged: function (type) {
_onChanged: function(type) {
setNamedTimeout("gl-typed", TYPING_MAX_DELAY, () => this._doCompile(type));
// Remove all the gutter markers and line classes from the editor.
@ -492,8 +492,8 @@ var ShadersEditorsView = {
* @param string type
* The corresponding shader type for the focused editor (e.g. "vs").
*/
_doCompile: function (type) {
(async function () {
_doCompile: function(type) {
(async function() {
let editor = await this._getEditor(type);
let shaderActor = await ShadersListView.selectedAttachment[type];
@ -509,7 +509,7 @@ var ShadersEditorsView = {
/**
* Called uppon a successful shader compilation.
*/
_onSuccessfulCompilation: function () {
_onSuccessfulCompilation: function() {
// Signal that the shader was compiled successfully.
window.emit(EVENTS.SHADER_COMPILED, null);
},
@ -517,7 +517,7 @@ var ShadersEditorsView = {
/**
* Called uppon an unsuccessful shader compilation.
*/
_onFailedCompilation: function (type, editor, errors) {
_onFailedCompilation: function(type, editor, errors) {
let lineCount = editor.lineCount();
let currentLine = editor.getCursor().line;
let listeners = { mouseover: this._onMarkerMouseOver };
@ -557,10 +557,9 @@ var ShadersEditorsView = {
line: current.line,
messages: [current.text]
}];
} else {
previous.messages.push(current.text);
return accumulator;
}
previous.messages.push(current.text);
return accumulator;
}
function displayErrors({ line, messages }) {
// Add gutter markers and line classes for every error in the source.
@ -585,7 +584,7 @@ var ShadersEditorsView = {
/**
* Event listener for the 'mouseover' event on a marker in the editor gutter.
*/
_onMarkerMouseOver: function (line, node, messages) {
_onMarkerMouseOver: function(line, node, messages) {
if (node._markerErrorsTooltip) {
return;
}
@ -601,7 +600,7 @@ var ShadersEditorsView = {
/**
* Removes all the gutter markers and line classes from the editor.
*/
_cleanEditor: function (type) {
_cleanEditor: function(type) {
this._getEditor(type).then(editor => {
editor.removeAllMarkers("errors");
this._errors[type].forEach(e => editor.removeLineClass(e.line));

View file

@ -19,7 +19,6 @@ async function ifWebGLSupported() {
let vsEditor = await ShadersEditorsView._getEditor("vs");
let fsEditor = await ShadersEditorsView._getEditor("fs");
is(vsEditor.getText().indexOf("gl_Position"), 170,
"The vertex shader editor contains the correct text.");
is(fsEditor.getText().indexOf("gl_FragColor"), 97,

View file

@ -23,10 +23,12 @@ async function ifWebGLSupported() {
getPrograms(gFront, 2, (actors) => {
// Fired upon each actor addition, we want to check only
// after the first actor has been added so we can test state
if (actors.length === 1)
if (actors.length === 1) {
checkFirstProgram();
if (actors.length === 2)
}
if (actors.length === 2) {
checkSecondProgram();
}
}),
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
]).then(([programs, ]) => programs);

View file

@ -19,7 +19,6 @@ async function ifWebGLSupported() {
let vsEditor = await ShadersEditorsView._getEditor("vs");
let fsEditor = await ShadersEditorsView._getEditor("fs");
vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 });
let error = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
@ -40,7 +39,6 @@ async function ifWebGLSupported() {
ok(infoLog.includes("ERROR: 0:8: 'assign'"),
"An assignment error is contained in the info log.");
fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 });
error = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
@ -56,7 +54,6 @@ async function ifWebGLSupported() {
ok(infoLog.includes("ERROR: 0:6: 'constructor'"),
"A constructor error is contained in the info log.");
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
await ensurePixelIs(gFront, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);

View file

@ -44,7 +44,7 @@ async function ifWebGLSupported() {
ok(true, "The corner pixel colors are correct after unblackboxing.");
function checkShaderSource(aMessage) {
return (async function () {
return (async function() {
let newVertexShader = await programActor.getVertexShader();
let newFragmentShader = await programActor.getFragmentShader();
is(vertexShader, newVertexShader,

View file

@ -25,7 +25,7 @@ async function ifWebGLSupported() {
finish();
function testHighlighting(programActor) {
return (async function () {
return (async function() {
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
ok(true, "The corner pixel colors are correct before highlighting.");

View file

@ -53,7 +53,7 @@ async function ifWebGLSupported() {
finish();
function checkFirstCachedPrograms(programActor) {
return (async function () {
return (async function() {
let programs = await front.getPrograms();
is(programs.length, 1,
@ -64,7 +64,7 @@ async function ifWebGLSupported() {
}
function checkSecondCachedPrograms(oldProgramActor, newProgramActors) {
return (async function () {
return (async function() {
let programs = await front.getPrograms();
is(programs.length, 2,
@ -82,7 +82,7 @@ async function ifWebGLSupported() {
}
function checkHighlightingInTheFirstPage(programActor) {
return (async function () {
return (async function() {
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
ok(true, "The corner pixel colors are correct before highlighting.");
@ -100,7 +100,7 @@ async function ifWebGLSupported() {
}
function checkHighlightingInTheSecondPage(firstProgramActor, secondProgramActor) {
return (async function () {
return (async function() {
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");

View file

@ -90,7 +90,7 @@ async function ifWebGLSupported() {
finish();
function checkHighlightingInTheFirstPage(programActor) {
return (async function () {
return (async function() {
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
ok(true, "The corner pixel colors are correct before highlighting.");
@ -108,7 +108,7 @@ async function ifWebGLSupported() {
}
function checkHighlightingInTheSecondPage(firstProgramActor, secondProgramActor) {
return (async function () {
return (async function() {
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");

View file

@ -55,7 +55,7 @@
initProgram(1);
initBuffers();
drawScene();
}
};
function initProgram(i) {
let vertexShader = getShader("shader-vs");
@ -94,9 +94,9 @@
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
-1.0, -1.0, 0.0
]), gl.STATIC_DRAW);
}
@ -119,8 +119,7 @@
function blend(i) {
if (i == 0) {
gl.disable(gl.BLEND);
}
else if (i == 1) {
} else if (i == 1) {
gl.enable(gl.BLEND);
gl.blendColor(0.5, 0, 0, 0.25);
gl.blendEquationSeparate(

View file

@ -49,7 +49,7 @@
initBuffers(i);
drawScene(i);
}
}
};
function initProgram(i) {
let vertexShader = getShader(gl[i], "shader-vs");
@ -88,9 +88,9 @@
gl[i].bindBuffer(gl[i].ARRAY_BUFFER, squareVerticesPositionBuffer[i]);
gl[i].bufferData(gl[i].ARRAY_BUFFER, new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
-1.0, -1.0, 0.0
]), gl[i].STATIC_DRAW);
}

View file

@ -55,7 +55,7 @@
initProgram(1);
initBuffers();
drawScene();
}
};
function initProgram(i) {
let vertexShader = getShader("shader-vs");
@ -94,9 +94,9 @@
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
-1.0, -1.0, 0.0
]), gl.STATIC_DRAW);
}

View file

@ -59,7 +59,7 @@
}
gl.linkProgram(shaderProgram);
}
};
function getShader(gl, id) {
let script = document.getElementById(id);

View file

@ -50,7 +50,7 @@
initProgram();
initBuffers();
drawScene();
}
};
function initProgram() {
let vertexShader = getShader(gl, "shader-vs");
@ -90,9 +90,9 @@
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
1.0, -1.0, 0.0,
-1.0, -1.0, 0.0
-1.0, -1.0, 0.0
]), gl.STATIC_DRAW);
squareVerticesColorBuffer = gl.createBuffer();

View file

@ -72,7 +72,7 @@ async function test() {
let generator = isWebGLSupported(document) ? ifWebGLSupported : ifWebGLUnsupported;
try {
await generator();
} catch(e) {
} catch (e) {
handlError(e);
}
}
@ -106,7 +106,7 @@ function isApproxColor(aFirst, aSecond, aMargin) {
}
function ensurePixelIs(aFront, aPosition, aColor, aWaitFlag = false, aSelector = "canvas") {
return (async function () {
return (async function() {
let pixel = await aFront.getPixel({ selector: aSelector, position: aPosition });
if (isApproxColor(pixel, aColor)) {
ok(true, "Expected pixel is shown at: " + aPosition.toSource());
@ -149,7 +149,7 @@ function initBackend(aUrl) {
DebuggerServer.init();
DebuggerServer.registerAllActors();
return (async function () {
return (async function() {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
@ -163,7 +163,7 @@ function initBackend(aUrl) {
function initShaderEditor(aUrl) {
info("Initializing a shader editor pane.");
return (async function () {
return (async function() {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
@ -199,7 +199,9 @@ function getPrograms(front, count, onAdd) {
front.on("program-linked", function onLink(actor) {
if (actors.length !== count) {
actors.push(actor);
if (typeof onAdd === "function") onAdd(actors);
if (typeof onAdd === "function") {
onAdd(actors);
}
}
if (actors.length === count) {
front.off("program-linked", onLink);