diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 0b0b020cf19..47dfcad1aa5 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -1508,6 +1508,17 @@ impl Stylist { pub fn shutdown() { UA_CASCADE_DATA_CACHE.lock().unwrap().clear() } + + /// Temporary testing method. See bug 1403397. + pub fn corrupt_rule_hash_and_crash(&self, index: usize) { + let mut origin_iter = self.cascade_data.iter_origins(); + let d = origin_iter.next().unwrap().0; + let mut it = d.element_map.local_name_hash.iter(); + let nth = index % it.len(); + let entry = it.nth(nth).unwrap(); + let ptr = entry.0 as *const _ as *const usize as *mut usize; + unsafe { *ptr = 0; } + } } /// This struct holds data which users of Stylist may want to extract diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index d79b2ca6496..432ed4a73c6 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -4046,3 +4046,9 @@ pub extern "C" fn Servo_HasPendingRestyleAncestor(element: RawGeckoElementBorrow } false } + +#[no_mangle] +pub extern "C" fn Servo_CorruptRuleHashAndCrash(set: RawServoStyleSetBorrowed, index: usize) { + let per_doc_data = PerDocumentStyleData::from_ffi(set).borrow(); + per_doc_data.stylist.corrupt_rule_hash_and_crash(index); +}