diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 7abebcac971..a2ec90033ba 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -273,6 +273,22 @@ impl HeapSizeOf for MutHeap { } } +impl PartialEq for MutHeap> { + fn eq(&self, other: &Self) -> bool { + unsafe { + *self.val.get() == *other.val.get() + } + } +} + +impl PartialEq for MutHeap> { + fn eq(&self, other: &T) -> bool { + unsafe { + **self.val.get() == *other + } + } +} + /// A holder that provides interior mutability for GC-managed values such as /// `JS`, with nullability represented by an enclosing Option wrapper. /// Essentially a `Cell>>`, but safer. @@ -334,6 +350,23 @@ impl MutNullableHeap> { *self.ptr.get() = val.map(|p| JS::from_ref(p)); } } + +} + +impl PartialEq for MutNullableHeap> { + fn eq(&self, other: &Self) -> bool { + unsafe { + *self.ptr.get() == *other.ptr.get() + } + } +} + +impl<'a, T: Reflectable> PartialEq> for MutNullableHeap> { + fn eq(&self, other: &Option<&T>) -> bool { + unsafe { + *self.ptr.get() == other.map(JS::from_ref) + } + } } impl Default for MutNullableHeap {