Auto merge of #8359 - ben0x539:js-url-query-fragment, r=eefriedman

Append query string + fragment to javascript: url.

When loading a URL whose scheme is javascript, we should do what
https://html.spec.whatwg.org/multipage/browsers.html#javascript-protocol
says and append the URL's query and fragment components to the scheme
data, as well as percent- and utf-8-decode the whole thing, before
evaluating it as javascript.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8359)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-07 04:03:35 +05:30
commit 33bbed7dc1
4 changed files with 69 additions and 3 deletions

View file

@ -29809,7 +29809,16 @@
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html": [
{
"path": "html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-query-fragment-components.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {

View file

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

View file

@ -0,0 +1,28 @@
<!doctype html>
<title> javascript url with query and fragment components </title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var a = null;
var b = null;
var c = null;
</script>
<iframe id="a" src='javascript:"nope" ? "yep" : "what";'></iframe>
<iframe id="b" src='javascript:"wrong"; // # %0a "ok";'></iframe>
<iframe id="c" src='javascript:"%252525 ? %252525 # %252525"'></iframe>
<script>
var t = async_test("iframes with javascript src", {timeout:1000});
function check(id, expected) {
assert_equals(
document.getElementById(id).contentDocument.body.textContent,
expected);
}
onload = t.step_func(function() {
check("a", "yep");
check("b", "ok");
check("c", "%2525 ? %2525 # %2525");
t.done();
});
</script>