mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Fix crash when enumerating properties of global object (#36491)
These changes make our implementation of the enumeration hook for globals [match Gecko's](https://searchfox.org/mozilla-central/rev/1f65969e57c757146e3e548614b49d3a4168eeb8/dom/base/nsGlobalWindowInner.cpp#3297), fixing an assertion failure that occurred in the previous implementation. Our enumeration hook is supposed to fill a vector with names of properties on the global object without modifying the global in any way; instead we were defining all of the missing webidl interfaces. We now do much less work and crash less. Testing: New crashtest based on manual testcase. Fixes: #34686 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
a1b9949f75
commit
30390f8c5e
9 changed files with 98 additions and 34 deletions
|
@ -43,13 +43,21 @@ fn main() {
|
|||
let json: Value = serde_json::from_reader(File::open(json).unwrap()).unwrap();
|
||||
let mut map = phf_codegen::Map::new();
|
||||
for (key, value) in json.as_object().unwrap() {
|
||||
map.entry(Bytes(key), value.as_str().unwrap());
|
||||
let parts = value.as_array().unwrap();
|
||||
map.entry(
|
||||
Bytes(key),
|
||||
&format!(
|
||||
"Interface {{ define: {}, enabled: {} }}",
|
||||
parts[0].as_str().unwrap(),
|
||||
parts[1].as_str().unwrap()
|
||||
),
|
||||
);
|
||||
}
|
||||
let phf = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("InterfaceObjectMapPhf.rs");
|
||||
let mut phf = File::create(phf).unwrap();
|
||||
writeln!(
|
||||
&mut phf,
|
||||
"pub(crate) static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = {};",
|
||||
"pub(crate) static MAP: phf::Map<&'static [u8], Interface> = {};",
|
||||
map.build(),
|
||||
)
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue