Repository navigation
Conversation
Signed-off-by: Uthman Yahaya Baba <[email protected]>
|
🔨 Triggering try run (#15062622412) for Linux (WPT) |
|
Test results for linux-wpt from try job (#15062622412): Flaky unexpected result (19)
Stable unexpected results that are known to be intermittent (19)
Stable unexpected results (187)
|
|
|
|
Oof! We're going to need to figure out what's now going wrong with font loads that are supposed to work. |
| .credentials_mode(CredentialsMode::CredentialsSameOrigin) | ||
| .service_workers_mode(ServiceWorkersMode::All) |
There was a problem hiding this comment.
If these are the default values, maybe they don't need to be set explicitly here?
| ) | ||
| .expect("Parsing shouldn't fail as descriptors are valid by construction"); | ||
|
|
||
| //Construct a WebFontDocumentContext object for the current document. |
There was a problem hiding this comment.
Nit:
| //Construct a WebFontDocumentContext object for the current document. | |
| // Construct a WebFontDocumentContext object for the current document. |
| let document_context = WebFontDocumentContext { | ||
| policy_container: global.policy_container(), | ||
| document_url: global.api_base_url(), | ||
| has_trustworthy_ancestor_origin: global.has_trustworthy_ancestor_origin(), | ||
| insecure_requests_policy: global.insecure_requests_policy(), | ||
| }; |
There was a problem hiding this comment.
Since this struct is only applicable on Window currently, perhaps it would be useful to create a helper in Window which makes this data structure.
| //Construct a new document context for the reflow. | ||
| let document_context = WebFontDocumentContext { | ||
| policy_container: self.global().policy_container(), | ||
| document_url: self.global().api_base_url(), | ||
| has_trustworthy_ancestor_origin: self.global().has_trustworthy_ancestor_origin(), | ||
| insecure_requests_policy: self.global().insecure_requests_policy(), | ||
| }; |
There was a problem hiding this comment.
The helper could be used here as well.
There was a problem hiding this comment.
Thank you for the recommendations
Signed-off-by: Uthman Yahaya Baba <[email protected]>
#37021 exposed that our tests are trying to load a local file path for Ahem.ttf, but this stops working when we implement the specified CORS protections for our font requests. Luckily, the WPT suite already provides a same-origin version of the same font, so we can just update our CSS to use that font face instead. Testing: Existing WPT coverage. Signed-off-by: Josh Matthews <[email protected]>
Signed-off-by: Uthman Yahaya Baba <[email protected]>
|
🔨 Triggering try run (#15368876501) for Linux (WPT) |
|
Test results for linux-wpt from try job (#15368876501): Flaky unexpected result (25)
Stable unexpected results that are known to be intermittent (23)
|
|
✨ Try run (#15368876501) succeeded. |
jdm
left a comment
There was a problem hiding this comment.
Great work! This is almost ready to merge!
| pub fn new_document_context(&self) -> WebFontDocumentContext { | ||
| WebFontDocumentContext { | ||
| policy_container: self.global().policy_container(), | ||
| document_url: self.global().api_base_url(), | ||
| has_trustworthy_ancestor_origin: self.global().has_trustworthy_ancestor_origin(), | ||
| insecure_requests_policy: self.global().insecure_requests_policy(), | ||
| } | ||
| } |
There was a problem hiding this comment.
| pub fn new_document_context(&self) -> WebFontDocumentContext { | |
| WebFontDocumentContext { | |
| policy_container: self.global().policy_container(), | |
| document_url: self.global().api_base_url(), | |
| has_trustworthy_ancestor_origin: self.global().has_trustworthy_ancestor_origin(), | |
| insecure_requests_policy: self.global().insecure_requests_policy(), | |
| } | |
| } | |
| pub(crate) fn web_font_context(&self) -> WebFontDocumentContext { | |
| let global = self.upcast::<GlobalScope>(); | |
| WebFontDocumentContext { | |
| policy_container: global.policy_container(), | |
| document_url: global.api_base_url(), | |
| has_trustworthy_ancestor_origin: global.has_trustworthy_ancestor_origin(), | |
| insecure_requests_policy: global.insecure_requests_policy(), | |
| } | |
| } |
| #[derive(Clone, Debug)] | ||
| pub struct WebFontDocumentContext { |
There was a problem hiding this comment.
| #[derive(Clone, Debug)] | |
| pub struct WebFontDocumentContext { | |
| /// Document-specific data required to fetch a web font. | |
| #[derive(Clone, Debug)] | |
| pub struct WebFontDocumentContext { |
|
|
||
| # direnv | ||
| .envrc | ||
| tests/wpt/web-platform-tests/ |
| ) | ||
| .expect("Parsing shouldn't fail as descriptors are valid by construction"); | ||
|
|
||
| // Construct a WebFontDocumentContext object for the current document. |
There was a problem hiding this comment.
I don't think this comment (and the similar ones in the rest of the PR) give readers any new information. Let's remove them.
#37021 exposed that our tests are trying to load a local file path for Ahem.ttf, but this stops working when we implement the specified CORS protections for our font requests. Luckily, the WPT suite already provides a same-origin version of the same font, so we can just update our CSS to use that font face instead. Testing: Existing WPT coverage. Signed-off-by: Josh Matthews <[email protected]>
|
@uthmaniv Thanks for the work up to this point! We would like to continue working on this, as it is a useful addition to our font context loader. Are you planning to continue on this or shall we ask somebody else to do so? Thanks in advance for your reply! |
|
Rebased in #40301. |
Rebase of #37021 with review comments applied. These changes bundle up the required information from the relevant global when a stylesheet is added so that any requests for web fonts match the specification. Testing: Newly passing tests. Fixes: #36590 --------- Signed-off-by: Uthman Yahaya Baba <[email protected]> Signed-off-by: Josh Matthews <[email protected]> Co-authored-by: Uthman Yahaya Baba <[email protected]>
Implements font fetching requirements for CSS Fonts 4 spec by introducing WebFontDocumentContext.
WebFontDocumentContextincomponents/fonts/font_context.rswith fields for policy container, document URL, trustworthy ancestor origin, and insecure requests policy;.WebFontDocumentContextas an argument toFontContextWebFontMethods::add_all_web_fonts_from_stylesheet,FontContextWebFontMethods::load_web_font_for_script, andFontContext::start_loading_one_web_fontinfont_context.rs.WebFontDocumentContextinWebFontDownloadStateand updatesRequestBuilderfields using its values and CSS Fonts 4 constants.WebFontDocumentContexttoReflowRequestinforce_reflow(window.rs), constructed withself.global().Layouttrait inscript_layout/lib.rsto include&WebFontDocumentContextinadd_stylesheetandload_web_fonts_from_stylesheet.document.rsto constructWebFontDocumentContextusingself.window.global()foradd_stylesheetandload_web_fonts_from_stylesheetcalls.layout_thread.rsto usereflow_request.document_contextinhandle_reflowforload_all_web_fonts_from_stylesheet_with_guard.referrer-policy/css-integration/font-face(removed.inias tests pass) andcontent-security-policy/font-src.Testing:
-Ran WPT tests:
./mach test-wpt --release tests/wpt/tests/referrer-policy/css-integration/font-face tests/wpt/tests/content-security-policy/font-src./mach update-wpt, confirming tests passFixes: Web font requests are missing many settings #36590