mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #17083 - danielj41:javascript-url-global-3, r=jdm
"javascript:" urls: execute in correct global scope <!-- Please describe your changes on the following line: --> #### Summary This pull request makes `javascript:` urls execute in the correct global scope. #### Example ```html <script> var x = 4; </script> <!-- this branch: logs "4" --> <!-- master: undefined variable error --> <a href="javascript:console.log(x)">link</a> ``` #### Questions I'm new to servo and rust, so I'm unsure about these changes. In particular: * What's the appropriate place to evaluate the js? * I moved it to `handle_navigate`, but I'm not sure if this will catch all occurrences of `javascript:` urls. I also don't know if this will execute in the correct thread and the correct window. * What should I do with the result of the js evaluation? * I just ignored it. The previous behavior displayed it as the content of a new page load. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15147, #16718 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17083) <!-- Reviewable:end -->
This commit is contained in:
commit
40c8a6389a
17 changed files with 154 additions and 93 deletions
|
@ -146,12 +146,24 @@ pub struct LoadData {
|
|||
pub headers: Headers,
|
||||
/// The data.
|
||||
pub data: Option<Vec<u8>>,
|
||||
/// The result of evaluating a javascript scheme url.
|
||||
pub js_eval_result: Option<JsEvalResult>,
|
||||
/// The referrer policy.
|
||||
pub referrer_policy: Option<ReferrerPolicy>,
|
||||
/// The referrer URL.
|
||||
pub referrer_url: Option<ServoUrl>,
|
||||
}
|
||||
|
||||
/// The result of evaluating a javascript scheme url.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum JsEvalResult {
|
||||
/// The js evaluation had a non-string result, 204 status code.
|
||||
/// https://html.spec.whatwg.org/multipage/#navigate 12.11
|
||||
NoContent,
|
||||
/// The js evaluation had a string result.
|
||||
Ok(Vec<u8>)
|
||||
}
|
||||
|
||||
impl LoadData {
|
||||
/// Create a new `LoadData` object.
|
||||
pub fn new(url: ServoUrl,
|
||||
|
@ -165,6 +177,7 @@ impl LoadData {
|
|||
method: Method::Get,
|
||||
headers: Headers::new(),
|
||||
data: None,
|
||||
js_eval_result: None,
|
||||
referrer_policy: referrer_policy,
|
||||
referrer_url: referrer_url,
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ pub enum ScriptMsg {
|
|||
/// A new load has been requested, with an option to replace the current entry once loaded
|
||||
/// instead of adding a new entry.
|
||||
LoadUrl(LoadData, bool),
|
||||
/// Abort loading after sending a LoadUrl message.
|
||||
AbortLoadUrl,
|
||||
/// Post a message to the currently active window of a given browsing context.
|
||||
PostMessage(BrowsingContextId, Option<ImmutableOrigin>, Vec<u8>),
|
||||
/// Dispatch a mozbrowser event to the parent of a mozbrowser iframe.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue