tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_styleeditor_reload.js (1274B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 // Test that selected sheet and cursor position persists during reload.
      6 
      7 const TESTCASE_URI = TEST_BASE_HTTPS + "simple.html";
      8 
      9 const LINE_NO = 5;
     10 const COL_NO = 3;
     11 
     12 add_task(async function () {
     13  const { ui } = await openStyleEditorForURL(TESTCASE_URI);
     14 
     15  is(ui.editors.length, 2, "Two sheets present after load.");
     16 
     17  info("Selecting the second editor");
     18  await ui.selectStyleSheet(ui.editors[1].styleSheet, LINE_NO, COL_NO);
     19  const selectedStyleSheetIndex = ui.editors[1].styleSheet.styleSheetIndex;
     20 
     21  await reloadPageAndWaitForStyleSheets(ui, 2);
     22 
     23  info("Waiting for source editor to be ready.");
     24  const newEditor = findEditor(ui, selectedStyleSheetIndex);
     25  await newEditor.getSourceEditor();
     26 
     27  is(
     28    ui.selectedEditor,
     29    newEditor,
     30    "Editor of stylesheet that has styleSheetIndex we selected is selected after reload"
     31  );
     32 
     33  const { line, ch } = ui.selectedEditor.sourceEditor.getCursor();
     34  is(line, LINE_NO, "correct line selected");
     35  is(ch, COL_NO, "correct column selected");
     36 });
     37 
     38 function findEditor(ui, styleSheetIndex) {
     39  return ui.editors.find(
     40    editor => editor.styleSheet.styleSheetIndex === styleSheetIndex
     41  );
     42 }