mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,66 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* Bug 968896 */
|
||||
|
||||
// Test the completions using numbers.
|
||||
const source = "0x1.";
|
||||
const completions = ["toExponential", "toFixed", "toString"];
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
function test() {
|
||||
const options = { tabContent: "test scratchpad autocomplete" };
|
||||
openTabAndScratchpad(options)
|
||||
.then(Task.async(runTests))
|
||||
.then(finish, console.error);
|
||||
}
|
||||
|
||||
|
||||
function* runTests([win, sp]) {
|
||||
const {editor} = sp;
|
||||
const editorWin = editor.container.contentWindow;
|
||||
|
||||
// Show the completions popup.
|
||||
sp.setText(source);
|
||||
sp.editor.setCursor({ line: 0, ch: source.length });
|
||||
yield keyOnce("suggestion-entered", " ", { ctrlKey: true });
|
||||
|
||||
// Get the hints popup container.
|
||||
const hints = editorWin.document.querySelector(".CodeMirror-hints");
|
||||
|
||||
ok(hints,
|
||||
"The hint container should exist.");
|
||||
is(hints.childNodes.length, 3,
|
||||
"The hint container should have the completions.");
|
||||
|
||||
let i = 0;
|
||||
for (let completion of completions) {
|
||||
let active = hints.querySelector(".CodeMirror-hint-active");
|
||||
is(active.textContent, completion,
|
||||
"Check that completion " + i++ + " is what is expected.");
|
||||
yield keyOnce("suggestion-entered", "VK_DOWN");
|
||||
}
|
||||
|
||||
// We should have looped around to the first suggestion again. Accept it.
|
||||
yield keyOnce("after-suggest", "VK_RETURN");
|
||||
|
||||
is(sp.getText(), source + completions[0],
|
||||
"Autocompletion should work and select the right element.");
|
||||
|
||||
// Check that the information tooltips work.
|
||||
sp.setText("5");
|
||||
yield keyOnce("show-information", " ", { ctrlKey: true, shiftKey: true });
|
||||
|
||||
// Get the information container.
|
||||
const info = editorWin.document.querySelector(".CodeMirror-Tern-information");
|
||||
ok(info,
|
||||
"Info tooltip should appear.");
|
||||
is(info.textContent.slice(0, 6), "number",
|
||||
"Info tooltip should have expected contents.");
|
||||
|
||||
function keyOnce(event, key, opts = {}) {
|
||||
const p = editor.once(event);
|
||||
EventUtils.synthesizeKey(key, opts, editorWin);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue