diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/inspector/test/browser_inspector_highlighter-by-type.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_highlighter-by-type.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-by-type.js b/devtools/client/inspector/test/browser_inspector_highlighter-by-type.js new file mode 100644 index 0000000000..c9e67c8eca --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_highlighter-by-type.js @@ -0,0 +1,65 @@ +/* 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"; + +// Check that custom highlighters can be retrieved by type and that they expose +// the expected API. + +const TEST_URL = "data:text/html;charset=utf-8,custom highlighters"; + +add_task(async function () { + const { inspector } = await openInspectorForURL(TEST_URL); + + await manyInstancesOfCustomHighlighters(inspector); + await showHideMethodsAreAvailable(inspector); + await unknownHighlighterTypeShouldntBeAccepted(inspector); +}); + +async function manyInstancesOfCustomHighlighters({ inspectorFront }) { + const h1 = await inspectorFront.getHighlighterByType("BoxModelHighlighter"); + const h2 = await inspectorFront.getHighlighterByType("BoxModelHighlighter"); + ok(h1 !== h2, "getHighlighterByType returns new instances every time (1)"); + + const h3 = await inspectorFront.getHighlighterByType( + "CssTransformHighlighter" + ); + const h4 = await inspectorFront.getHighlighterByType( + "CssTransformHighlighter" + ); + ok(h3 !== h4, "getHighlighterByType returns new instances every time (2)"); + ok( + h3 !== h1 && h3 !== h2, + "getHighlighterByType returns new instances every time (3)" + ); + ok( + h4 !== h1 && h4 !== h2, + "getHighlighterByType returns new instances every time (4)" + ); + + await h1.finalize(); + await h2.finalize(); + await h3.finalize(); + await h4.finalize(); +} + +async function showHideMethodsAreAvailable({ inspectorFront }) { + const h1 = await inspectorFront.getHighlighterByType("BoxModelHighlighter"); + const h2 = await inspectorFront.getHighlighterByType( + "CssTransformHighlighter" + ); + + ok("show" in h1, "Show method is present on the front API"); + ok("show" in h2, "Show method is present on the front API"); + ok("hide" in h1, "Hide method is present on the front API"); + ok("hide" in h2, "Hide method is present on the front API"); + + await h1.finalize(); + await h2.finalize(); +} + +async function unknownHighlighterTypeShouldntBeAccepted({ inspectorFront }) { + const h = await inspectorFront.getHighlighterByType("whatever"); + ok(!h, "No highlighter was returned for the invalid type"); +} |