Skip to content

Commit cae8fa0

Browse files
joedow-42chromium-wpt-export-bot
authored andcommitted
Fix cross-world Promise leak in navigator.keyboard.getLayoutMap()
This CL refactors KeyboardLayout::GetKeyboardLayoutMap to use ScriptPromiseProperty instead of maintaining a HeapVector of ScriptPromiseResolvers. This change aligns the implementation with Blink's preferred patterns for Promise-returning methods while continuing to satisfy the Keyboard API specifications: - Concurrent requests within the same world are automatically handled by ScriptPromiseProperty to return the same pending promise instance. - To ensure sequential calls return new promise instances (as required by the spec), `layout_map_property_` is now explicitly cleared once it has reached a resolved or rejected state. Bug: 501485453 Change-Id: Ia19bc3408e61ec160764f6229b6158fa5a912c3f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7751051 Reviewed-by: Yuki Shiino <yukishiino@chromium.org> Commit-Queue: Joe Downing <joedow@chromium.org> Cr-Commit-Position: refs/heads/main@{#1615641}
1 parent fb35c08 commit cae8fa0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

keyboard-map/navigator-keyboard-map-two-sequential-requests.https.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
'use strict';
66

77
promise_test(() => {
8-
return navigator.keyboard.getLayoutMap()
9-
.then(() => {
10-
return navigator.keyboard.getLayoutMap();
11-
});
12-
}, '[Keyboard Map] getLayoutMap() called twice sequentially');
8+
const p1 = navigator.keyboard.getLayoutMap();
9+
return p1.then(() => {
10+
const p2 = navigator.keyboard.getLayoutMap();
11+
assert_not_equals(p1, p2);
12+
return p2;
13+
});
14+
}, '[Keyboard Map] getLayoutMap() returns a new promise for sequential calls');
1315

1416
</script>

0 commit comments

Comments
 (0)