Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if all the function calls associated with an animation frame snapshot |
michael@0 | 6 | * are properly displayed in the UI. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | function ifTestingSupported() { |
michael@0 | 10 | let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); |
michael@0 | 11 | let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; |
michael@0 | 12 | |
michael@0 | 13 | yield reload(target); |
michael@0 | 14 | |
michael@0 | 15 | let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); |
michael@0 | 16 | let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); |
michael@0 | 17 | SnapshotsListView._onRecordButtonClick(); |
michael@0 | 18 | yield promise.all([recordingFinished, callListPopulated]); |
michael@0 | 19 | |
michael@0 | 20 | is(CallsListView.itemCount, 8, |
michael@0 | 21 | "All the function calls should now be displayed in the UI."); |
michael@0 | 22 | |
michael@0 | 23 | testItem(CallsListView.getItemAtIndex(0), |
michael@0 | 24 | "1", "ctx", "clearRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:25"); |
michael@0 | 25 | |
michael@0 | 26 | testItem(CallsListView.getItemAtIndex(1), |
michael@0 | 27 | "2", "ctx", "fillStyle", " = rgb(192, 192, 192)", "doc_simple-canvas.html:20"); |
michael@0 | 28 | testItem(CallsListView.getItemAtIndex(2), |
michael@0 | 29 | "3", "ctx", "fillRect", "(0, 0, 128, 128)", "doc_simple-canvas.html:21"); |
michael@0 | 30 | |
michael@0 | 31 | testItem(CallsListView.getItemAtIndex(3), |
michael@0 | 32 | "4", "ctx", "fillStyle", " = rgba(0, 0, 192, 0.5)", "doc_simple-canvas.html:20"); |
michael@0 | 33 | testItem(CallsListView.getItemAtIndex(4), |
michael@0 | 34 | "5", "ctx", "fillRect", "(30, 30, 55, 50)", "doc_simple-canvas.html:21"); |
michael@0 | 35 | |
michael@0 | 36 | testItem(CallsListView.getItemAtIndex(5), |
michael@0 | 37 | "6", "ctx", "fillStyle", " = rgba(192, 0, 0, 0.5)", "doc_simple-canvas.html:20"); |
michael@0 | 38 | testItem(CallsListView.getItemAtIndex(6), |
michael@0 | 39 | "7", "ctx", "fillRect", "(10, 10, 55, 50)", "doc_simple-canvas.html:21"); |
michael@0 | 40 | |
michael@0 | 41 | testItem(CallsListView.getItemAtIndex(7), |
michael@0 | 42 | "8", "", "requestAnimationFrame", "(Function)", "doc_simple-canvas.html:30"); |
michael@0 | 43 | |
michael@0 | 44 | function testItem(item, index, context, name, args, location) { |
michael@0 | 45 | let i = CallsListView.indexOfItem(item); |
michael@0 | 46 | is(i, index - 1, |
michael@0 | 47 | "The item at index " + index + " is correctly displayed in the UI."); |
michael@0 | 48 | |
michael@0 | 49 | is($(".call-item-index", item.target).getAttribute("value"), index, |
michael@0 | 50 | "The item's gutter label has the correct text."); |
michael@0 | 51 | |
michael@0 | 52 | if (context) { |
michael@0 | 53 | is($(".call-item-context", item.target).getAttribute("value"), context, |
michael@0 | 54 | "The item's context label has the correct text."); |
michael@0 | 55 | } else { |
michael@0 | 56 | is($(".call-item-context", item.target), null, |
michael@0 | 57 | "The item's context label should not be available."); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | is($(".call-item-name", item.target).getAttribute("value"), name, |
michael@0 | 61 | "The item's name label has the correct text."); |
michael@0 | 62 | is($(".call-item-args", item.target).getAttribute("value"), args, |
michael@0 | 63 | "The item's args label has the correct text."); |
michael@0 | 64 | is($(".call-item-location", item.target).getAttribute("value"), location, |
michael@0 | 65 | "The item's location label has the correct text."); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | yield teardown(panel); |
michael@0 | 69 | finish(); |
michael@0 | 70 | } |