зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1177346 Part 4 - Add test for using inspector while paused.
--HG-- extra : rebase_source : ad8d9a0b2a72d112e54028f3b6f141a635f5a6ba
This commit is contained in:
Родитель
2e57e98ac1
Коммит
dac2eb70cb
|
@ -73,6 +73,7 @@ skip-if = os == "mac" # Full keyboard navigation on OSX only works if Full Keybo
|
|||
[browser_inspector_highlighter-04.js]
|
||||
[browser_inspector_highlighter-05.js]
|
||||
[browser_inspector_highlighter-06.js]
|
||||
[browser_inspector_highlighter-07.js]
|
||||
[browser_inspector_highlighter-by-type.js]
|
||||
[browser_inspector_highlighter-cancel.js]
|
||||
[browser_inspector_highlighter-comments.js]
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// Test that the highlighter works when the debugger is paused.
|
||||
|
||||
function debuggerIsPaused(dbg) {
|
||||
const {
|
||||
selectors: { isPaused },
|
||||
getState,
|
||||
} = dbg;
|
||||
return !!isPaused(getState());
|
||||
}
|
||||
|
||||
function waitForPaused(dbg) {
|
||||
return new Promise(resolve => {
|
||||
if (debuggerIsPaused(dbg)) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const unsubscribe = dbg.store.subscribe(() => {
|
||||
if (debuggerIsPaused(dbg)) {
|
||||
unsubscribe();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createDebuggerContext(toolbox) {
|
||||
const panel = toolbox.getPanel("jsdebugger");
|
||||
const win = panel.panelWin;
|
||||
const { store, client, selectors, actions } = panel.getVarsForTests();
|
||||
|
||||
return {
|
||||
actions: actions,
|
||||
selectors: selectors,
|
||||
getState: store.getState,
|
||||
store: store,
|
||||
client: client,
|
||||
toolbox: toolbox,
|
||||
win: win,
|
||||
panel: panel,
|
||||
};
|
||||
}
|
||||
|
||||
const IFRAME_SRC = "<style>" +
|
||||
"body {" +
|
||||
"margin:0;" +
|
||||
"height:100%;" +
|
||||
"background-color:red" +
|
||||
"}" +
|
||||
"</style><body>hello from iframe</body>";
|
||||
|
||||
const DOCUMENT_SRC = "<style>" +
|
||||
"iframe {" +
|
||||
"height:200px;" +
|
||||
"border: 11px solid black;" +
|
||||
"padding: 13px;" +
|
||||
"}" +
|
||||
"body,iframe {" +
|
||||
"margin:0" +
|
||||
"}" +
|
||||
"</style>" +
|
||||
"<body>" +
|
||||
"<script>setInterval('debugger', 100)</script>" +
|
||||
"<iframe src='data:text/html;charset=utf-8," + IFRAME_SRC + "'></iframe>" +
|
||||
"</body>";
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8," + DOCUMENT_SRC;
|
||||
|
||||
add_task(async function() {
|
||||
const { inspector, toolbox, testActor } = await openInspectorForURL(TEST_URI);
|
||||
|
||||
const target = await TargetFactory.forTab(gBrowser.selectedTab);
|
||||
await gDevTools.showToolbox(target, "jsdebugger");
|
||||
const dbg = createDebuggerContext(toolbox);
|
||||
|
||||
await waitForPaused(dbg);
|
||||
|
||||
await gDevTools.showToolbox(target, "inspector");
|
||||
|
||||
// Needed to get this test to pass consistently :(
|
||||
await waitForTime(1000);
|
||||
|
||||
info("Waiting for box mode to show.");
|
||||
const body = await getNodeFront("body", inspector);
|
||||
await inspector.highlighter.showBoxModel(body);
|
||||
|
||||
info("Waiting for element picker to become active.");
|
||||
await startPicker(toolbox);
|
||||
|
||||
info("Moving mouse over iframe padding.");
|
||||
await moveMouseOver("iframe", 1, 1);
|
||||
|
||||
info("Performing checks");
|
||||
await testActor.isNodeCorrectlyHighlighted("iframe", is);
|
||||
|
||||
function moveMouseOver(selector, x, y) {
|
||||
info("Waiting for element " + selector + " to be highlighted");
|
||||
testActor.synthesizeMouse({selector, x, y, options: {type: "mousemove"}});
|
||||
return inspector.inspector.nodePicker.once("picker-node-hovered");
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче