Fix broken unit-test of webview (#36238)

This PR fixes the broken unit-test after
[#35662](https://github.com/servo/servo/pull/35662)

Testing: Verified locally and CI confirms too.
Fixes: Migrate the test to use new API

cc: @xiaochengh

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
This commit is contained in:
Shubham Gupta 2025-04-02 18:00:24 +08:00 committed by GitHub
parent 4402b7cf8f
commit 520a7f7bc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 9 deletions

View file

@ -946,7 +946,7 @@ mod test {
BrowsingContextId, BrowsingContextIndex, PipelineNamespace, PipelineNamespaceId, WebViewId,
};
use crate::webview::{UnknownWebView, WebViewAlreadyExists, WebViewManager};
use crate::webview::{UnknownWebView, WebViewManager};
fn top_level_id(namespace_id: u32, index: u32) -> WebViewId {
WebViewId(BrowsingContextId {
@ -970,10 +970,13 @@ mod test {
PipelineNamespace::install(PipelineNamespaceId(0));
let mut webviews = WebViewManager::default();
// add() adds the webview to the map, but not the painting order.
assert!(webviews.add(WebViewId::new(), 'a').is_ok());
assert!(webviews.add(WebViewId::new(), 'b').is_ok());
assert!(webviews.add(WebViewId::new(), 'c').is_ok());
// entry() adds the webview to the map, but not the painting order.
webviews.entry(WebViewId::new()).or_insert('a');
webviews.entry(WebViewId::new()).or_insert('b');
webviews.entry(WebViewId::new()).or_insert('c');
assert!(webviews.get(top_level_id(0, 1)).is_some());
assert!(webviews.get(top_level_id(0, 2)).is_some());
assert!(webviews.get(top_level_id(0, 3)).is_some());
assert_eq!(
webviews_sorted(&webviews),
vec![
@ -985,10 +988,8 @@ mod test {
assert!(webviews.painting_order.is_empty());
// add() returns WebViewAlreadyExists if the webview id already exists.
assert_eq!(
webviews.add(top_level_id(0, 3), 'd'),
Err(WebViewAlreadyExists(top_level_id(0, 3)))
);
webviews.entry(top_level_id(0, 3)).or_insert('d');
assert!(webviews.get(top_level_id(0, 3)).is_some());
// Other methods return UnknownWebView or None if the webview id doesnt exist.
assert_eq!(

View file

@ -162,6 +162,7 @@ class MachCommands(CommandBase):
self_contained_tests = [
"background_hang_monitor",
"base",
"compositing",
"constellation",
"devtools",
"fonts",