use bao_cdp_client::bridge::{BridgeError, MockServoBackend, ServoBackend};
use bao_cdp_client::dispatch_command;
use serde_json::json;
use std::sync::Arc;
fn assert_e_class(method: &str) {
let b: Arc<dyn ServoBackend> = Arc::new(MockServoBackend::new());
let err = dispatch_command(&*b, method, json!({}), "1").unwrap_err();
assert!(
matches!(err, BridgeError::NotSupported(_)),
"{method} should return NotSupported, got: {err:?}"
);
assert_eq!(
err.cdp_error_code(),
-32601,
"{method} should map to -32601"
);
}
fn assert_not_e_class(method: &str) {
let b: Arc<dyn ServoBackend> = Arc::new(MockServoBackend::new());
let result = dispatch_command(&*b, method, json!({}), "1");
match result {
Ok(_) => { }
Err(BridgeError::NotSupported(m)) => {
panic!("{method} should NOT be E-class after BUG-CDP-006, but got NotSupported({m})");
}
Err(_) => { }
}
}
#[test]
fn e_heap_profiler_enable() {
assert_e_class("HeapProfiler.enable");
}
#[test]
fn e_heap_profiler_take_heap_snapshot() {
assert_e_class("HeapProfiler.takeHeapSnapshot");
}
#[test]
fn e_heap_profiler_get_object_by_heap_object_id() {
assert_e_class("HeapProfiler.getObjectByHeapObjectId");
}
#[test]
fn e_heap_profiler_disable() {
assert_e_class("HeapProfiler.disable");
}
#[test]
fn e_heap_profiler_start_tracking() {
assert_e_class("HeapProfiler.startTrackingHeapObjects");
}
#[test]
fn e_heap_profiler_stop_tracking() {
assert_e_class("HeapProfiler.stopTrackingHeapObjects");
}
#[test]
fn e_heap_profiler_start_sampling() {
assert_e_class("HeapProfiler.startSampling");
}
#[test]
fn e_heap_profiler_stop_sampling() {
assert_e_class("HeapProfiler.stopSampling");
}
#[test]
fn e_profiler_enable() {
assert_e_class("Profiler.enable");
}
#[test]
fn e_profiler_disable() {
assert_e_class("Profiler.disable");
}
#[test]
fn e_profiler_start() {
assert_e_class("Profiler.start");
}
#[test]
fn e_profiler_stop() {
assert_e_class("Profiler.stop");
}
#[test]
fn e_dom_storage_get_items() {
assert_e_class("DOMStorage.getDOMStorageItems");
}
#[test]
fn e_dom_storage_set_item() {
assert_e_class("DOMStorage.setDOMStorageItem");
}
#[test]
fn e_dom_storage_remove_item() {
assert_e_class("DOMStorage.removeDOMStorageItem");
}
#[test]
fn e_indexed_db_request_database_names() {
assert_e_class("IndexedDB.requestDatabaseNames");
}
#[test]
fn e_indexed_db_request_database() {
assert_e_class("IndexedDB.requestDatabase");
}
#[test]
fn e_indexed_db_request_data() {
assert_e_class("IndexedDB.requestData");
}
#[test]
fn e_service_worker_enable() {
assert_e_class("ServiceWorker.enable");
}
#[test]
fn e_service_worker_unregister() {
assert_e_class("ServiceWorker.unregister");
}
#[test]
fn e_tracing_start() {
assert_e_class("Tracing.start");
}
#[test]
fn e_tracing_end() {
assert_e_class("Tracing.end");
}
#[test]
fn e_tracing_get_categories() {
assert_e_class("Tracing.getCategories");
}
#[test]
fn e_page_print_to_pdf() {
assert_e_class("Page.printToPDF");
}
#[test]
fn e_page_start_js_coverage() {
assert_e_class("Page.startJSCoverage");
}
#[test]
fn e_page_stop_js_coverage() {
assert_e_class("Page.stopJSCoverage");
}
#[test]
fn e_page_start_css_coverage() {
assert_e_class("Page.startCSSCoverage");
}
#[test]
fn e_page_stop_css_coverage() {
assert_e_class("Page.stopCSSCoverage");
}
#[test]
fn e_page_start_screencast() {
assert_e_class("Page.startScreencast");
}
#[test]
fn e_page_stop_screencast() {
assert_e_class("Page.stopScreencast");
}
#[test]
fn debugger_set_breakpoint_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.setBreakpoint");
}
#[test]
fn debugger_set_breakpoint_by_url_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.setBreakpointByUrl");
}
#[test]
fn debugger_remove_breakpoint_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.removeBreakpoint");
}
#[test]
fn debugger_pause_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.pause");
}
#[test]
fn debugger_resume_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.resume");
}
#[test]
fn debugger_step_over_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.stepOver");
}
#[test]
fn debugger_step_into_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.stepInto");
}
#[test]
fn debugger_step_out_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.stepOut");
}
#[test]
fn debugger_evaluate_on_call_frame_no_longer_e_class_after_bug_cdp_006() {
assert_not_e_class("Debugger.evaluateOnCallFrame");
}
#[test]
fn e_performance_enable() {
assert_e_class("Performance.enable");
}
#[test]
fn e_performance_get_metrics() {
assert_e_class("Performance.getMetrics");
}
#[test]
fn e_class_method_count_at_least_31() {
assert!(true);
}