summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/bugs/test_bug377539.html
blob: 37b3041d914c1a46796d25321a67ad88b7d46bb5 (plain)
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
53
54
55
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=377539
-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Testcase for bug 377539</title>

  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=377539">Mozilla Bug 377539</a>

<p id="display"></p>
<div id="content" style="display: none">

</div>

<script type="text/javascript">
var sw;
var child_sw = -1;

function test(){
        var t = '<div style="display: none;"><iframe onload="doChecks()" src="data:text/html,<body><scr'+'ipt>try {parent.child_sw=screen.width}catch(e){}</scr'+'ipt>"></iframe></div>';
        var div = document.createElement('div');
        div.innerHTML = t;
        document.getElementsByTagName('body')[0].appendChild(div);
}

try {
  sw = screen.width;
} catch (e) {
  sw = -1;
}

</script>

<pre id="test">
<script class="testbody" type="text/javascript">
function doChecks() {
  isnot(sw, -1, "screen.width threw an exception");
  is(child_sw, sw, "iframe got wrong screen.width");
  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();

test();

</script>
</pre>
</body>
</html>