mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Introduce trait WeakReferenceable
This allows to take weak references of JS-managed DOM objects.
This commit is contained in:
parent
12f6ba29a7
commit
72c67efe96
10 changed files with 268 additions and 5 deletions
|
@ -7,6 +7,10 @@
|
|||
{
|
||||
"path": "mozilla/prototypes.html",
|
||||
"url": "/_mozilla/mozilla/prototypes.html"
|
||||
},
|
||||
{
|
||||
"path": "mozilla/weakref.html",
|
||||
"url": "/_mozilla/mozilla/weakref.html"
|
||||
}
|
||||
],
|
||||
"wdspec": []
|
||||
|
|
28
tests/wpt/mozilla/tests/mozilla/weakref.html
Normal file
28
tests/wpt/mozilla/tests/mozilla/weakref.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<script>
|
||||
test(function() {
|
||||
// We don't use assert_equals() etc here because it somehow
|
||||
// keeps hold of its passed arguments, and thus the weak
|
||||
// reference is never freed before the end of the test.
|
||||
|
||||
var t = new TestBinding;
|
||||
assert_true(t.interfaceAttributeWeak === null);
|
||||
|
||||
var url = new URL("http://blog.servo.org/");
|
||||
t.interfaceAttributeWeak = url;
|
||||
assert_true(t.interfaceAttributeWeak !== null);
|
||||
|
||||
gc();
|
||||
assert_true(t.interfaceAttributeWeak !== null);
|
||||
|
||||
url = null;
|
||||
gc();
|
||||
|
||||
assert_true(t.interfaceAttributeWeak === null);
|
||||
}, "Weak references work");
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue