servo/components/script
atbrakhi c8ee11fe77
DevTools: sources for HTML files should be the whole HTML file (#37456)
To show the contents of inline scripts in the Sources panel, we need to
send the whole HTML file from script to devtools, not just the script
code. This is trickier than the external script case, but we can look to
[how Firefox does
it](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Getting.20the.20original.20page.20HTML.20from.20script/near/524392861)
for some inspiration. The process is as follows:

- when we execute a script
  - notify devtools to create the source actor
- if it’s an external script, send the script code to the devtools
server
  - if it’s an inline script, don’t send any source contents yet
  - devtools stores the contents in the source actor
- while loading a new document
  - buffer the markup, so we can send it to devtools
- when we finish loading a new document
  - send the buffered markup to the devtools server
- devtools stores the contents in any source actors with no contents yet
- when a source actor gets a `source` request
  - if we have the contents, send those contents to the client
- if we don’t have the contents (inline script that loaded while
devtools was closed)
    - FUTURE: try to fetch the markup out of cache
    - otherwise send `<!-- not available; please reload! -->`

Testing: Several tests added to test the changes, also updates an
existing test with correct assertion
Fixes: https://github.com/servo/servo/issues/36874

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-06-21 18:46:35 +00:00
..
docs doc: fix broken link to UnrootedMustRoot plugin (#36198) 2025-03-28 10:23:41 +00:00
dom DevTools: sources for HTML files should be the whole HTML file (#37456) 2025-06-21 18:46:35 +00:00
layout_dom Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
resources Embed user agent stylesheets and media control resouces in libservo (#36803) 2025-05-04 18:48:09 +00:00
svgpath Add Path2D (#35783) 2025-03-26 12:12:44 +00:00
xpath fix(xpath): pass in correct context node for // and / in predicates (#37434) 2025-06-17 18:45:00 +00:00
animation_timeline.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
animations.rs Fix potential clippy warning for NodeDamage enum variant (#37391) 2025-06-11 09:53:15 +00:00
body.rs Consistently use Dom in native promise handlers (#37226) 2025-06-03 07:41:34 +00:00
build.rs script: copy include! files from script_bindings to script's OUT_DIR (#36384) 2025-04-08 19:22:24 +00:00
canvas_context.rs Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
canvas_state.rs pixels: Move Snapshot and related data structures to pixels (#37590) 2025-06-20 14:47:06 +00:00
Cargo.toml Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
clipboard_provider.rs Move ScriptToConstellationMsg to constellation_traits (#36364) 2025-04-05 22:13:29 +00:00
conversions.rs suppress build warnings when disabling webgpu and webxr (#35379) 2025-02-08 08:16:21 +00:00
devtools.rs script: Upgrade node_ids to pipeline_to_node_ids to track the owner pipeline of the node (#37213) 2025-06-02 12:26:45 +00:00
document_collection.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
document_loader.rs script: LoadBlocker's drop impl shouldn't run after termination. (#36508) 2025-04-21 07:17:00 +00:00
drag_data_store.rs Add support for static SVG images using resvg crate (#36721) 2025-05-27 11:02:40 +00:00
fetch.rs Correct event_target for CSP violations (#36887) 2025-05-08 10:46:31 +00:00
iframe_collection.rs Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
image_animation.rs Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
init.rs Make generated bindings generic over DOM types (#35169) 2025-01-25 05:08:49 +00:00
layout_image.rs Correct event_target for CSP violations (#36887) 2025-05-08 10:46:31 +00:00
lib.rs Make the crown disabled warning clearer and less scary (#37535) 2025-06-19 12:44:26 +00:00
links.rs Use version of markup5ever with web_atoms crate (#36542) 2025-04-19 11:49:37 +00:00
messaging.rs compositor: Wait for both Script and the Constellation when shutting down Pipelines (#37505) 2025-06-17 09:56:31 +00:00
microtask.rs Implement MicrotaskRunnable for DefaultTeeReadRequestMicrotask (#37404) 2025-06-12 10:46:31 +00:00
mime.rs Switch to data_url::mime for document content type (#36522) 2025-04-15 17:12:48 +00:00
navigation.rs constellation: Pass system theme to new Pipelines (#37132) 2025-05-26 12:05:38 +00:00
network_listener.rs Propagate CanGc arguments through callers in constructors (#35541) 2025-02-20 16:17:45 +00:00
realms.rs Move generated bindings to script_bindings (#36323) 2025-04-04 06:45:08 +00:00
routed_promise.rs script: add TaskSource argument to route_promise (#36831) 2025-05-04 17:05:27 +00:00
script_module.rs script: complete resolve_module_specifier (#37552) 2025-06-21 06:17:27 +00:00
script_runtime.rs Initial IndexedDB Support (#33044) 2025-06-19 05:19:07 +00:00
script_thread.rs Rename script_layout_interface to layout_api (#37591) 2025-06-20 17:13:05 +00:00
security_manager.rs script: Fix check for document root when targeting CSP events (#37474) 2025-06-15 14:54:41 +00:00
serviceworker_manager.rs Move ScriptToConstellationMsg to constellation_traits (#36364) 2025-04-05 22:13:29 +00:00
stylesheet_loader.rs Use spec compliant content-type extraction in more places and enable a <stylesheet> quirk (#28321) 2025-05-19 11:38:01 +00:00
stylesheet_set.rs script: Limit public exports. (#34915) 2025-01-10 08:19:19 +00:00
task.rs Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00
task_manager.rs Initial IndexedDB Support (#33044) 2025-06-19 05:19:07 +00:00
task_queue.rs Use strum to iterate through enum variants and get their names (#35933) 2025-03-13 12:00:31 +00:00
task_source.rs Initial IndexedDB Support (#33044) 2025-06-19 05:19:07 +00:00
test.rs script: Refactor dom/headers to match spec better (#36943) 2025-05-21 19:07:32 +00:00
textinput.rs Send synthetic keydown/keyup at ime_insert_text (#37175) 2025-05-30 02:06:15 +00:00
timers.rs script: Allow reflows that do not produce display lists (#37186) 2025-06-12 19:25:04 +00:00
unminify.rs Update rustfmt to the 2024 style edition (#35764) 2025-03-03 11:26:53 +00:00
webdriver_handlers.rs [WebDriver] Implement "Find Element(s) From ShadowRoot" (#37578) 2025-06-20 11:54:39 +00:00
window_named_properties.rs Migrate to the 2024 edition (#35755) 2025-03-13 10:28:11 +00:00