diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/test/browser_inspector_highlighter-08.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_highlighter-08.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-08.js b/devtools/client/inspector/test/browser_inspector_highlighter-08.js new file mode 100644 index 0000000000..49b544a325 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_highlighter-08.js @@ -0,0 +1,67 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// Test that performing multiple requests to highlight nodes or to hide the highlighter, +// without waiting for the former ones to complete, still works well. +add_task(async function () { + info("Loading the test document and opening the inspector"); + const { inspector, highlighterTestFront } = await openInspectorForURL( + "data:text/html," + ); + const html = await getNodeFront("html", inspector); + const body = await getNodeFront("body", inspector); + const type = inspector.highlighters.TYPES.BOXMODEL; + const getActiveHighlighter = () => { + return inspector.highlighters.getActiveHighlighter(type); + }; + is(getActiveHighlighter(), null, "The highlighter is hidden by default"); + + info("Highlight <body>, and hide the highlighter immediately after"); + await Promise.all([ + inspector.highlighters.showHighlighterTypeForNode(type, body), + inspector.highlighters.hideHighlighterType(type), + ]); + is(getActiveHighlighter(), null, "The highlighter is hidden"); + + info("Highlight <body>, then <html>, then <body> again, synchronously"); + await Promise.all([ + inspector.highlighters.showHighlighterTypeForNode(type, body), + inspector.highlighters.showHighlighterTypeForNode(type, html), + inspector.highlighters.showHighlighterTypeForNode(type, body), + ]); + ok( + await highlighterTestFront.assertHighlightedNode("body"), + "The highlighter highlights <body>" + ); + + info("Highlight <html>, then <body>, then <html> again, synchronously"); + await Promise.all([ + inspector.highlighters.showHighlighterTypeForNode(type, html), + inspector.highlighters.showHighlighterTypeForNode(type, body), + inspector.highlighters.showHighlighterTypeForNode(type, html), + ]); + ok( + await highlighterTestFront.assertHighlightedNode("html"), + "The highlighter highlights <html>" + ); + + info("Hide the highlighter, and highlight <html> immediately after"); + await Promise.all([ + inspector.highlighters.hideHighlighterType(type), + inspector.highlighters.showHighlighterTypeForNode(type, body), + ]); + ok( + await highlighterTestFront.assertHighlightedNode("body"), + "The highlighter highlights <body>" + ); + + info("Highlight <html>, and hide the highlighter immediately after"); + await Promise.all([ + inspector.highlighters.showHighlighterTypeForNode(type, html), + inspector.highlighters.hideHighlighterType(type), + ]); + is(getActiveHighlighter(), null, "The highlighter is hidden"); +}); |