Introduce trait WeakReferenceable

This allows to take weak references of JS-managed DOM objects.
This commit is contained in:
Anthony Ramine 2015-10-18 13:53:12 +02:00
parent 12f6ba29a7
commit 72c67efe96
10 changed files with 268 additions and 5 deletions

View file

@ -7,6 +7,10 @@
{
"path": "mozilla/prototypes.html",
"url": "/_mozilla/mozilla/prototypes.html"
},
{
"path": "mozilla/weakref.html",
"url": "/_mozilla/mozilla/weakref.html"
}
],
"wdspec": []

View 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>