--- a/devtools/client/shadereditor/panel.js
+++ b/devtools/client/shadereditor/panel.js
@@ -23,17 +23,17 @@ exports.ShaderEditorPanel = ShaderEditor
ShaderEditorPanel.prototype = {
/**
* Open is effectively an asynchronous constructor.
*
* @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.
if (!this.target.isRemote) {
targetPromise = this.target.makeRemote();
} else {
targetPromise = promise.resolve(this.target);
}
@@ -56,17 +56,17 @@ ShaderEditorPanel.prototype = {
},
// DevToolPanel API
get target() {
return this._toolbox.target;
},
- destroy: function () {
+ destroy: function() {
// Make sure this panel is not already destroyed.
if (this._destroyer) {
return this._destroyer;
}
return this._destroyer = this.panelWin.shutdownShaderEditor().then(() => {
// Destroy front to ensure packet handler is removed from client
this.panelWin.gFront.destroy();
--- a/devtools/client/shadereditor/shadereditor.js
+++ b/devtools/client/shadereditor/shadereditor.js
@@ -83,34 +83,34 @@ function shutdownShaderEditor() {
/**
* Functions handling target-related lifetime events.
*/
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);
this._onProgramLinked = this._onProgramLinked.bind(this);
this._onProgramsAdded = this._onProgramsAdded.bind(this);
gToolbox.on("host-changed", this._onHostChanged);
gTarget.on("will-navigate", this._onTabWillNavigate);
gTarget.on("navigate", this._onTabNavigated);
gFront.on("program-linked", this._onProgramLinked);
this.reloadButton = $("#requests-menu-reload-notice-button");
this.reloadButton.addEventListener("command", this._onReloadCommand);
},
/**
* 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);
gFront.off("program-linked", this._onProgramLinked);
this.reloadButton.removeEventListener("command", this._onReloadCommand);
},
/**
@@ -118,17 +118,17 @@ var EventsHandler = {
*/
_onReloadCommand() {
gFront.setup({ reload: true });
},
/**
* Handles a host change event on the parent toolbox.
*/
- _onHostChanged: function () {
+ _onHostChanged: function() {
if (gToolbox.hostType == "side") {
$("#shaders-pane").removeAttribute("height");
}
},
_onTabWillNavigate: function({isFrameSwitching}) {
// Make sure the backend is prepared to handle WebGL contexts.
if (!isFrameSwitching) {
@@ -149,59 +149,59 @@ var EventsHandler = {
$("#content").hidden = true;
window.emit(EVENTS.UI_RESET);
},
/**
* 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
// actually linked).
gFront.getPrograms().then(this._onProgramsAdded);
},
/**
* 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);
},
/**
* Callback for the front's getPrograms() method.
*/
- _onProgramsAdded: function (programActors) {
+ _onProgramsAdded: function(programActors) {
programActors.forEach(this._addProgram);
window.emit(EVENTS.PROGRAMS_ADDED);
},
/**
* 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;
ShadersListView.addProgram(programActor);
}
};
/**
* Functions handling the sources UI.
*/
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
});
this._onProgramSelect = this._onProgramSelect.bind(this);
this._onProgramCheck = this._onProgramCheck.bind(this);
this._onProgramMouseOver = this._onProgramMouseOver.bind(this);
@@ -211,30 +211,30 @@ var ShadersListView = extend(WidgetMetho
this.widget.addEventListener("check", this._onProgramCheck);
this.widget.addEventListener("mouseover", this._onProgramMouseOver, true);
this.widget.addEventListener("mouseout", this._onProgramMouseOut, true);
},
/**
* 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);
this.widget.removeEventListener("mouseout", this._onProgramMouseOut, true);
},
/**
* Adds a program to this programs container.
*
* @param object programActor
* The program actor coming from the active thread.
*/
- addProgram: function (programActor) {
+ addProgram: function(programActor) {
if (this.hasProgram(programActor)) {
return;
}
// Currently, there's no good way of differentiating between programs
// in a way that helps humans. It will be a good idea to implement a
// standard of allowing debuggees to add some identifiable metadata to their
// program sources or instances.
@@ -271,24 +271,24 @@ var ShadersListView = extend(WidgetMetho
/**
* Returns whether a program was already added to this programs container.
*
* @param object programActor
* The program actor coming from the active thread.
* @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;
}
// The container is not empty and an actual item was selected.
let attachment = sourceItem.attachment;
function getShaders() {
return promise.all([
@@ -313,42 +313,42 @@ var ShadersListView = extend(WidgetMetho
.then(getSources)
.then(showSources)
.catch(console.error);
},
/**
* 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;
attachment.programActor[checked ? "unblackbox" : "blackbox"]();
},
/**
* 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);
if (e instanceof Event) {
e.preventDefault();
e.stopPropagation();
}
}
},
/**
* 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();
if (e instanceof Event) {
e.preventDefault();
e.stopPropagation();
}
@@ -358,17 +358,17 @@ var ShadersListView = extend(WidgetMetho
/**
* Functions handling the editors displaying the vertex and fragment shaders.
*/
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");
this._vsChanged = this._onChanged.bind(this, "vs");
this._fsChanged = this._onChanged.bind(this, "fs");
},
/**
@@ -388,24 +388,24 @@ var ShadersEditorsView = {
*
* @param object sources
* An object containing the following properties
* - vs: the vertex shader source code
* - fs: the fragment shader source code
* @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)),
view._getEditor("fs").then(e => setTextAndClearHistory(e, sources.fs))
]);
await view._toggleListeners("on");
})().then(() => window.emit(EVENTS.SOURCES_SHOWN, sources));
},
@@ -414,17 +414,17 @@ var ShadersEditorsView = {
* Lazily initializes and returns a promise for an Editor instance.
*
* @param string type
* Specifies for which shader type should an editor be retrieved,
* either are "vs" for a vertex, or "fs" for a fragment shader.
* @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);
}
let deferred = defer();
this._editorPromises.set(type, deferred.promise);
// Initialize the source editor and store the newly created instance
@@ -445,84 +445,84 @@ var ShadersEditorsView = {
/**
* Toggles all the event listeners for the editors either on or off.
*
* @param string flag
* Either "on" to enable the event listeners, "off" to disable them.
* @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"]);
editor[flag]("change", this["_" + type + "Changed"]);
});
}));
},
/**
* The focus listener for a source editor.
*
* @param string focused
* The corresponding shader type for the focused editor (e.g. "vs").
* @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");
},
/**
* The change listener for a source editor.
*
* @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.
this._cleanEditor(type);
},
/**
* Recompiles the source code for the shader being edited.
* This function is fired at a certain delay after the user stops typing.
*
* @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];
try {
await shaderActor.compile(editor.getText());
this._onSuccessfulCompilation();
} catch (e) {
this._onFailedCompilation(type, editor, e);
}
}.bind(this))();
},
/**
* Called uppon a successful shader compilation.
*/
- _onSuccessfulCompilation: function () {
+ _onSuccessfulCompilation: function() {
// Signal that the shader was compiled successfully.
window.emit(EVENTS.SHADER_COMPILED, null);
},
/**
* 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 };
function matchLinesAndMessages(string) {
return {
// First number that is not equal to 0.
lineMatch: string.match(/\d{2,}|[1-9]/),
@@ -552,20 +552,19 @@ var ShadersEditorsView = {
function groupSameLineMessages(accumulator, current) {
// Group errors corresponding to the same line number to a single object.
let previous = accumulator[accumulator.length - 1];
if (!previous || previous.line != current.line) {
return [...accumulator, {
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.
editor.addMarker(line, "errors", "error");
editor.setMarkerListeners(line, "errors", "error", listeners, messages);
editor.addLineClass(line, "error-line");
}
@@ -580,33 +579,33 @@ var ShadersEditorsView = {
// Signal that the shader wasn't compiled successfully.
window.emit(EVENTS.SHADER_COMPILED, errors);
},
/**
* 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;
}
let tooltip = node._markerErrorsTooltip = new Tooltip(document);
tooltip.defaultOffsetX = GUTTER_ERROR_PANEL_OFFSET_X;
tooltip.setTextContent({ messages: messages });
tooltip.startTogglingOnHover(node, () => true, {
toggleDelay: GUTTER_ERROR_PANEL_DELAY
});
},
/**
* 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));
this._errors[type].length = 0;
window.emit(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
});
},
--- a/devtools/client/shadereditor/test/browser_se_editors-contents.js
+++ b/devtools/client/shadereditor/test/browser_se_editors-contents.js
@@ -14,17 +14,16 @@ async function ifWebGLSupported() {
await promise.all([
once(gFront, "program-linked"),
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
]);
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,
"The fragment shader editor contains the correct text.");
await teardown(panel);
finish();
}
--- a/devtools/client/shadereditor/test/browser_se_programs-list.js
+++ b/devtools/client/shadereditor/test/browser_se_programs-list.js
@@ -18,20 +18,22 @@ async function ifWebGLSupported() {
"The shaders list has a negative index.");
reload(target);
let [firstProgramActor, secondProgramActor] = await promise.all([
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);
is(ShadersListView.attachments[0].label, L10N.getFormatStr("shadersList.programLabel", 0),
"The correct first label is shown in the shaders list.");
is(ShadersListView.attachments[1].label, L10N.getFormatStr("shadersList.programLabel", 1),
"The correct second label is shown in the shaders list.");
--- a/devtools/client/shadereditor/test/browser_se_shaders-edit-02.js
+++ b/devtools/client/shadereditor/test/browser_se_shaders-edit-02.js
@@ -14,17 +14,16 @@ async function ifWebGLSupported() {
await promise.all([
once(gFront, "program-linked"),
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
]);
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);
ok(error,
"The new vertex shader source was compiled with errors.");
// The implementation has the choice to defer all compile-time errors to link time.
let infoLog = (error.compile != "") ? error.compile : error.link;
@@ -35,33 +34,31 @@ async function ifWebGLSupported() {
"The info log status contains three errors.");
ok(infoLog.includes("ERROR: 0:8: 'constructor'"),
"A constructor error is contained in the info log.");
ok(infoLog.includes("ERROR: 0:8: '='"),
"A dimension error is contained in the info log.");
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);
ok(error,
"The new fragment shader source was compiled with errors.");
infoLog = (error.compile != "") ? error.compile : error.link;
isnot(infoLog, "",
"The one of the compile or link info logs should not be empty.");
is(infoLog.split("ERROR").length - 1, 1,
"The info log contains one error.");
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);
vsEditor.replaceText("vec4", { line: 7, ch: 22 }, { line: 7, ch: 26 });
error = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
ok(!error, "The new vertex shader source was compiled successfully.");
fsEditor.replaceText("vec3", { line: 2, ch: 14 }, { line: 2, ch: 18 });
--- a/devtools/client/shadereditor/test/browser_webgl-actor-test-06.js
+++ b/devtools/client/shadereditor/test/browser_webgl-actor-test-06.js
@@ -39,17 +39,17 @@ async function ifWebGLSupported() {
await programActor.unblackbox();
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);
await checkShaderSource("The shader sources are correct after unblackboxing.");
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,
"The same vertex shader actor was retrieved.");
is(fragmentShader, newFragmentShader,
"The same fragment shader actor was retrieved.");
let vertSource = await newVertexShader.getText();
--- a/devtools/client/shadereditor/test/browser_webgl-actor-test-10.js
+++ b/devtools/client/shadereditor/test/browser_webgl-actor-test-10.js
@@ -20,17 +20,17 @@ async function ifWebGLSupported() {
reload(target);
await testHighlighting((await once(front, "program-linked")));
ok(true, "Canvas was correctly instrumented on the third navigation.");
await removeTab(target.tab);
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.");
await programActor.highlight([0, 1, 0, 1]);
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, 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 after highlighting.");
--- a/devtools/client/shadereditor/test/browser_webgl-actor-test-15.js
+++ b/devtools/client/shadereditor/test/browser_webgl-actor-test-15.js
@@ -48,28 +48,28 @@ async function ifWebGLSupported() {
await checkSecondCachedPrograms(firstProgram, [secondProgram, thirdProgram]);
await checkHighlightingInTheSecondPage(secondProgram, thirdProgram);
ok(true, "The cached programs behave correctly after navigating forward again.");
await removeTab(target.tab);
finish();
function checkFirstCachedPrograms(programActor) {
- return (async function () {
+ return (async function() {
let programs = await front.getPrograms();
is(programs.length, 1,
"There should be 1 cached program actor.");
is(programs[0], programActor,
"The cached program actor was the expected one.");
})();
}
function checkSecondCachedPrograms(oldProgramActor, newProgramActors) {
- return (async function () {
+ return (async function() {
let programs = await front.getPrograms();
is(programs.length, 2,
"There should be 2 cached program actors after the navigation.");
is(programs[0], newProgramActors[0],
"The first cached program actor was the expected one after the navigation.");
is(programs[1], newProgramActors[1],
"The second cached program actor was the expected one after the navigation.");
@@ -77,17 +77,17 @@ async function ifWebGLSupported() {
isnot(newProgramActors[0], oldProgramActor,
"The old program actor is not equal to the new first program actor.");
isnot(newProgramActors[1], oldProgramActor,
"The old program actor is not equal to the new second program actor.");
})();
}
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.");
await programActor.highlight([0, 1, 0, 1]);
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, 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 after highlighting.");
@@ -95,17 +95,17 @@ async function ifWebGLSupported() {
await programActor.unhighlight();
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 after unhighlighting.");
})();
}
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");
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
ok(true, "The two canvases are correctly drawn before highlighting.");
await firstProgramActor.highlight([1, 0, 0, 1]);
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
--- a/devtools/client/shadereditor/test/browser_webgl-actor-test-16.js
+++ b/devtools/client/shadereditor/test/browser_webgl-actor-test-16.js
@@ -85,17 +85,17 @@ async function ifWebGLSupported() {
await checkHighlightingInTheSecondPage(programs[0], programs[1]);
ok(true, "The cached programs behave correctly after navigating forward and reloading.");
await removeTab(target.tab);
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.");
await programActor.highlight([0, 1, 0, 1]);
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, 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 after highlighting.");
@@ -103,17 +103,17 @@ async function ifWebGLSupported() {
await programActor.unhighlight();
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 after unhighlighting.");
})();
}
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");
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
ok(true, "The two canvases are correctly drawn before highlighting.");
await firstProgramActor.highlight([1, 0, 0, 1]);
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
--- a/devtools/client/shadereditor/test/doc_blended-geometry.html
+++ b/devtools/client/shadereditor/test/doc_blended-geometry.html
@@ -50,17 +50,17 @@
canvas = document.querySelector("canvas");
gl = canvas.getContext("webgl", { preserveDrawingBuffer: true });
gl.clearColor(0.0, 0.0, 0.0, 1.0);
initProgram(0);
initProgram(1);
initBuffers();
drawScene();
- }
+ };
function initProgram(i) {
let vertexShader = getShader("shader-vs");
let fragmentShader = getShader("shader-fs-" + i);
program[i] = gl.createProgram();
gl.attachShader(program[i], vertexShader);
gl.attachShader(program[i], fragmentShader);
@@ -89,19 +89,19 @@
return shader;
}
function initBuffers() {
squareVerticesPositionBuffer = gl.createBuffer();
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);
}
function drawScene() {
gl.clear(gl.COLOR_BUFFER_BIT);
for (let i = 0; i < 2; i++) {
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesPositionBuffer);
@@ -114,18 +114,17 @@
}
window.requestAnimationFrame(drawScene);
}
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(
gl.FUNC_REVERSE_SUBTRACT, gl.FUNC_SUBTRACT);
gl.blendFuncSeparate(
gl.CONSTANT_COLOR, gl.ONE_MINUS_CONSTANT_COLOR,
gl.ONE_MINUS_CONSTANT_COLOR, gl.CONSTANT_COLOR);
}
--- a/devtools/client/shadereditor/test/doc_multiple-contexts.html
+++ b/devtools/client/shadereditor/test/doc_multiple-contexts.html
@@ -44,17 +44,17 @@
canvas[i] = document.querySelector("#canvas" + (i + 1));
gl[i] = canvas[i].getContext("webgl", { preserveDrawingBuffer: true });
gl[i].clearColor(0.0, 0.0, 0.0, 1.0);
initProgram(i);
initBuffers(i);
drawScene(i);
}
- }
+ };
function initProgram(i) {
let vertexShader = getShader(gl[i], "shader-vs");
let fragmentShader = getShader(gl[i], "shader-fs");
program[i] = gl[i].createProgram();
gl[i].attachShader(program[i], vertexShader);
gl[i].attachShader(program[i], fragmentShader);
@@ -83,19 +83,19 @@
return shader;
}
function initBuffers(i) {
squareVerticesPositionBuffer[i] = gl[i].createBuffer();
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);
}
function drawScene(i) {
gl[i].clear(gl[i].COLOR_BUFFER_BIT);
gl[i].bindBuffer(gl[i].ARRAY_BUFFER, squareVerticesPositionBuffer[i]);
gl[i].vertexAttribPointer(vertexPositionAttribute[i], 3, gl[i].FLOAT, false, 0, 0);
--- a/devtools/client/shadereditor/test/doc_overlapping-geometry.html
+++ b/devtools/client/shadereditor/test/doc_overlapping-geometry.html
@@ -50,17 +50,17 @@
canvas = document.querySelector("canvas");
gl = canvas.getContext("webgl", { preserveDrawingBuffer: true });
gl.clearColor(0.0, 0.0, 0.0, 1.0);
initProgram(0);
initProgram(1);
initBuffers();
drawScene();
- }
+ };
function initProgram(i) {
let vertexShader = getShader("shader-vs");
let fragmentShader = getShader("shader-fs-" + i);
program[i] = gl.createProgram();
gl.attachShader(program[i], vertexShader);
gl.attachShader(program[i], fragmentShader);
@@ -89,19 +89,19 @@
return shader;
}
function initBuffers() {
squareVerticesPositionBuffer = gl.createBuffer();
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);
}
function drawScene() {
gl.clear(gl.COLOR_BUFFER_BIT);
for (let i = 0; i < 2; i++) {
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesPositionBuffer);
--- a/devtools/client/shadereditor/test/doc_shader-order.html
+++ b/devtools/client/shadereditor/test/doc_shader-order.html
@@ -54,17 +54,17 @@
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
} else {
gl.attachShader(shaderProgram, fragmentShader);
gl.attachShader(shaderProgram, vertexShader);
}
gl.linkProgram(shaderProgram);
- }
+ };
function getShader(gl, id) {
let script = document.getElementById(id);
let source = script.textContent;
let shader;
if (script.type == "x-shader/x-fragment") {
shader = gl.createShader(gl.FRAGMENT_SHADER);
--- a/devtools/client/shadereditor/test/doc_simple-canvas.html
+++ b/devtools/client/shadereditor/test/doc_simple-canvas.html
@@ -45,17 +45,17 @@
window.onload = function() {
canvas = document.querySelector("canvas");
gl = canvas.getContext("webgl", { preserveDrawingBuffer: true });
gl.clearColor(0.0, 0.0, 0.0, 1.0);
initProgram();
initBuffers();
drawScene();
- }
+ };
function initProgram() {
let vertexShader = getShader(gl, "shader-vs");
let fragmentShader = getShader(gl, "shader-fs");
program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
@@ -85,19 +85,19 @@
return shader;
}
function initBuffers() {
squareVerticesPositionBuffer = gl.createBuffer();
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();
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesColorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0, 1.0, 1.0, 1.0,
1.0, 0.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
--- a/devtools/client/shadereditor/test/head.js
+++ b/devtools/client/shadereditor/test/head.js
@@ -67,17 +67,17 @@ function ifWebGLUnsupported() {
todo(false, "Skipping test because WebGL isn't supported.");
finish();
}
async function test() {
let generator = isWebGLSupported(document) ? ifWebGLSupported : ifWebGLUnsupported;
try {
await generator();
- } catch(e) {
+ } catch (e) {
handlError(e);
}
}
function createCanvas() {
return document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
}
@@ -101,17 +101,17 @@ function isApprox(aFirst, aSecond, aMarg
function isApproxColor(aFirst, aSecond, aMargin) {
return isApprox(aFirst.r, aSecond.r, aMargin) &&
isApprox(aFirst.g, aSecond.g, aMargin) &&
isApprox(aFirst.b, aSecond.b, aMargin) &&
isApprox(aFirst.a, aSecond.a, 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());
return;
}
if (aWaitFlag) {
await aFront.waitForFrame();
@@ -144,31 +144,31 @@ function reload(aTarget, aWaitForTargetE
}
function initBackend(aUrl) {
info("Initializing a shader editor front.");
DebuggerServer.init();
DebuggerServer.registerAllActors();
- return (async function () {
+ return (async function() {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
await target.makeRemote();
let front = new WebGLFront(target.client, target.form);
return { target, front };
})();
}
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);
await target.makeRemote();
Services.prefs.setBoolPref("devtools.shadereditor.enabled", true);
let toolbox = await gDevTools.showToolbox(target, "shadereditor");
let panel = toolbox.getCurrentPanel();
@@ -194,17 +194,19 @@ function teardown(aPanel) {
// programs that should be listened to and waited on, and an optional
// `onAdd` function that calls with the entire actors array on program link
function getPrograms(front, count, onAdd) {
let actors = [];
let deferred = defer();
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);
deferred.resolve(actors);
}
});
return deferred.promise;
}