haikuwebkit/LayoutTests/fast/dom/navigator-property-gc-after...

35 lines
1.2 KiB
HTML
Raw Permalink Normal View History

navigator.geolocation wrapper should not become GC-collectable once its frame is detached https://bugs.webkit.org/show_bug.cgi?id=200436 Reviewed by Darin Adler. Source/WebCore: navigator.geolocation wrapper should not become GC-collectable once its frame is detached, given that it can outlive the frame. Instead, tie the navigator.geolocation wrapper's lifetime to its Navigator's. Test: fast/dom/navigator-property-gc-after-frame-detach.html * Modules/geolocation/Geolocation.cpp: (WebCore::Geolocation::create): (WebCore::Geolocation::Geolocation): (WebCore::Geolocation::navigator): (WebCore::Geolocation::frame const): * Modules/geolocation/Geolocation.h: * Modules/geolocation/Geolocation.idl: * Modules/geolocation/NavigatorGeolocation.cpp: (WebCore::NavigatorGeolocation::NavigatorGeolocation): (WebCore::NavigatorGeolocation::from): (WebCore::NavigatorGeolocation::geolocation): (WebCore::NavigatorGeolocation::geolocation const): * Modules/geolocation/NavigatorGeolocation.h: * bindings/js/JSNavigatorCustom.cpp: (WebCore::JSNavigator::visitAdditionalChildren): * bindings/js/JSWorkerNavigatorCustom.cpp: (WebCore::JSWorkerNavigator::visitAdditionalChildren): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/IDLAttributes.json: * page/Navigator.cpp: (WebCore::Navigator::plugins): (WebCore::Navigator::mimeTypes): * page/NavigatorBase.h: * plugins/DOMMimeTypeArray.cpp: (WebCore::DOMMimeTypeArray::DOMMimeTypeArray): * plugins/DOMMimeTypeArray.h: * plugins/DOMMimeTypeArray.idl: * plugins/DOMPluginArray.cpp: (WebCore::DOMPluginArray::DOMPluginArray): * plugins/DOMPluginArray.h: * plugins/DOMPluginArray.idl: * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerContainer.idl: LayoutTests: Add layout test coverage. * fast/dom/navigator-property-gc-after-frame-detach-expected.txt: Added. * fast/dom/navigator-property-gc-after-frame-detach.html: Added. Canonical link: https://commits.webkit.org/214214@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248276 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-05 23:00:26 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<iframe id="testFrame" src="about:blank"></iframe>
<script>
description("Tests that Navigator properties do not get GC'd before their Navigator object.");
jsTestIsAsync = true;
var navigatorProperties = [ "geolocation", "mimeTypes", "plugins" ];
if (navigator.serviceWorker)
navigatorProperties.push("serviceWorker");
onload = function() {
frameNavigator = document.getElementById("testFrame").contentWindow.navigator;
for (let navigatorProperty of navigatorProperties)
eval("frameNavigator." + navigatorProperty + ".foo = 1;");
document.getElementById("testFrame").remove();
for (let navigatorProperty of navigatorProperties)
shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
debug("");
gc();
for (let navigatorProperty of navigatorProperties)
shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
debug("");
setTimeout(() => {
gc();
for (let navigatorProperty of navigatorProperties)
shouldBe("frameNavigator." + navigatorProperty + ".foo", "1");
finishJSTest();
}, 10);
}
</script>
</body>