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 | // Tests that the developer toolbar works properly |
michael@0 | 5 | |
michael@0 | 6 | const TEST_URI = "data:text/html;charset=utf-8,<p>Tooltip Tests</p>"; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | addTab(TEST_URI, function(browser, tab) { |
michael@0 | 10 | info("Starting browser_toolbar_tooltip.js"); |
michael@0 | 11 | openTest(); |
michael@0 | 12 | }); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function openTest() { |
michael@0 | 16 | ok(!DeveloperToolbar.visible, "DeveloperToolbar is not visible in runTest"); |
michael@0 | 17 | |
michael@0 | 18 | oneTimeObserve(DeveloperToolbar.NOTIFICATIONS.SHOW, catchFail(runTest)); |
michael@0 | 19 | document.getElementById("Tools:DevToolbar").doCommand(); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function runTest() { |
michael@0 | 23 | let tooltipPanel = DeveloperToolbar.tooltipPanel; |
michael@0 | 24 | |
michael@0 | 25 | DeveloperToolbar.display.focusManager.helpRequest(); |
michael@0 | 26 | DeveloperToolbar.display.inputter.setInput('help help'); |
michael@0 | 27 | |
michael@0 | 28 | DeveloperToolbar.display.inputter.setCursor({ start: 'help help'.length }); |
michael@0 | 29 | is(tooltipPanel._dimensions.start, 'help '.length, |
michael@0 | 30 | 'search param start, when cursor at end'); |
michael@0 | 31 | ok(getLeftMargin() > 30, 'tooltip offset, when cursor at end') |
michael@0 | 32 | |
michael@0 | 33 | DeveloperToolbar.display.inputter.setCursor({ start: 'help'.length }); |
michael@0 | 34 | is(tooltipPanel._dimensions.start, 0, |
michael@0 | 35 | 'search param start, when cursor at end of command'); |
michael@0 | 36 | ok(getLeftMargin() > 9, 'tooltip offset, when cursor at end of command') |
michael@0 | 37 | |
michael@0 | 38 | DeveloperToolbar.display.inputter.setCursor({ start: 'help help'.length - 1 }); |
michael@0 | 39 | is(tooltipPanel._dimensions.start, 'help '.length, |
michael@0 | 40 | 'search param start, when cursor at penultimate position'); |
michael@0 | 41 | ok(getLeftMargin() > 30, 'tooltip offset, when cursor at penultimate position') |
michael@0 | 42 | |
michael@0 | 43 | DeveloperToolbar.display.inputter.setCursor({ start: 0 }); |
michael@0 | 44 | is(tooltipPanel._dimensions.start, 0, |
michael@0 | 45 | 'search param start, when cursor at start'); |
michael@0 | 46 | ok(getLeftMargin() > 9, 'tooltip offset, when cursor at start') |
michael@0 | 47 | |
michael@0 | 48 | finish(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function getLeftMargin() { |
michael@0 | 52 | let style = DeveloperToolbar.tooltipPanel._panel.style.marginLeft; |
michael@0 | 53 | return parseInt(style.slice(0, -2), 10); |
michael@0 | 54 | } |