browser_toolbox_view_source_03.js (1276B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /** 5 * Tests that Toolbox#viewSourceInStyleEditor works when style editor is not 6 * yet opened. 7 */ 8 9 var URL = `${URL_ROOT_SSL}doc_viewsource.html`; 10 var CSS_URL = `${URL_ROOT_SSL}doc_theme.css`; 11 12 async function viewSource() { 13 const toolbox = await openNewTabAndToolbox(URL); 14 15 const fileFound = await toolbox.viewSourceInStyleEditorByURL(CSS_URL, 2); 16 ok( 17 fileFound, 18 "viewSourceInStyleEditorByURL should resolve to true if source found." 19 ); 20 21 const stylePanel = toolbox.getPanel("styleeditor"); 22 ok(stylePanel, "The style editor panel was opened."); 23 is( 24 toolbox.currentToolId, 25 "styleeditor", 26 "The style editor panel was selected." 27 ); 28 29 const { UI } = stylePanel; 30 31 is( 32 UI.selectedEditor.styleSheet.href, 33 CSS_URL, 34 "The correct source is shown in the style editor." 35 ); 36 is( 37 UI.selectedEditor.sourceEditor.getCursor().line + 1, 38 2, 39 "The correct line is highlighted in the style editor's source editor." 40 ); 41 42 await closeToolboxAndTab(toolbox); 43 finish(); 44 } 45 46 function test() { 47 viewSource().then(finish, error => { 48 ok(false, "Got an error: " + error.message + "\n" + error.stack); 49 finish(); 50 }); 51 }