blob: 2f6a414249420c6370b9698373911e2da581e9ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the scrollable badge is shown next to scrollable elements, and is updated
// dynamically when necessary.
const TEST_URI = `
<style type="text/css">
#wrapper {
width: 300px;
height: 300px;
overflow: scroll;
}
#wrapper.no-scroll {
overflow: hidden;
}
#content {
height: 1000px;
}
</style>
<div id="wrapper">
<div id="content"></div>
</div>
`;
add_task(async function () {
const { inspector } = await openInspectorForURL(
"data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)
);
let badge = await getBadgeEl(inspector);
ok(badge, "The scrollable badge exists on the test node");
info("Make the test node non-scrollable");
let onStateChanged = inspector.walker.once("scrollable-change");
await toggleScrollableClass();
await onStateChanged;
badge = await getBadgeEl(inspector);
ok(!badge, "The scrollable badge doesn't exist anymore");
info("Make the test node scrollable again");
onStateChanged = inspector.walker.once("scrollable-change");
await toggleScrollableClass();
await onStateChanged;
badge = await getBadgeEl(inspector);
ok(badge, "The scrollable badge exists again");
});
async function getBadgeEl(inspector) {
const wrapperMarkupContainer = await getContainerForSelector(
"#wrapper",
inspector
);
return wrapperMarkupContainer.elt.querySelector(
".inspector-badge.scrollable-badge"
);
}
async function toggleScrollableClass() {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
content.document.querySelector("#wrapper").classList.toggle("no-scroll");
});
}
|