Skip to content

Commit b914762

Browse files
Ravjit Uppalchromium-wpt-export-bot
authored andcommitted
[PEPC] Precise attribute is no longer set-once-only
Precise attribute can now be set and unset multiple times. This has no side-effect the first time it is set, but every subsequent change to the attribute, the permission element will be disabled for 500ms. Bug: 452297243 Change-Id: Ia8c80a50dd37174451756d9f34d1f855a7e2ffa8
1 parent 2164d3d commit b914762

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Permission Element: invalid if precise attribute is changed</title>
6+
<link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md" />
7+
<script src="/resources/testharness.js"></script>
8+
<script src="/resources/testharnessreport.js"></script>
9+
</head>
10+
<body>
11+
<script>
12+
promise_test(async (t) => {
13+
let is_element_valid = false;
14+
const element = document.createElement("permission");
15+
element.setAttribute("type", "geolocation");
16+
element.onvalidationstatuschange = t.step_func(() => {
17+
if (element.invalidReason == "") {
18+
is_element_valid = true;
19+
}
20+
if (element.invalidReason == "attribute_changed") {
21+
is_element_valid = false;
22+
}
23+
});
24+
document.body.appendChild(element);
25+
26+
await t.step_wait(() => is_element_valid === true, "Wait for the element to be ready.");
27+
28+
// setting the preciselocation attribute should temporarily disable the element.
29+
element.setAttribute("preciselocation", "");
30+
await t.step_wait(
31+
() => is_element_valid === false,
32+
"Element should become invalid after preciselocation is set.",
33+
);
34+
await t.step_wait(
35+
() => is_element_valid === true,
36+
"Element should automatically become valid again after 500ms after the attribute is set.",
37+
);
38+
39+
// uusetting the preciselocation attribute should temporarily disable the element.
40+
element.removeAttribute("preciselocation");
41+
await t.step_wait(
42+
() => is_element_valid === false,
43+
"Element should become invalid after preciselocation is unset.",
44+
);
45+
await t.step_wait(
46+
() => is_element_valid === true,
47+
"Element should automatically become valid again after 500ms after the attribute is unset.",
48+
);
49+
}, "Permission element is invalid temporarily if the precise attribute is changed.");
50+
</script>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)