Auto merge of #8147 - nox:weakref, r=Ms2ger

Implement weak-referenceable JS-managed objects

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8147)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-13 06:22:40 +05:30
commit e63b1e83d4
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>