1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/canvasdebugger/test/browser_canvas-frontend-stepping.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 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 the stepping buttons in the call list toolbar work as advertised. 1.9 + */ 1.10 + 1.11 +function ifTestingSupported() { 1.12 + let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); 1.13 + let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; 1.14 + 1.15 + yield reload(target); 1.16 + 1.17 + let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); 1.18 + let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); 1.19 + SnapshotsListView._onRecordButtonClick(); 1.20 + yield promise.all([recordingFinished, callListPopulated]); 1.21 + 1.22 + checkSteppingButtons(1, 1, 1, 1); 1.23 + is(CallsListView.selectedIndex, -1, 1.24 + "There should be no selected item in the calls list view initially."); 1.25 + 1.26 + CallsListView._onResume(); 1.27 + checkSteppingButtons(1, 1, 1, 1); 1.28 + is(CallsListView.selectedIndex, 0, 1.29 + "The first draw call should now be selected."); 1.30 + 1.31 + CallsListView._onResume(); 1.32 + checkSteppingButtons(1, 1, 1, 1); 1.33 + is(CallsListView.selectedIndex, 2, 1.34 + "The second draw call should now be selected."); 1.35 + 1.36 + CallsListView._onStepOver(); 1.37 + checkSteppingButtons(1, 1, 1, 1); 1.38 + is(CallsListView.selectedIndex, 3, 1.39 + "The next context call should now be selected."); 1.40 + 1.41 + CallsListView._onStepOut(); 1.42 + checkSteppingButtons(0, 0, 1, 0); 1.43 + is(CallsListView.selectedIndex, 7, 1.44 + "The last context call should now be selected."); 1.45 + 1.46 + function checkSteppingButtons(resume, stepOver, stepIn, stepOut) { 1.47 + if (!resume) { 1.48 + is($("#resume").getAttribute("disabled"), "true", 1.49 + "The resume button doesn't have the expected disabled state."); 1.50 + } else { 1.51 + is($("#resume").hasAttribute("disabled"), false, 1.52 + "The resume button doesn't have the expected enabled state."); 1.53 + } 1.54 + if (!stepOver) { 1.55 + is($("#step-over").getAttribute("disabled"), "true", 1.56 + "The stepOver button doesn't have the expected disabled state."); 1.57 + } else { 1.58 + is($("#step-over").hasAttribute("disabled"), false, 1.59 + "The stepOver button doesn't have the expected enabled state."); 1.60 + } 1.61 + if (!stepIn) { 1.62 + is($("#step-in").getAttribute("disabled"), "true", 1.63 + "The stepIn button doesn't have the expected disabled state."); 1.64 + } else { 1.65 + is($("#step-in").hasAttribute("disabled"), false, 1.66 + "The stepIn button doesn't have the expected enabled state."); 1.67 + } 1.68 + if (!stepOut) { 1.69 + is($("#step-out").getAttribute("disabled"), "true", 1.70 + "The stepOut button doesn't have the expected disabled state."); 1.71 + } else { 1.72 + is($("#step-out").hasAttribute("disabled"), false, 1.73 + "The stepOut button doesn't have the expected enabled state."); 1.74 + } 1.75 + } 1.76 + 1.77 + yield teardown(panel); 1.78 + finish(); 1.79 +}