1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/shadereditor/test/browser_se_editors-error-tooltip.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if error tooltips can be opened from the editor's gutter when there's 1.9 + * a shader compilation error. 1.10 + */ 1.11 + 1.12 +function ifWebGLSupported() { 1.13 + let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL); 1.14 + let { gFront, EVENTS, ShadersEditorsView } = panel.panelWin; 1.15 + 1.16 + reload(target); 1.17 + yield promise.all([ 1.18 + once(gFront, "program-linked"), 1.19 + once(panel.panelWin, EVENTS.SOURCES_SHOWN) 1.20 + ]); 1.21 + 1.22 + let vsEditor = yield ShadersEditorsView._getEditor("vs"); 1.23 + let fsEditor = yield ShadersEditorsView._getEditor("fs"); 1.24 + 1.25 + vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 }); 1.26 + yield once(panel.panelWin, EVENTS.SHADER_COMPILED); 1.27 + 1.28 + // Synthesizing 'mouseenter' events doesn't work, hack around this by 1.29 + // manually calling the event listener with the expected arguments. 1.30 + let editorDocument = vsEditor.container.contentDocument; 1.31 + let marker = editorDocument.querySelector(".error"); 1.32 + let parsed = ShadersEditorsView._errors.vs[0].messages; 1.33 + ShadersEditorsView._onMarkerMouseEnter(7, marker, parsed); 1.34 + 1.35 + let tooltip = marker._markerErrorsTooltip; 1.36 + ok(tooltip, "A tooltip was created successfully."); 1.37 + 1.38 + let content = tooltip.content; 1.39 + ok(tooltip.content, 1.40 + "Some tooltip's content was set."); 1.41 + ok(tooltip.content.className.contains("devtools-tooltip-simple-text-container"), 1.42 + "The tooltip's content container was created correctly."); 1.43 + 1.44 + let messages = content.childNodes; 1.45 + is(messages.length, 2, 1.46 + "There are two messages displayed in the tooltip."); 1.47 + ok(messages[0].className.contains("devtools-tooltip-simple-text"), 1.48 + "The first message was created correctly."); 1.49 + ok(messages[1].className.contains("devtools-tooltip-simple-text"), 1.50 + "The second message was created correctly."); 1.51 + 1.52 + ok(messages[0].textContent.contains("'constructor' : too many arguments"), 1.53 + "The first message contains the correct text."); 1.54 + ok(messages[1].textContent.contains("'assign' : cannot convert"), 1.55 + "The second message contains the correct text."); 1.56 + 1.57 + yield teardown(panel); 1.58 + finish(); 1.59 +}