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:
bors-servo 2017-09-09 04:39:43 -05:00 committed by GitHub
commit 40c8a6389a
17 changed files with 154 additions and 93 deletions

View file

@ -326433,6 +326433,12 @@
{}
]
],
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-global-scope.html": [
[
"/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-global-scope.html",
{}
]
],
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html": [
[
"/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html",
@ -559898,6 +559904,10 @@
"3842ac825b9fb33d0d95ef99f77c8c7d02a88e9a",
"support"
],
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-global-scope.html": [
"d678c54e2c20d5f240fd68790ea4e03512db2c8a",
"testharness"
],
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html": [
"1278f37be250f761f84bf352ebff8ed4c8a04e96",
"testharness"

View file

@ -1,6 +1,5 @@
[open-url-javascript-window-2.htm]
type: testharness
expected: TIMEOUT
[XMLHttpRequest: open() - resolving URLs (javascript: <iframe>; 2)]
expected: TIMEOUT
expected: FAIL

View file

@ -1,6 +0,0 @@
[open-url-javascript-window.htm]
type: testharness
expected: TIMEOUT
[XMLHttpRequest: open() - resolving URLs (javascript: <iframe>; 1)]
expected: TIMEOUT

View file

@ -1,5 +0,0 @@
[contenttype_javascripturi.html]
type: testharness
[Javascript URI document.contentType === 'text/html']
expected: FAIL

View file

@ -1,5 +0,0 @@
[013.html]
type: testharness
[Link with onclick navigation to javascript url with delayed document.write and href navigation ]
expected: FAIL

View file

@ -1,5 +0,0 @@
[014.html]
type: testharness
[ Link with javascript onclick form submission script order ]
expected: FAIL

View file

@ -1,5 +0,0 @@
[015.html]
type: testharness
[ Link with javascript onclick and href script order ]
expected: FAIL

View file

@ -1,5 +0,0 @@
[javascript-url-query-fragment-components.html]
type: testharness
[iframes with javascript src]
expected: FAIL

View file

@ -7,6 +7,3 @@
[Script script-svg]
expected: NOTRUN
[Script iframe-src]
expected: NOTRUN

View file

@ -1,5 +0,0 @@
[028.html]
type: testharness
[ scheduler: javascript: URL]
expected: FAIL

View file

@ -1,5 +0,0 @@
[029.html]
type: testharness
[ scheduler: javascript: URL in HREF]
expected: FAIL

View file

@ -0,0 +1,16 @@
<!doctype html>
<meta charset=utf-8>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<a id="javascript-link" href="javascript:changeStatus()">link</a>
<script>
function changeStatus() {
t.done();
}
var t = async_test(function(t) {
document.querySelector("#javascript-link").click();
}, "javascript: scheme urls should be executed in current global scope");
</script>