зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1470086 - Refactor shader editor initializer. r=jdescottes
MozReview-Commit-ID: sLVVmv8ZUF --HG-- rename : devtools/client/shadereditor/shadereditor.xul => devtools/client/shadereditor/index.xul extra : rebase_source : 8e6e0d46c8935bb80cd21f1904fd2c7b6ee8ac64
This commit is contained in:
Родитель
ef0edd4cb5
Коммит
4d61fa3588
|
@ -6,6 +6,7 @@
|
|||
|
||||
const Services = require("Services");
|
||||
const osString = Services.appinfo.OS;
|
||||
const { Cu } = require("chrome");
|
||||
|
||||
// Panels
|
||||
loader.lazyGetter(this, "OptionsPanel", () => require("devtools/client/framework/toolbox-options").OptionsPanel);
|
||||
|
@ -14,7 +15,6 @@ loader.lazyGetter(this, "WebConsolePanel", () => require("devtools/client/webcon
|
|||
loader.lazyGetter(this, "DebuggerPanel", () => require("devtools/client/debugger/panel").DebuggerPanel);
|
||||
loader.lazyGetter(this, "NewDebuggerPanel", () => require("devtools/client/debugger/new/panel").DebuggerPanel);
|
||||
loader.lazyGetter(this, "StyleEditorPanel", () => require("devtools/client/styleeditor/styleeditor-panel").StyleEditorPanel);
|
||||
loader.lazyGetter(this, "ShaderEditorPanel", () => require("devtools/client/shadereditor/panel").ShaderEditorPanel);
|
||||
loader.lazyGetter(this, "CanvasDebuggerPanel", () => require("devtools/client/canvasdebugger/panel").CanvasDebuggerPanel);
|
||||
loader.lazyGetter(this, "WebAudioEditorPanel", () => require("devtools/client/webaudioeditor/panel").WebAudioEditorPanel);
|
||||
loader.lazyGetter(this, "MemoryPanel", () => require("devtools/client/memory/panel").MemoryPanel);
|
||||
|
@ -219,7 +219,7 @@ Tools.shaderEditor = {
|
|||
ordinal: 5,
|
||||
visibilityswitch: "devtools.shadereditor.enabled",
|
||||
icon: "chrome://devtools/skin/images/tool-shadereditor.svg",
|
||||
url: "chrome://devtools/content/shadereditor/shadereditor.xul",
|
||||
url: "chrome://devtools/content/shadereditor/index.xul",
|
||||
label: l10n("ToolboxShaderEditor.label"),
|
||||
panelLabel: l10n("ToolboxShaderEditor.panelLabel"),
|
||||
tooltip: l10n("ToolboxShaderEditor.tooltip"),
|
||||
|
@ -229,7 +229,13 @@ Tools.shaderEditor = {
|
|||
},
|
||||
|
||||
build: function(iframeWindow, toolbox) {
|
||||
return new ShaderEditorPanel(iframeWindow, toolbox);
|
||||
const { BrowserLoader } = Cu.import("resource://devtools/client/shared/browser-loader.js", {});
|
||||
const browserRequire = BrowserLoader({
|
||||
baseURI: "resource://devtools/client/shadereditor/",
|
||||
window: iframeWindow
|
||||
}).require;
|
||||
const { ShaderEditorPanel } = browserRequire("devtools/client/shadereditor/panel");
|
||||
return new ShaderEditorPanel(toolbox);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ devtools.jar:
|
|||
content/debugger/views/stack-frames-classic-view.js (debugger/views/stack-frames-classic-view.js)
|
||||
content/debugger/views/filter-view.js (debugger/views/filter-view.js)
|
||||
content/debugger/utils.js (debugger/utils.js)
|
||||
content/shadereditor/shadereditor.xul (shadereditor/shadereditor.xul)
|
||||
content/shadereditor/shadereditor.js (shadereditor/shadereditor.js)
|
||||
content/shadereditor/index.xul (shadereditor/index.xul)
|
||||
content/canvasdebugger/index.xul (canvasdebugger/index.xul)
|
||||
content/canvasdebugger/canvasdebugger.js (canvasdebugger/canvasdebugger.js)
|
||||
content/canvasdebugger/snapshotslist.js (canvasdebugger/snapshotslist.js)
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
<script type="application/javascript"
|
||||
src="chrome://devtools/content/shared/theme-switching.js"/>
|
||||
|
||||
<script type="application/javascript" src="shadereditor.js"/>
|
||||
|
||||
<vbox class="theme-body" flex="1">
|
||||
<hbox id="reload-notice"
|
||||
class="notice-container"
|
|
@ -4,7 +4,8 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DevToolsModules(
|
||||
'panel.js'
|
||||
'panel.js',
|
||||
'shadereditor.js'
|
||||
)
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const promise = require("promise");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const { WebGLFront } = require("devtools/shared/fronts/webgl");
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
const { EventsHandler, ShadersListView, ShadersEditorsView, EVENTS, $, L10N } =
|
||||
require("./shadereditor");
|
||||
|
||||
function ShaderEditorPanel(iframeWindow, toolbox) {
|
||||
this.panelWin = iframeWindow;
|
||||
function ShaderEditorPanel(toolbox) {
|
||||
this._toolbox = toolbox;
|
||||
this._destroyer = null;
|
||||
this.panelWin = window;
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
|
@ -21,37 +21,36 @@ function ShaderEditorPanel(iframeWindow, toolbox) {
|
|||
exports.ShaderEditorPanel = ShaderEditorPanel;
|
||||
|
||||
ShaderEditorPanel.prototype = {
|
||||
|
||||
// Expose symbols for tests:
|
||||
EVENTS,
|
||||
$,
|
||||
L10N,
|
||||
|
||||
/**
|
||||
* Open is effectively an asynchronous constructor.
|
||||
*
|
||||
* @return object
|
||||
* A promise that is resolved when the Shader Editor completes opening.
|
||||
*/
|
||||
open: function() {
|
||||
let targetPromise;
|
||||
|
||||
async open() {
|
||||
// Local debugging needs to make the target remote.
|
||||
if (!this.target.isRemote) {
|
||||
targetPromise = this.target.makeRemote();
|
||||
} else {
|
||||
targetPromise = promise.resolve(this.target);
|
||||
await this.target.makeRemote();
|
||||
}
|
||||
|
||||
return targetPromise
|
||||
.then(() => {
|
||||
this.panelWin.gToolbox = this._toolbox;
|
||||
this.panelWin.gTarget = this.target;
|
||||
this.panelWin.gFront = new WebGLFront(this.target.client, this.target.form);
|
||||
return this.panelWin.startupShaderEditor();
|
||||
})
|
||||
.then(() => {
|
||||
this.isReady = true;
|
||||
this.emit("ready");
|
||||
return this;
|
||||
})
|
||||
.catch(function onError(aReason) {
|
||||
DevToolsUtils.reportException("ShaderEditorPanel.prototype.open", aReason);
|
||||
});
|
||||
this.front = new WebGLFront(this.target.client, this.target.form);
|
||||
this.shadersListView = new ShadersListView();
|
||||
this.eventsHandler = new EventsHandler();
|
||||
this.shadersEditorsView = new ShadersEditorsView();
|
||||
await this.shadersListView.initialize(this._toolbox, this.shadersEditorsView);
|
||||
await this.eventsHandler.initialize(this, this._toolbox, this.target, this.front,
|
||||
this.shadersListView);
|
||||
await this.shadersEditorsView.initialize(this, this.shadersListView);
|
||||
|
||||
this.isReady = true;
|
||||
this.emit("ready");
|
||||
return this;
|
||||
},
|
||||
|
||||
// DevToolPanel API
|
||||
|
@ -60,16 +59,19 @@ ShaderEditorPanel.prototype = {
|
|||
return this._toolbox.target;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
destroy() {
|
||||
// Make sure this panel is not already destroyed.
|
||||
if (this._destroyer) {
|
||||
return this._destroyer;
|
||||
}
|
||||
|
||||
return (this._destroyer = this.panelWin.shutdownShaderEditor().then(() => {
|
||||
return (this._destroyer = (async () => {
|
||||
await this.shadersListView.destroy();
|
||||
await this.eventsHandler.destroy();
|
||||
await this.shadersEditorsView.destroy();
|
||||
// Destroy front to ensure packet handler is removed from client
|
||||
this.panelWin.gFront.destroy();
|
||||
this.front.destroy();
|
||||
this.emit("destroyed");
|
||||
}));
|
||||
})());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
/* exported startupShaderEditor, shutdownShaderEditor */
|
||||
|
||||
const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const {SideMenuWidget} = require("resource://devtools/client/shared/widgets/SideMenuWidget.jsm");
|
||||
const {SideMenuWidget} = require("devtools/client/shared/widgets/SideMenuWidget.jsm");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const {Task} = require("devtools/shared/task");
|
||||
|
@ -19,11 +16,6 @@ const {extend} = require("devtools/shared/extend");
|
|||
const {WidgetMethods, setNamedTimeout} =
|
||||
require("devtools/client/shared/widgets/view-helpers");
|
||||
|
||||
// Use privileged promise in panel documents to prevent having them to freeze
|
||||
// during toolbox destruction. See bug 1402779.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Promise = require("Promise");
|
||||
|
||||
// The panel's window global is an EventEmitter firing the following events:
|
||||
const EVENTS = {
|
||||
// When new programs are received from the server.
|
||||
|
@ -42,7 +34,7 @@ const EVENTS = {
|
|||
// When the editor's error markers are all removed
|
||||
EDITOR_ERROR_MARKERS_REMOVED: "ShaderEditor:EditorCleaned"
|
||||
};
|
||||
XPCOMUtils.defineConstant(this, "EVENTS", EVENTS);
|
||||
exports.EVENTS = EVENTS;
|
||||
|
||||
const STRINGS_URI = "devtools/client/locales/shadereditor.properties";
|
||||
const HIGHLIGHT_TINT = [1, 0, 0.25, 1]; // rgba
|
||||
|
@ -56,89 +48,70 @@ const DEFAULT_EDITOR_CONFIG = {
|
|||
showAnnotationRuler: true
|
||||
};
|
||||
|
||||
/**
|
||||
* The current target and the WebGL Editor front, set by this tool's host.
|
||||
*/
|
||||
var gToolbox, gTarget, gFront;
|
||||
|
||||
/**
|
||||
* Initializes the shader editor controller and views.
|
||||
*/
|
||||
function startupShaderEditor() {
|
||||
return promise.all([
|
||||
EventsHandler.initialize(),
|
||||
ShadersListView.initialize(),
|
||||
ShadersEditorsView.initialize()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the shader editor controller and views.
|
||||
*/
|
||||
function shutdownShaderEditor() {
|
||||
return promise.all([
|
||||
EventsHandler.destroy(),
|
||||
ShadersListView.destroy(),
|
||||
ShadersEditorsView.destroy()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions handling target-related lifetime events.
|
||||
*/
|
||||
var EventsHandler = {
|
||||
class EventsHandler {
|
||||
/**
|
||||
* Listen for events emitted by the current tab target.
|
||||
*/
|
||||
initialize: function() {
|
||||
initialize(panel, toolbox, target, front, shadersListView) {
|
||||
this.panel = panel;
|
||||
this.toolbox = toolbox;
|
||||
this.target = target;
|
||||
this.front = front;
|
||||
this.shadersListView = shadersListView;
|
||||
|
||||
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.toolbox.on("host-changed", this._onHostChanged);
|
||||
this.target.on("will-navigate", this._onTabWillNavigate);
|
||||
this.target.on("navigate", this._onTabNavigated);
|
||||
this.front.on("program-linked", this._onProgramLinked);
|
||||
this.reloadButton = $("#requests-menu-reload-notice-button");
|
||||
this._onReloadCommand = this._onReloadCommand.bind(this);
|
||||
this.reloadButton.addEventListener("command", this._onReloadCommand);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove events emitted by the current tab target.
|
||||
*/
|
||||
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);
|
||||
destroy() {
|
||||
this.toolbox.off("host-changed", this._onHostChanged);
|
||||
this.target.off("will-navigate", this._onTabWillNavigate);
|
||||
this.target.off("navigate", this._onTabNavigated);
|
||||
this.front.off("program-linked", this._onProgramLinked);
|
||||
this.reloadButton.removeEventListener("command", this._onReloadCommand);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a command event on reload button
|
||||
*/
|
||||
_onReloadCommand() {
|
||||
gFront.setup({ reload: true });
|
||||
},
|
||||
this.front.setup({ reload: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a host change event on the parent toolbox.
|
||||
*/
|
||||
_onHostChanged: function() {
|
||||
if (gToolbox.hostType == "right" || gToolbox.hostType == "left") {
|
||||
_onHostChanged() {
|
||||
if (this.toolbox.hostType == "right" || this.toolbox.hostType == "left") {
|
||||
$("#shaders-pane").removeAttribute("height");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onTabWillNavigate: function({isFrameSwitching}) {
|
||||
_onTabWillNavigate({isFrameSwitching}) {
|
||||
// Make sure the backend is prepared to handle WebGL contexts.
|
||||
if (!isFrameSwitching) {
|
||||
gFront.setup({ reload: false });
|
||||
this.front.setup({ reload: false });
|
||||
}
|
||||
|
||||
// Reset UI.
|
||||
ShadersListView.empty();
|
||||
this.shadersListView.empty();
|
||||
// When switching to an iframe, ensure displaying the reload button.
|
||||
// As the document has already been loaded without being hooked.
|
||||
if (isFrameSwitching) {
|
||||
|
@ -150,55 +123,61 @@ var EventsHandler = {
|
|||
}
|
||||
|
||||
$("#content").hidden = true;
|
||||
window.emit(EVENTS.UI_RESET);
|
||||
},
|
||||
this.panel.emit(EVENTS.UI_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called for each location change in the debugged tab.
|
||||
*/
|
||||
_onTabNavigated: function() {
|
||||
_onTabNavigated() {
|
||||
// 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);
|
||||
},
|
||||
this.front.getPrograms().then(this._onProgramsAdded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every time a program was linked in the debugged tab.
|
||||
*/
|
||||
_onProgramLinked: function(programActor) {
|
||||
_onProgramLinked(programActor) {
|
||||
this._addProgram(programActor);
|
||||
window.emit(EVENTS.NEW_PROGRAM);
|
||||
},
|
||||
this.panel.emit(EVENTS.NEW_PROGRAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the front's getPrograms() method.
|
||||
*/
|
||||
_onProgramsAdded: function(programActors) {
|
||||
programActors.forEach(this._addProgram);
|
||||
window.emit(EVENTS.PROGRAMS_ADDED);
|
||||
},
|
||||
_onProgramsAdded(programActors) {
|
||||
programActors.forEach(this._addProgram.bind(this));
|
||||
this.panel.emit(EVENTS.PROGRAMS_ADDED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a program to the shaders list and unhides any modal notices.
|
||||
*/
|
||||
_addProgram: function(programActor) {
|
||||
_addProgram(programActor) {
|
||||
$("#waiting-notice").hidden = true;
|
||||
$("#reload-notice").hidden = true;
|
||||
$("#content").hidden = false;
|
||||
ShadersListView.addProgram(programActor);
|
||||
this.shadersListView.addProgram(programActor);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.EventsHandler = EventsHandler;
|
||||
|
||||
/**
|
||||
* Functions handling the sources UI.
|
||||
*/
|
||||
var ShadersListView = extend(WidgetMethods, {
|
||||
function WidgetMethodsClass() {
|
||||
}
|
||||
WidgetMethodsClass.prototype = WidgetMethods;
|
||||
class ShadersListView extends WidgetMethodsClass {
|
||||
/**
|
||||
* Initialization function, called when the tool is started.
|
||||
*/
|
||||
initialize: function() {
|
||||
initialize(toolbox, shadersEditorsView) {
|
||||
this.toolbox = toolbox;
|
||||
this.shadersEditorsView = shadersEditorsView;
|
||||
this.widget = new SideMenuWidget(this._pane = $("#shaders-pane"), {
|
||||
showArrows: true,
|
||||
showItemCheckboxes: true
|
||||
|
@ -213,17 +192,17 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
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() {
|
||||
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.
|
||||
|
@ -231,7 +210,7 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
* @param object programActor
|
||||
* The program actor coming from the active thread.
|
||||
*/
|
||||
addProgram: function(programActor) {
|
||||
addProgram(programActor) {
|
||||
if (this.hasProgram(programActor)) {
|
||||
return;
|
||||
}
|
||||
|
@ -265,11 +244,11 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
|
||||
// Prevent this container from growing indefinitely in height when the
|
||||
// toolbox is docked to the side.
|
||||
if ((gToolbox.hostType == "left" || gToolbox.hostType == "right") &&
|
||||
if ((this.toolbox.hostType == "left" || this.toolbox.hostType == "right") &&
|
||||
this.itemCount == SHADERS_AUTOGROW_ITEMS) {
|
||||
this._pane.setAttribute("height", this._pane.getBoundingClientRect().height);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a program was already added to this programs container.
|
||||
|
@ -279,14 +258,14 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
* @param boolean
|
||||
* True if the program was added, false otherwise.
|
||||
*/
|
||||
hasProgram: function(programActor) {
|
||||
hasProgram(programActor) {
|
||||
return !!this.attachments.filter(e => e.programActor == programActor).length;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The select listener for the programs container.
|
||||
*/
|
||||
_onProgramSelect: function({ detail: sourceItem }) {
|
||||
_onProgramSelect({ detail: sourceItem }) {
|
||||
if (!sourceItem) {
|
||||
return;
|
||||
}
|
||||
|
@ -305,33 +284,33 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
fragmentShaderActor.getText()
|
||||
]);
|
||||
}
|
||||
function showSources([vertexShaderText, fragmentShaderText]) {
|
||||
return ShadersEditorsView.setText({
|
||||
const showSources = ([vertexShaderText, fragmentShaderText]) => {
|
||||
return this.shadersEditorsView.setText({
|
||||
vs: vertexShaderText,
|
||||
fs: fragmentShaderText
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
getShaders()
|
||||
.then(getSources)
|
||||
.then(showSources)
|
||||
.catch(console.error);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The check listener for the programs container.
|
||||
*/
|
||||
_onProgramCheck: function({ detail: { checked }, target }) {
|
||||
_onProgramCheck({ detail: { checked }, target }) {
|
||||
const sourceItem = this.getItemForElement(target);
|
||||
const attachment = sourceItem.attachment;
|
||||
attachment.isBlackBoxed = !checked;
|
||||
attachment.programActor[checked ? "unblackbox" : "blackbox"]();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The mouseover listener for the programs container.
|
||||
*/
|
||||
_onProgramMouseOver: function(e) {
|
||||
_onProgramMouseOver(e) {
|
||||
const sourceItem = this.getItemForElement(e.target, { noSiblings: true });
|
||||
if (sourceItem && !sourceItem.attachment.isBlackBoxed) {
|
||||
sourceItem.attachment.programActor.highlight(HIGHLIGHT_TINT);
|
||||
|
@ -341,12 +320,12 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The mouseout listener for the programs container.
|
||||
*/
|
||||
_onProgramMouseOut: function(e) {
|
||||
_onProgramMouseOut(e) {
|
||||
const sourceItem = this.getItemForElement(e.target, { noSiblings: true });
|
||||
if (sourceItem && !sourceItem.attachment.isBlackBoxed) {
|
||||
sourceItem.attachment.programActor.unhighlight();
|
||||
|
@ -357,34 +336,42 @@ var ShadersListView = extend(WidgetMethods, {
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.ShadersListView = ShadersListView;
|
||||
|
||||
/**
|
||||
* Functions handling the editors displaying the vertex and fragment shaders.
|
||||
*/
|
||||
var ShadersEditorsView = {
|
||||
class ShadersEditorsView {
|
||||
/**
|
||||
* Initialization function, called when the tool is started.
|
||||
*/
|
||||
initialize: function() {
|
||||
initialize(panel, shadersListView) {
|
||||
this.panel = panel;
|
||||
this.shadersListView = shadersListView;
|
||||
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");
|
||||
},
|
||||
|
||||
this._errors = {
|
||||
vs: [],
|
||||
fs: []
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruction function, called when the tool is closed.
|
||||
*/
|
||||
destroy: Task.async(function* () {
|
||||
async destroy() {
|
||||
this._destroyed = true;
|
||||
yield this._toggleListeners("off");
|
||||
await this._toggleListeners("off");
|
||||
for (const p of this._editorPromises.values()) {
|
||||
const editor = yield p;
|
||||
const editor = await p;
|
||||
editor.destroy();
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text displayed in the vertex and fragment shader editors.
|
||||
|
@ -396,7 +383,7 @@ var ShadersEditorsView = {
|
|||
* @return object
|
||||
* A promise resolving upon completion of text setting.
|
||||
*/
|
||||
setText: function(sources) {
|
||||
setText(sources) {
|
||||
const view = this;
|
||||
function setTextAndClearHistory(editor, text) {
|
||||
editor.setText(text);
|
||||
|
@ -410,8 +397,8 @@ var ShadersEditorsView = {
|
|||
view._getEditor("fs").then(e => setTextAndClearHistory(e, sources.fs))
|
||||
]);
|
||||
await view._toggleListeners("on");
|
||||
})().then(() => window.emit(EVENTS.SOURCES_SHOWN, sources));
|
||||
},
|
||||
})().then(() => this.panel.emit(EVENTS.SOURCES_SHOWN, sources));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily initializes and returns a promise for an Editor instance.
|
||||
|
@ -422,7 +409,7 @@ var ShadersEditorsView = {
|
|||
* @return object
|
||||
* Returns a promise that resolves to an editor instance
|
||||
*/
|
||||
_getEditor: function(type) {
|
||||
_getEditor(type) {
|
||||
if (this._editorPromises.has(type)) {
|
||||
return this._editorPromises.get(type);
|
||||
}
|
||||
|
@ -443,7 +430,7 @@ var ShadersEditorsView = {
|
|||
}
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles all the event listeners for the editors either on or off.
|
||||
|
@ -453,14 +440,14 @@ var ShadersEditorsView = {
|
|||
* @return object
|
||||
* A promise resolving upon completion of toggling the listeners.
|
||||
*/
|
||||
_toggleListeners: function(flag) {
|
||||
_toggleListeners(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.
|
||||
|
@ -470,10 +457,10 @@ var ShadersEditorsView = {
|
|||
* @param string focused
|
||||
* The corresponding shader type for the other editor (e.g. "fs").
|
||||
*/
|
||||
_onFocused: function(focused, unfocused) {
|
||||
_onFocused(focused, unfocused) {
|
||||
$("#" + focused + "-editor-label").setAttribute("selected", "");
|
||||
$("#" + unfocused + "-editor-label").removeAttribute("selected");
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* The change listener for a source editor.
|
||||
|
@ -481,12 +468,12 @@ var ShadersEditorsView = {
|
|||
* @param string type
|
||||
* The corresponding shader type for the focused editor (e.g. "vs").
|
||||
*/
|
||||
_onChanged: function(type) {
|
||||
_onChanged(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.
|
||||
|
@ -495,10 +482,10 @@ var ShadersEditorsView = {
|
|||
* @param string type
|
||||
* The corresponding shader type for the focused editor (e.g. "vs").
|
||||
*/
|
||||
_doCompile: function(type) {
|
||||
_doCompile(type) {
|
||||
(async function() {
|
||||
const editor = await this._getEditor(type);
|
||||
const shaderActor = await ShadersListView.selectedAttachment[type];
|
||||
const shaderActor = await this.shadersListView.selectedAttachment[type];
|
||||
|
||||
try {
|
||||
await shaderActor.compile(editor.getText());
|
||||
|
@ -507,20 +494,20 @@ var ShadersEditorsView = {
|
|||
this._onFailedCompilation(type, editor, e);
|
||||
}
|
||||
}.bind(this))();
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Called uppon a successful shader compilation.
|
||||
*/
|
||||
_onSuccessfulCompilation: function() {
|
||||
_onSuccessfulCompilation() {
|
||||
// Signal that the shader was compiled successfully.
|
||||
window.emit(EVENTS.SHADER_COMPILED, null);
|
||||
},
|
||||
this.panel.emit(EVENTS.SHADER_COMPILED, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called uppon an unsuccessful shader compilation.
|
||||
*/
|
||||
_onFailedCompilation: function(type, editor, errors) {
|
||||
_onFailedCompilation(type, editor, errors) {
|
||||
const lineCount = editor.lineCount();
|
||||
const currentLine = editor.getCursor().line;
|
||||
const listeners = { mouseover: this._onMarkerMouseOver };
|
||||
|
@ -581,13 +568,13 @@ var ShadersEditorsView = {
|
|||
.forEach(displayErrors);
|
||||
|
||||
// Signal that the shader wasn't compiled successfully.
|
||||
window.emit(EVENTS.SHADER_COMPILED, errors);
|
||||
},
|
||||
this.panel.emit(EVENTS.SHADER_COMPILED, errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for the 'mouseover' event on a marker in the editor gutter.
|
||||
*/
|
||||
_onMarkerMouseOver: function(line, node, messages) {
|
||||
_onMarkerMouseOver(line, node, messages) {
|
||||
if (node._markerErrorsTooltip) {
|
||||
return;
|
||||
}
|
||||
|
@ -598,37 +585,30 @@ var ShadersEditorsView = {
|
|||
tooltip.startTogglingOnHover(node, () => true, {
|
||||
toggleDelay: GUTTER_ERROR_PANEL_DELAY
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all the gutter markers and line classes from the editor.
|
||||
*/
|
||||
_cleanEditor: function(type) {
|
||||
_cleanEditor(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);
|
||||
this.panel.emit(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
});
|
||||
},
|
||||
|
||||
_errors: {
|
||||
vs: [],
|
||||
fs: []
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.ShadersEditorsView = ShadersEditorsView;
|
||||
|
||||
/**
|
||||
* Localization convenience methods.
|
||||
*/
|
||||
var L10N = new LocalizationHelper(STRINGS_URI);
|
||||
|
||||
/**
|
||||
* Convenient way of emitting events from the panel window.
|
||||
*/
|
||||
EventEmitter.decorate(this);
|
||||
exports.L10N = L10N;
|
||||
|
||||
/**
|
||||
* DOM query helper.
|
||||
*/
|
||||
var $ = (selector, target = document) => target.querySelector(selector);
|
||||
exports.$ = $;
|
||||
|
|
|
@ -6,32 +6,32 @@
|
|||
*/
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, $, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
// Attach frame scripts if in e10s to perform
|
||||
// history navigation via the content
|
||||
loadFrameScripts();
|
||||
|
||||
const reloaded = reload(target);
|
||||
const firstProgram = await once(gFront, "program-linked");
|
||||
const firstProgram = await once(front, "program-linked");
|
||||
await reloaded;
|
||||
|
||||
const navigated = navigate(target, MULTIPLE_CONTEXTS_URL);
|
||||
const [secondProgram, thirdProgram] = await getPrograms(gFront, 2);
|
||||
const [secondProgram, thirdProgram] = await getPrograms(front, 2);
|
||||
await navigated;
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
await navigateInHistory(target, "back", "will-navigate");
|
||||
await once(panel.panelWin, EVENTS.PROGRAMS_ADDED);
|
||||
await once(panel.panelWin, EVENTS.SOURCES_SHOWN);
|
||||
await once(panel, EVENTS.PROGRAMS_ADDED);
|
||||
await once(panel, EVENTS.SOURCES_SHOWN);
|
||||
|
||||
is($("#content").hidden, false,
|
||||
"The tool's content should not be hidden.");
|
||||
is(ShadersListView.itemCount, 1,
|
||||
is(shadersListView.itemCount, 1,
|
||||
"The shaders list contains one entry after navigating back.");
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The shaders list has a correct selection after navigating back.");
|
||||
|
||||
is(vsEditor.getText().indexOf("gl_Position"), 170,
|
||||
|
@ -40,14 +40,14 @@ async function ifWebGLSupported() {
|
|||
"The fragment shader editor contains the correct text.");
|
||||
|
||||
await navigateInHistory(target, "forward", "will-navigate");
|
||||
await once(panel.panelWin, EVENTS.PROGRAMS_ADDED);
|
||||
await once(panel.panelWin, EVENTS.SOURCES_SHOWN);
|
||||
await once(panel, EVENTS.PROGRAMS_ADDED);
|
||||
await once(panel, EVENTS.SOURCES_SHOWN);
|
||||
|
||||
is($("#content").hidden, false,
|
||||
"The tool's content should not be hidden.");
|
||||
is(ShadersListView.itemCount, 2,
|
||||
is(shadersListView.itemCount, 2,
|
||||
"The shaders list contains two entries after navigating forward.");
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The shaders list has a correct selection after navigating forward.");
|
||||
|
||||
is(vsEditor.getText().indexOf("gl_Position"), 100,
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, ShadersEditorsView, EVENTS } = panel.panelWin;
|
||||
const { front, shadersEditorsView, EVENTS } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(vsEditor.getText().indexOf("gl_Position"), 170,
|
||||
"The vertex shader editor contains the correct text.");
|
||||
|
|
|
@ -8,64 +8,64 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, EVENTS, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 });
|
||||
let vertError = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
let vertError = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
info("Error marks added in the vertex shader editor.");
|
||||
|
||||
vsEditor.insertText(" ", { line: 1, ch: 0 });
|
||||
await panel.panelWin.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
await panel.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
is(vsEditor.getText(1), " precision lowp float;", "Typed space.");
|
||||
checkHasVertFirstError(false, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
info("Error marks removed while typing in the vertex shader editor.");
|
||||
|
||||
vertError = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
vertError = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
info("Error marks were re-added after recompiling the vertex shader.");
|
||||
|
||||
fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 });
|
||||
let fragError = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
let fragError = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
checkHasFragError(true, fragError);
|
||||
info("Error marks added in the fragment shader editor.");
|
||||
|
||||
fsEditor.insertText(" ", { line: 1, ch: 0 });
|
||||
await panel.panelWin.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
await panel.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
is(fsEditor.getText(1), " precision lowp float;", "Typed space.");
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
checkHasFragError(false, fragError);
|
||||
info("Error marks removed while typing in the fragment shader editor.");
|
||||
|
||||
fragError = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
fragError = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
checkHasFragError(true, fragError);
|
||||
info("Error marks were re-added after recompiling the fragment shader.");
|
||||
|
||||
vsEditor.replaceText("2", { line: 3, ch: 19 }, { line: 3, ch: 20 });
|
||||
await panel.panelWin.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
await panel.once(EVENTS.EDITOR_ERROR_MARKERS_REMOVED);
|
||||
checkHasVertFirstError(false, vertError);
|
||||
checkHasVertSecondError(false, vertError);
|
||||
checkHasFragError(true, fragError);
|
||||
info("Error marks removed while typing in the vertex shader editor again.");
|
||||
|
||||
vertError = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
vertError = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
checkHasVertFirstError(true, vertError);
|
||||
checkHasVertSecondError(true, vertError);
|
||||
checkHasFragError(true, fragError);
|
||||
|
@ -86,7 +86,7 @@ async function ifWebGLSupported() {
|
|||
is(vsEditor.hasLineClass(line, "error-line"), bool,
|
||||
"Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
|
||||
|
||||
const parsed = ShadersEditorsView._errors.vs;
|
||||
const parsed = shadersEditorsView._errors.vs;
|
||||
is(parsed.length >= 1, bool,
|
||||
"There's " + (bool ? ">= 1" : "< 1") + " parsed vertex shader error(s).");
|
||||
|
||||
|
@ -116,7 +116,7 @@ async function ifWebGLSupported() {
|
|||
is(vsEditor.hasLineClass(line, "error-line"), bool,
|
||||
"Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
|
||||
|
||||
const parsed = ShadersEditorsView._errors.vs;
|
||||
const parsed = shadersEditorsView._errors.vs;
|
||||
is(parsed.length >= 2, bool,
|
||||
"There's " + (bool ? ">= 2" : "< 2") + " parsed vertex shader error(s).");
|
||||
|
||||
|
@ -144,7 +144,7 @@ async function ifWebGLSupported() {
|
|||
is(fsEditor.hasLineClass(line, "error-line"), bool,
|
||||
"Error style is " + (bool ? "" : "not ") + "applied to the faulty line.");
|
||||
|
||||
const parsed = ShadersEditorsView._errors.fs;
|
||||
const parsed = shadersEditorsView._errors.fs;
|
||||
is(parsed.length >= 1, bool,
|
||||
"There's " + (bool ? ">= 2" : "< 1") + " parsed fragment shader error(s).");
|
||||
|
||||
|
|
|
@ -8,26 +8,26 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, EVENTS, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 });
|
||||
await once(panel.panelWin, EVENTS.SHADER_COMPILED);
|
||||
await once(panel, EVENTS.SHADER_COMPILED);
|
||||
|
||||
// Synthesizing 'mouseover' events doesn't work, hack around this by
|
||||
// manually calling the event listener with the expected arguments.
|
||||
const editorDocument = vsEditor.container.contentDocument;
|
||||
const marker = editorDocument.querySelector(".error");
|
||||
const parsed = ShadersEditorsView._errors.vs[0].messages;
|
||||
ShadersEditorsView._onMarkerMouseOver(7, marker, parsed);
|
||||
const parsed = shadersEditorsView._errors.vs[0].messages;
|
||||
shadersEditorsView._onMarkerMouseOver(7, marker, parsed);
|
||||
|
||||
const tooltip = marker._markerErrorsTooltip;
|
||||
ok(tooltip, "A tooltip was created successfully.");
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await once(gFront, "program-linked");
|
||||
await once(front, "program-linked");
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
ok(vsEditor, "A vertex shader editor was initialized.");
|
||||
ok(fsEditor, "A fragment shader editor was initialized.");
|
||||
|
@ -21,8 +21,8 @@ async function ifWebGLSupported() {
|
|||
isnot(vsEditor, fsEditor,
|
||||
"The vertex shader editor is distinct from the fragment shader editor.");
|
||||
|
||||
const vsEditor2 = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor2 = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor2 = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor2 = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(vsEditor, vsEditor2,
|
||||
"The vertex shader editor instances are cached.");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, $ } = panel.panelWin;
|
||||
const { front, $ } = panel;
|
||||
|
||||
is($("#reload-notice").hidden, false,
|
||||
"The 'reload this page' notice should initially be visible.");
|
||||
|
@ -17,7 +17,7 @@ async function ifWebGLSupported() {
|
|||
"The tool's content should initially be hidden.");
|
||||
|
||||
const navigating = once(target, "will-navigate");
|
||||
const linked = once(gFront, "program-linked");
|
||||
const linked = once(front, "program-linked");
|
||||
reload(target);
|
||||
|
||||
await navigating;
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, $, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
is($("#reload-notice").hidden, true,
|
||||
|
@ -22,15 +22,15 @@ async function ifWebGLSupported() {
|
|||
is($("#content").hidden, false,
|
||||
"The tool's content should not be hidden anymore.");
|
||||
|
||||
is(ShadersListView.itemCount, 1,
|
||||
is(shadersListView.itemCount, 1,
|
||||
"The shaders list contains one entry.");
|
||||
is(ShadersListView.selectedItem, ShadersListView.items[0],
|
||||
is(shadersListView.selectedItem, shadersListView.items[0],
|
||||
"The shaders list has a correct item selected.");
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The shaders list has a correct index selected.");
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(vsEditor.getText().indexOf("gl_Position"), 170,
|
||||
"The vertex shader editor contains the correct text.");
|
||||
|
@ -41,7 +41,7 @@ async function ifWebGLSupported() {
|
|||
const navigated = once(target, "will-navigate");
|
||||
navigate(target, "about:blank");
|
||||
|
||||
await promise.all([navigating, once(panel.panelWin, EVENTS.UI_RESET) ]);
|
||||
await promise.all([navigating, once(panel, EVENTS.UI_RESET) ]);
|
||||
|
||||
is($("#reload-notice").hidden, true,
|
||||
"The 'reload this page' notice should be hidden while navigating.");
|
||||
|
@ -50,11 +50,11 @@ async function ifWebGLSupported() {
|
|||
is($("#content").hidden, true,
|
||||
"The tool's content should be hidden now that there's no WebGL content.");
|
||||
|
||||
is(ShadersListView.itemCount, 0,
|
||||
is(shadersListView.itemCount, 0,
|
||||
"The shaders list should be empty.");
|
||||
is(ShadersListView.selectedItem, null,
|
||||
is(shadersListView.selectedItem, null,
|
||||
"The shaders list has no correct item.");
|
||||
is(ShadersListView.selectedIndex, -1,
|
||||
is(shadersListView.selectedIndex, -1,
|
||||
"The shaders list has a negative index.");
|
||||
|
||||
await navigated;
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, debuggee, panel } = await initShaderEditor(MULTIPLE_CONTEXTS_URL);
|
||||
const { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => {
|
||||
once(panel, EVENTS.SHADER_COMPILED).then(() => {
|
||||
ok(false, "No shaders should be publicly compiled during this test.");
|
||||
});
|
||||
|
||||
reload(target);
|
||||
const [[firstProgramActor, secondProgramActor]] = await promise.all([
|
||||
getPrograms(gFront, 2),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
getPrograms(front, 2),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
vsEditor.once("change", () => {
|
||||
ok(false, "The vertex shader source was unexpectedly changed.");
|
||||
|
@ -28,124 +28,124 @@ async function ifWebGLSupported() {
|
|||
fsEditor.once("change", () => {
|
||||
ok(false, "The fragment shader source was unexpectedly changed.");
|
||||
});
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
once(panel, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
ok(false, "No sources should be changed form this point onward.");
|
||||
});
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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(!ShadersListView.selectedAttachment.isBlackBoxed,
|
||||
ok(!shadersListView.selectedAttachment.isBlackBoxed,
|
||||
"The first program should not be blackboxed yet.");
|
||||
is(getBlackBoxCheckbox(panel, 0).checked, true,
|
||||
"The first blackbox checkbox should be initially checked.");
|
||||
ok(!ShadersListView.attachments[1].isBlackBoxed,
|
||||
ok(!shadersListView.attachments[1].isBlackBoxed,
|
||||
"The second program should not be blackboxed yet.");
|
||||
is(getBlackBoxCheckbox(panel, 1).checked, true,
|
||||
"The second blackbox checkbox should be initially checked.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
|
||||
ok(ShadersListView.selectedAttachment.isBlackBoxed,
|
||||
ok(shadersListView.selectedAttachment.isBlackBoxed,
|
||||
"The first program should now be blackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 0).checked, false,
|
||||
"The first blackbox checkbox should now be unchecked.");
|
||||
ok(!ShadersListView.attachments[1].isBlackBoxed,
|
||||
ok(!shadersListView.attachments[1].isBlackBoxed,
|
||||
"The second program should still not be blackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 1).checked, true,
|
||||
"The second blackbox checkbox should still be checked.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, 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: 0, g: 0, 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 first program was correctly blackboxed.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
ok(ShadersListView.selectedAttachment.isBlackBoxed,
|
||||
ok(shadersListView.selectedAttachment.isBlackBoxed,
|
||||
"The first program should still be blackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 0).checked, false,
|
||||
"The first blackbox checkbox should still be unchecked.");
|
||||
ok(ShadersListView.attachments[1].isBlackBoxed,
|
||||
ok(shadersListView.attachments[1].isBlackBoxed,
|
||||
"The second program should now be blackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 1).checked, false,
|
||||
"The second blackbox checkbox should now be unchecked.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
ok(true, "The second program was correctly blackboxed.");
|
||||
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
ok(true, "Highlighting shouldn't work while blackboxed (1).");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
ok(true, "Highlighting shouldn't work while blackboxed (2).");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas2");
|
||||
ok(true, "Highlighting shouldn't work while blackboxed (3).");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
ok(!ShadersListView.selectedAttachment.isBlackBoxed,
|
||||
ok(!shadersListView.selectedAttachment.isBlackBoxed,
|
||||
"The first program should now be unblackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 0).checked, true,
|
||||
"The first blackbox checkbox should now be rechecked.");
|
||||
ok(!ShadersListView.attachments[1].isBlackBoxed,
|
||||
ok(!shadersListView.attachments[1].isBlackBoxed,
|
||||
"The second program should now be unblackboxed.");
|
||||
is(getBlackBoxCheckbox(panel, 1).checked, true,
|
||||
"The second blackbox checkbox should now be rechecked.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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 programs were correctly unblackboxed.");
|
||||
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, 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: 0, 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 first program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
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: 0, b: 64, 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: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
ok(true, "The second program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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 programs were correctly unhighlighted.");
|
||||
|
||||
await teardown(panel);
|
||||
|
|
|
@ -8,49 +8,49 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, debuggee, panel } = await initShaderEditor(BLENDED_GEOMETRY_CANVAS_URL);
|
||||
const { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS } = panel;
|
||||
|
||||
reload(target);
|
||||
const [[firstProgramActor, secondProgramActor]] = await promise.all([
|
||||
getPrograms(gFront, 2),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
getPrograms(front, 2),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
ok(true, "The canvas was correctly drawn.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 0, b: 0, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 0, b: 0, a: 127 }, true);
|
||||
ok(true, "The first program was correctly blackboxed.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
ok(true, "The second program was correctly blackboxed.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
ok(true, "The two programs were correctly unblackboxed.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
ok(true, "The two programs were correctly blackboxed again.");
|
||||
|
||||
getBlackBoxCheckbox(panel, 0).click();
|
||||
getBlackBoxCheckbox(panel, 1).click();
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
ok(true, "The two programs were correctly unblackboxed again.");
|
||||
|
||||
await teardown(panel);
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, debuggee, panel } = await initShaderEditor(MULTIPLE_CONTEXTS_URL);
|
||||
const { EVENTS, gFront, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { EVENTS, front, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
const [[programActor]] = await promise.all([
|
||||
getPrograms(gFront, 1),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
getPrograms(front, 1),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const programItem = ShadersListView.selectedItem;
|
||||
const programItem = shadersListView.selectedItem;
|
||||
|
||||
is(programItem.attachment.programActor, programActor,
|
||||
"The correct program actor is cached for the selected item.");
|
||||
|
@ -29,11 +29,11 @@ async function ifWebGLSupported() {
|
|||
"The cached fragment shader promise returns the correct actor.");
|
||||
|
||||
is((await (await programActor.getVertexShader()).getText()),
|
||||
(await (await ShadersEditorsView._getEditor("vs")).getText()),
|
||||
(await (await shadersEditorsView._getEditor("vs")).getText()),
|
||||
"The cached vertex shader promise returns the correct text.");
|
||||
|
||||
is((await (await programActor.getFragmentShader()).getText()),
|
||||
(await (await ShadersEditorsView._getEditor("fs")).getText()),
|
||||
(await (await shadersEditorsView._getEditor("fs")).getText()),
|
||||
"The cached fragment shader promise returns the correct text.");
|
||||
|
||||
await teardown(panel);
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(MULTIPLE_CONTEXTS_URL);
|
||||
const { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => {
|
||||
once(panel, EVENTS.SHADER_COMPILED).then(() => {
|
||||
ok(false, "No shaders should be publicly compiled during this test.");
|
||||
});
|
||||
|
||||
reload(target);
|
||||
const [[firstProgramActor, secondProgramActor]] = await promise.all([
|
||||
getPrograms(gFront, 2),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
getPrograms(front, 2),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
vsEditor.once("change", () => {
|
||||
ok(false, "The vertex shader source was unexpectedly changed.");
|
||||
|
@ -28,54 +28,54 @@ async function ifWebGLSupported() {
|
|||
fsEditor.once("change", () => {
|
||||
ok(false, "The fragment shader source was unexpectedly changed.");
|
||||
});
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
once(panel, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
ok(false, "No sources should be changed form this point onward.");
|
||||
});
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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");
|
||||
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, 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: 0, 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 first program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
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: 0, b: 64, 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: 0, b: 64, a: 255 }, true, "#canvas2");
|
||||
ok(true, "The second program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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 programs were correctly unhighlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOver({ target: getBlackBoxCheckbox(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getBlackBoxCheckbox(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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 programs were left unchanged after hovering a blackbox checkbox.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getBlackBoxCheckbox(panel, 0) });
|
||||
shadersListView._onProgramMouseOut({ target: getBlackBoxCheckbox(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
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 programs were left unchanged after unhovering a blackbox checkbox.");
|
||||
|
||||
await teardown(panel);
|
||||
|
|
|
@ -8,35 +8,35 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, debuggee, panel } = await initShaderEditor(BLENDED_GEOMETRY_CANVAS_URL);
|
||||
const { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
const [[firstProgramActor, secondProgramActor]] = await promise.all([
|
||||
getPrograms(gFront, 2),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
getPrograms(front, 2),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
ok(true, "The canvas was correctly drawn.");
|
||||
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 0) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 0, b: 32, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 0, b: 32, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 0, b: 32, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 0, b: 32, a: 127 }, true);
|
||||
ok(true, "The first program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
ShadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 0) });
|
||||
shadersListView._onProgramMouseOver({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 255, g: 0, b: 64, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 255, g: 0, b: 64, a: 255 }, true);
|
||||
ok(true, "The second program was correctly highlighted.");
|
||||
|
||||
ShadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
shadersListView._onProgramMouseOut({ target: getItemLabel(panel, 1) });
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 127, g: 127, b: 127, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 127, b: 127, a: 127 }, true);
|
||||
ok(true, "The two programs were correctly unhighlighted.");
|
||||
|
||||
await teardown(panel);
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(MULTIPLE_CONTEXTS_URL);
|
||||
const { gFront, EVENTS, L10N, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, L10N, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
is(ShadersListView.itemCount, 0,
|
||||
is(shadersListView.itemCount, 0,
|
||||
"The shaders list should initially be empty.");
|
||||
is(ShadersListView.selectedItem, null,
|
||||
is(shadersListView.selectedItem, null,
|
||||
"The shaders list has no selected item.");
|
||||
is(ShadersListView.selectedIndex, -1,
|
||||
is(shadersListView.selectedIndex, -1,
|
||||
"The shaders list has a negative index.");
|
||||
|
||||
reload(target);
|
||||
|
||||
const [firstProgramActor, secondProgramActor] = await promise.all([
|
||||
getPrograms(gFront, 2, (actors) => {
|
||||
getPrograms(front, 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) {
|
||||
|
@ -30,12 +30,12 @@ async function ifWebGLSupported() {
|
|||
checkSecondProgram();
|
||||
}
|
||||
}),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]).then(([programs, ]) => programs);
|
||||
|
||||
is(ShadersListView.attachments[0].label, L10N.getFormatStr("shadersList.programLabel", 0),
|
||||
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),
|
||||
is(shadersListView.attachments[1].label, L10N.getFormatStr("shadersList.programLabel", 1),
|
||||
"The correct second label is shown in the shaders list.");
|
||||
|
||||
const vertexShader = await firstProgramActor.getVertexShader();
|
||||
|
@ -43,47 +43,47 @@ async function ifWebGLSupported() {
|
|||
const vertSource = await vertexShader.getText();
|
||||
const fragSource = await fragmentShader.getText();
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(vertSource, vsEditor.getText(),
|
||||
"The vertex shader editor contains the correct text.");
|
||||
is(fragSource, fsEditor.getText(),
|
||||
"The vertex shader editor contains the correct text.");
|
||||
|
||||
const compiled = once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => {
|
||||
const compiled = once(panel, EVENTS.SHADER_COMPILED).then(() => {
|
||||
ok(false, "Selecting a different program shouldn't recompile its shaders.");
|
||||
});
|
||||
|
||||
const shown = once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
const shown = once(panel, EVENTS.SOURCES_SHOWN).then(() => {
|
||||
ok(true, "The vertex and fragment sources have changed in the editors.");
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, shadersListView.items[1].target);
|
||||
await shown;
|
||||
|
||||
is(ShadersListView.selectedItem, ShadersListView.items[1],
|
||||
is(shadersListView.selectedItem, shadersListView.items[1],
|
||||
"The shaders list has a correct item selected.");
|
||||
is(ShadersListView.selectedIndex, 1,
|
||||
is(shadersListView.selectedIndex, 1,
|
||||
"The shaders list has a correct index selected.");
|
||||
|
||||
await teardown(panel);
|
||||
finish();
|
||||
|
||||
function checkFirstProgram() {
|
||||
is(ShadersListView.itemCount, 1,
|
||||
is(shadersListView.itemCount, 1,
|
||||
"The shaders list contains one entry.");
|
||||
is(ShadersListView.selectedItem, ShadersListView.items[0],
|
||||
is(shadersListView.selectedItem, shadersListView.items[0],
|
||||
"The shaders list has a correct item selected.");
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The shaders list has a correct index selected.");
|
||||
}
|
||||
function checkSecondProgram() {
|
||||
is(ShadersListView.itemCount, 2,
|
||||
is(shadersListView.itemCount, 2,
|
||||
"The shaders list contains two entries.");
|
||||
is(ShadersListView.selectedItem, ShadersListView.items[0],
|
||||
is(shadersListView.selectedItem, shadersListView.items[0],
|
||||
"The shaders list has a correct item selected.");
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The shaders list has a correct index selected.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, $, EVENTS, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, $, EVENTS, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(vsEditor.getText().indexOf("gl_Position"), 170,
|
||||
"The vertex shader editor contains the correct text.");
|
||||
|
@ -28,9 +28,9 @@ async function ifWebGLSupported() {
|
|||
is($("#fs-editor-label").hasAttribute("selected"), false,
|
||||
"The vertex shader editor shouldn't be initially selected.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 128, y: 128 }, { r: 191, g: 64, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 128, y: 128 }, { r: 191, g: 64, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
|
||||
|
||||
vsEditor.focus();
|
||||
|
||||
|
@ -40,13 +40,13 @@ async function ifWebGLSupported() {
|
|||
"The vertex shader editor shouldn't still not be selected.");
|
||||
|
||||
vsEditor.replaceText("2.0", { line: 7, ch: 44 }, { line: 7, ch: 47 });
|
||||
await once(panel.panelWin, EVENTS.SHADER_COMPILED);
|
||||
await once(panel, EVENTS.SHADER_COMPILED);
|
||||
|
||||
ok(true, "Vertex shader was changed.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
|
||||
ok(true, "The vertex shader was recompiled successfully.");
|
||||
|
||||
|
@ -58,13 +58,13 @@ async function ifWebGLSupported() {
|
|||
"The vertex shader editor should now be selected.");
|
||||
|
||||
fsEditor.replaceText("0.5", { line: 5, ch: 44 }, { line: 5, ch: 47 });
|
||||
await once(panel.panelWin, EVENTS.SHADER_COMPILED);
|
||||
await once(panel, EVENTS.SHADER_COMPILED);
|
||||
|
||||
ok(true, "Fragment shader was changed.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(gFront, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 127 }, true);
|
||||
await ensurePixelIs(gFront, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
await ensurePixelIs(front, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 127 }, true);
|
||||
await ensurePixelIs(front, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
|
||||
|
||||
ok(true, "The fragment shader was recompiled successfully.");
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(SIMPLE_CANVAS_URL);
|
||||
const { gFront, EVENTS, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(panel.panelWin, EVENTS.SOURCES_SHOWN)
|
||||
once(front, "program-linked"),
|
||||
once(panel, EVENTS.SOURCES_SHOWN)
|
||||
]);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const 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);
|
||||
let error = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
|
||||
ok(error,
|
||||
"The new vertex shader source was compiled with errors.");
|
||||
|
@ -40,7 +40,7 @@ async function ifWebGLSupported() {
|
|||
"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);
|
||||
error = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
|
||||
ok(error,
|
||||
"The new fragment shader source was compiled with errors.");
|
||||
|
@ -54,19 +54,19 @@ 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);
|
||||
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);
|
||||
|
||||
vsEditor.replaceText("vec4", { line: 7, ch: 22 }, { line: 7, ch: 26 });
|
||||
error = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
error = await panel.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 });
|
||||
error = await panel.panelWin.once(EVENTS.SHADER_COMPILED);
|
||||
error = await panel.once(EVENTS.SHADER_COMPILED);
|
||||
ok(!error, "The new fragment shader source was compiled successfully.");
|
||||
|
||||
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);
|
||||
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 teardown(panel);
|
||||
finish();
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
|
||||
async function ifWebGLSupported() {
|
||||
const { target, panel } = await initShaderEditor(MULTIPLE_CONTEXTS_URL);
|
||||
const { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
|
||||
const { front, EVENTS, shadersListView, shadersEditorsView } = panel;
|
||||
|
||||
reload(target);
|
||||
|
||||
await promise.all([
|
||||
once(gFront, "program-linked"),
|
||||
once(gFront, "program-linked")
|
||||
once(front, "program-linked"),
|
||||
once(front, "program-linked")
|
||||
]);
|
||||
|
||||
await once(panel.panelWin, EVENTS.SOURCES_SHOWN);
|
||||
await once(panel, EVENTS.SOURCES_SHOWN);
|
||||
|
||||
const vsEditor = await ShadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await ShadersEditorsView._getEditor("fs");
|
||||
const vsEditor = await shadersEditorsView._getEditor("vs");
|
||||
const fsEditor = await shadersEditorsView._getEditor("fs");
|
||||
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The first program is currently selected.");
|
||||
is(vsEditor.getText().indexOf("1);"), 136,
|
||||
"The vertex shader editor contains the correct initial text (1).");
|
||||
|
@ -34,28 +34,28 @@ async function ifWebGLSupported() {
|
|||
"The fragment shader editor contains the correct initial text (2).");
|
||||
|
||||
vsEditor.replaceText("2.", { line: 5, ch: 44 }, { line: 5, ch: 45 });
|
||||
await once(panel.panelWin, EVENTS.SHADER_COMPILED);
|
||||
await once(panel, EVENTS.SHADER_COMPILED);
|
||||
|
||||
fsEditor.replaceText(".0", { line: 5, ch: 35 }, { line: 5, ch: 37 });
|
||||
await once(panel.panelWin, EVENTS.SHADER_COMPILED);
|
||||
await once(panel, EVENTS.SHADER_COMPILED);
|
||||
|
||||
ok(true, "Vertex and fragment shaders were changed.");
|
||||
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(gFront, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(gFront, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 0, 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: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
await ensurePixelIs(front, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
|
||||
|
||||
ok(true, "The vertex and fragment shaders were recompiled successfully.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target);
|
||||
await once(panel.panelWin, EVENTS.SOURCES_SHOWN);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, shadersListView.items[1].target);
|
||||
await once(panel, EVENTS.SOURCES_SHOWN);
|
||||
|
||||
is(ShadersListView.selectedIndex, 1,
|
||||
is(shadersListView.selectedIndex, 1,
|
||||
"The second program is currently selected.");
|
||||
is(vsEditor.getText().indexOf("1);"), 136,
|
||||
"The vertex shader editor contains the correct text (1).");
|
||||
|
@ -66,10 +66,10 @@ async function ifWebGLSupported() {
|
|||
is(fsEditor.getText().indexOf(".0);"), -1,
|
||||
"The fragment shader editor contains the correct text (2).");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[0].target);
|
||||
await once(panel.panelWin, EVENTS.SOURCES_SHOWN);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, shadersListView.items[0].target);
|
||||
await once(panel, EVENTS.SOURCES_SHOWN);
|
||||
|
||||
is(ShadersListView.selectedIndex, 0,
|
||||
is(shadersListView.selectedIndex, 0,
|
||||
"The first program is currently selected again.");
|
||||
is(vsEditor.getText().indexOf("1);"), -1,
|
||||
"The vertex shader editor contains the correct text (3).");
|
||||
|
|
Загрузка…
Ссылка в новой задаче