/* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ // Tests that the addon commands works as they should const csscoverage = require("devtools/shared/fronts/csscoverage"); const PAGE_1 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page1.html"; const PAGE_2 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page2.html"; const PAGE_3 = TEST_BASE_HTTPS + "browser_cmd_csscoverage_page3.html"; const SHEET_A = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetA.css"; const SHEET_B = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetB.css"; const SHEET_C = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetC.css"; const SHEET_D = TEST_BASE_HTTPS + "browser_cmd_csscoverage_sheetD.css"; add_task(function* () { let options = yield helpers.openTab(PAGE_3); yield helpers.openToolbar(options); let usage = yield csscoverage.getUsage(options.target); yield navigate(usage, options); yield checkPages(usage); yield checkEditorReport(usage); // usage.createPageReport is not supported for usage.oneshot data as of // bug 1035300 because the page report assumed we have preload data which // oneshot can't gather. The ideal solution is to have a special no-preload // mode for the page report, but since oneshot isn't needed for the UI to // function, we're currently not supporting page report for oneshot data // yield checkPageReport(usage); yield helpers.closeToolbar(options); yield helpers.closeTab(options); }); /** * Just check current page */ function* navigate(usage, options) { ok(!usage.isRunning(), "csscoverage is not running"); yield usage.oneshot(); ok(!usage.isRunning(), "csscoverage is still not running"); } /** * Check the expected pages have been visited */ function* checkPages(usage) { let expectedVisited = [ PAGE_3 ]; let actualVisited = yield usage._testOnlyVisitedPages(); isEqualJson(actualVisited, expectedVisited, "Visited"); } /** * Check that createEditorReport returns the expected JSON */ function* checkEditorReport(usage) { // Page1 let expectedPage1 = { reports: [] }; let actualPage1 = yield usage.createEditorReport(PAGE_1 + " \u2192