mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
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:
commit
e63b1e83d4
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