///|
/// Supported event/module names accepted by session.{subscribe,unsubscribe}.
fn is_valid_session_subscription_event_name(name : String) -> Bool {
if name == "browsingContext" ||
name == "script" ||
name == "log" ||
name == "network" ||
name == "input" ||
name == "storage" ||
name == "browser" ||
name == "bluetooth" ||
name == "permissions" ||
name == "session" ||
name == "webExtension" ||
name == "speculation" {
return true
}
match name {
"browsingContext.contextCreated" => true
"browsingContext.contextDestroyed" => true
"browsingContext.domContentLoaded" => true
"browsingContext.load" => true
"browsingContext.navigationStarted" => true
"browsingContext.navigationFailed" => true
"browsingContext.navigationAborted" => true
"browsingContext.navigationCommitted" => true
"browsingContext.fragmentNavigated" => true
"browsingContext.historyUpdated" => true
"browsingContext.downloadWillBegin" => true
"browsingContext.downloadEnd" => true
"browsingContext.userPromptOpened" => true
"browsingContext.userPromptClosed" => true
"log.entryAdded" => true
"script.realmCreated" => true
"script.realmDestroyed" => true
"script.message" => true
"network.beforeRequestSent" => true
"network.responseStarted" => true
"network.responseCompleted" => true
"network.fetchError" => true
"network.authRequired" => true
"input.fileDialogOpened" => true
"bluetooth.requestDevicePromptUpdated" => true
"bluetooth.gattConnectionAttempted" => true
"bluetooth.characteristicEventGenerated" => true
"bluetooth.descriptorEventGenerated" => true
"speculation.prefetchStatusUpdated" => true
_ => false
}
}
///|
/// Validate 32-char hex subscription id format.
fn is_valid_subscription_id_format(subscription_id : String) -> Bool {
if subscription_id.length() != 32 {
return false
}
for c in subscription_id.iter() {
if !((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F')) {
return false
}
}
true
}