File: location-protocol-setter-with-colon.sub.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (52 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (30)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe id="existing" src="resources/post-your-protocol.html?existing"></iframe>
<iframe id="http-and-gunk" src="resources/post-your-protocol.html?http-and-gunk"></iframe>
<!-- iframe id="https-and-gunk" src="resources/post-your-protocol.html?https-and-gunk"></iframe -->
<script>
// NOTE: we do not listen to message events until our load event fires, so we
// only get them for the things we actually care about.
var wrapper_test = async_test("General setup");
var tests = {
  "existing": { test: async_test("Set location.protocol = location.protocol"),
                result: location.protocol },
  "http-and-gunk": { test:  async_test("Set location.protocol to http:gunk"),
                     result: "http:" },
  // We should really test the "https:gunk" case too, and assert that it ends up
  // with a protocol of "https:", but can't.  See comments below for why.
};

function messageListener(e) {
  var data = e.data;
  var id = data.id;
  var t = tests[id].test;
  t.step(function() {
    assert_equals(data.protocol, tests[id].result, "Protocol should match");
  })
  t.done();
}

addEventListener("load", wrapper_test.step_func_done(function() {
  addEventListener("message", messageListener);

  tests["existing"].test.step(function() {
    var loc = document.getElementById("existing").contentWindow.location;
    loc.protocol = loc.protocol;
  });
  tests["http-and-gunk"].test.step(function() {
    var loc = document.getElementById("http-and-gunk").contentWindow.location;
    loc.protocol = "http:gunk";
  });
  // I wish we could test the https bit, but can't figure out a non-racy way to
  // do it, because we need to change both protocol (to https) _and_ port to
  // {{ports[https][0]}} to get a successful load unless we're running on the
  // default http port, but the setter uses the current value, which doesn't get
  // updated sync, as the url to start with for the set.  Oh, and there's no
  // good way to detect when the port set is "done" either.
}));

</script>