|
1 | 1 | /* Any copyright is dedicated to the Public Domain. |
2 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
3 | 3 |
|
4 | | -function getCoordsFromPosition(cm, { line, ch }) { |
5 | | - return cm.charCoords({ line: ~~line, ch: ~~ch }); |
6 | | -} |
7 | 4 |
|
8 | | -function hoverAtPos(dbg, { line, ch }) { |
9 | | - info(`Hovering at (${line}, ${ch})\n`); |
10 | | - const cm = getCM(dbg); |
11 | | - const coords = getCoordsFromPosition(cm, { line: line - 1, ch }); |
12 | | - const tokenEl = dbg.win.document.elementFromPoint(coords.left, coords.top); |
13 | | - const previewed = waitForDispatch(dbg, "SET_PREVIEW"); |
14 | | - tokenEl.dispatchEvent( |
15 | | - new MouseEvent("mouseover", { |
16 | | - bubbles: true, |
17 | | - cancelable: true, |
18 | | - view: dbg.win |
19 | | - }) |
20 | | - ); |
21 | | - return previewed; |
| 5 | +async function assertNoTooltip(dbg) { |
| 6 | + await waitForTime(200); |
| 7 | + const el = findElement(dbg, "tooltip"); |
| 8 | + is(el, null, "Tooltip should not exist") |
22 | 9 | } |
23 | 10 |
|
24 | 11 | function assertPreviewTooltip(dbg, { result, expression }) { |
@@ -58,12 +45,21 @@ add_task(async function() { |
58 | 45 | await waitForPaused(dbg); |
59 | 46 | await waitForSelectedSource(dbg, "times2"); |
60 | 47 |
|
61 | | - await hoverAtPos(dbg, { line: 2, ch: 9 }); |
62 | | - assertPreviewTooltip(dbg, { result: 4, expression: "x" }); |
| 48 | + info(`Test previewing in the original location`) |
| 49 | + await assertPreviews(dbg, [ |
| 50 | + { line: 2, column: 10, result: 4, expression: "x" } |
| 51 | + ]); |
63 | 52 |
|
| 53 | + info(`Test previewing in the generated location`) |
64 | 54 | await dbg.actions.jumpToMappedSelectedLocation(); |
65 | 55 | await waitForSelectedSource(dbg, "bundle.js"); |
| 56 | + await assertPreviews(dbg, [ |
| 57 | + { line: 70, column: 11, result: 4, expression: "x" } |
| 58 | + ]); |
| 59 | + |
66 | 60 |
|
67 | | - await hoverAtPos(dbg, { line: 70, ch: 10 }); |
68 | | - assertPreviewTooltip(dbg, { result: 4, expression: "x" }); |
| 61 | + info(`Test that you can not preview in another original file`); |
| 62 | + await selectSource(dbg, "output"); |
| 63 | + await hoverAtPos(dbg, { line: 2, ch: 16 }); |
| 64 | + await assertNoTooltip(dbg) |
69 | 65 | }); |
0 commit comments