mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
devtools: Fix source contents tests and fix a race (#38359)
test_sources_list() relied on <https://servo.org/js/load-table.js> to test scripts loaded from multiple origins, but that file was deleted a couple of weeks ago. this patch adds a second internal web server, then replaces that load with scripts loaded from two distinct origins: <http://127.0.0.1:10000> and <http://127.0.0.1:10001>. fixing that test revealed an impl bug where inline module scripts containing `import` statements may never get their source contents populated. this is because the logic for populating source contents for inline scripts only applied to source actors created *before* we finished parsing the page. we assumed that inline scripts always block the parser, but this is not the case. this patch ensures that inline source contents can be populated for source actors created after parse. Testing: adds a new test, test_source_content_with_inline_module_import_external() Fixes: part of #36325 Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
parent
900dd8d191
commit
a671c50bc9
3 changed files with 35 additions and 1 deletions
|
@ -84,6 +84,8 @@ pub struct ActorRegistry {
|
|||
|
||||
/// Lookup table for SourceActor names associated with a given PipelineId.
|
||||
source_actor_names: RefCell<HashMap<PipelineId, Vec<String>>>,
|
||||
/// Lookup table for inline source content associated with a given PipelineId.
|
||||
inline_source_content: RefCell<HashMap<PipelineId, String>>,
|
||||
|
||||
shareable: Option<Arc<Mutex<ActorRegistry>>>,
|
||||
next: Cell<u32>,
|
||||
|
@ -99,6 +101,7 @@ impl ActorRegistry {
|
|||
old_actors: RefCell::new(vec![]),
|
||||
script_actors: RefCell::new(HashMap::new()),
|
||||
source_actor_names: RefCell::new(HashMap::new()),
|
||||
inline_source_content: RefCell::new(HashMap::new()),
|
||||
shareable: None,
|
||||
next: Cell::new(0),
|
||||
start_stamp: CrossProcessInstant::now(),
|
||||
|
@ -262,4 +265,20 @@ impl ActorRegistry {
|
|||
|
||||
vec![]
|
||||
}
|
||||
|
||||
pub fn set_inline_source_content(&mut self, pipeline_id: PipelineId, content: String) {
|
||||
assert!(
|
||||
self.inline_source_content
|
||||
.borrow_mut()
|
||||
.insert(pipeline_id, content)
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
pub fn inline_source_content(&mut self, pipeline_id: PipelineId) -> Option<String> {
|
||||
self.inline_source_content
|
||||
.borrow()
|
||||
.get(&pipeline_id)
|
||||
.cloned()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue