Files
fx-urlpattern-impl/firefox-webapi-with-crates.md
T
2026-08-24 16:26:38 -04:00

3.5 KiB

marp, title, author, date, paginate, footer
marp title author date paginate footer
true @marp-team/marp-cli v4.4.0 (w/ @marp-team/marp-core v4.3.0) Firefox Web APIs with crates over FFI Ed Guloien Sept 2026 true <span> <img src="images/qb-logo-mark.png" width="60"/> Sept 2026 </span>
<style> /* font setup */ section { @font-face { font-family: 'Montserrat'; font-weight: 400; src: url('./fonts/Montserrat-Regular.woff2') format('woff2'); } @font-face { font-family: 'Montserrat'; font-weight: 700; src: url('./fonts/Montserrat-Bold.woff2') format('woff2'); } font-family: 'Montserrat', sans-sarif; } footer { width: 100%; text-align: left; } /* title setup */ h1 { color: #4ca783; border-bottom: 2px solid #fc8a09;} /* general title and text setup */ h2 { color: #4ca783; position: absolute; top: 50px; left: 60px; border-bottom: 2px solid #fc8a09; } section { font-family: 'Montserrat', sans-serif; color: #5d5d5c } /* references setup */ h4 { color: #4ca783; position: absolute; top: 100px; left: 60px; border-bottom: 2px solid #fc8a09; margin-top: 200px; } p { margin-top: 300px; font-family: 'Montserrat', sans-serif; } </style>

Firefox Web APIs with Crates (over FFI)

Ed Guloien


about://ed-guloien

  • Software Developer @ Quantum Bridge: Distributed Symmetric Key Exchange
  • Former Mozillian: Platform, Networking
  • Interests: Privacy, Security, Systems
  • ed.guloien@qubridge.io

bg right:40% width:350


Interop 2025

bg width:600px bg width:600px


URLPattern Web API

// JS
// build a pattern
const pattern = new URLPattern({ pathname: "/books/:id" });

// check for match
pattern.test("https://example.com/books/123"); 

// get match info by component
pattern.exec("https://example.com/books/123").pathname.groups

Denoland & Firefox

bg width:400px

bg width:600px


Web API Call Flow

bg center width:1000px


Urlpattern Crate API

bg center width:850px


Glue Crate

let pattern = quirks::parse::<SpiderMonkeyRegexp>(input);
let results = quirks::process_match(pattern, input);

// call it a day

Reality Sets In (Memory Concerns)

#[repr(transparent)]
pub struct UrlPatternGlue(pub *mut c_void);


if let Ok(pattern) = quirks::parse::<SpiderMonkeyRegexp>(input, ...) {
  unsafe {
    *res = UrlPatternGlue(Box::into_raw(Box::new(pattern)) as *mut _);
  }
}


glue::process_match(..., res: *mut MatchResults, other: MaybeString)


glue::doing_thing(..., res: &mut ThinVec<>);

Pattern Re-use; Marshaling

bg center width:1000px


99.8%

regex::Regex != EcmaScript Regex

Spidermonkey Challenges (many)

bg center width:825px


Phew!

width:900px

<style scoped> img { position: absolute; top: 150px; left: 15%; } </style>

References