Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=946067 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 946067</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | <script type="application/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | /** Test for Bug 946067 **/ |
michael@0 | 14 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 15 | |
michael@0 | 16 | function doGet(prop, thisObj) { |
michael@0 | 17 | return Object.getOwnPropertyDescriptor(window, prop).get.call(thisObj); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | function doSet(prop, thisObj, value) { |
michael@0 | 21 | return Object.getOwnPropertyDescriptor(window, prop).set.call(thisObj, value); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | window.onload = function() { |
michael@0 | 25 | frames[0].focus(); |
michael@0 | 26 | is(document.activeElement.id, "x", "Should have focused first subframe"); |
michael@0 | 27 | frames[0].blur(); |
michael@0 | 28 | window.focus.call(frames[1]); |
michael@0 | 29 | is(document.activeElement.id, "y", "Should have focused second subframe"); |
michael@0 | 30 | window.blur.call(frames[1]); |
michael@0 | 31 | |
michael@0 | 32 | frames[0].close(); |
michael@0 | 33 | is(frames[0].closed, false, "Subframe is not closed"); |
michael@0 | 34 | window.close.call(frames[0]); |
michael@0 | 35 | is(doGet("closed", frames[0]), false, "Subframe is still not closed"); |
michael@0 | 36 | |
michael@0 | 37 | is(frames[0].frames, frames[0], "window.frames === window"); |
michael@0 | 38 | is(doGet("frames", frames[0]), frames[0], |
michael@0 | 39 | "Really, window.frames === window"); |
michael@0 | 40 | |
michael@0 | 41 | try { |
michael@0 | 42 | frames[0].frames = 1; |
michael@0 | 43 | ok(false, "Should throw when setting .frames"); |
michael@0 | 44 | } catch (e) { |
michael@0 | 45 | ok(true, "Should throw when setting .frames"); |
michael@0 | 46 | } |
michael@0 | 47 | try { |
michael@0 | 48 | doSet("frames", frames[0], 1); |
michael@0 | 49 | ok(false, "Should still throw when setting .frames"); |
michael@0 | 50 | } catch (e) { |
michael@0 | 51 | ok(true, "Should still throw when setting .frames"); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | // Just check whether we can get the location without throwing: |
michael@0 | 55 | is(frames[0].location, doGet("location", frames[0]), |
michael@0 | 56 | "Should be same Location object"); |
michael@0 | 57 | |
michael@0 | 58 | is(frames[0].length, 0, "404 page has no subframes"); |
michael@0 | 59 | is(doGet("length", frames[0]), 0, "404 page has no subframes"); |
michael@0 | 60 | |
michael@0 | 61 | is(frames[0].opener, null, "subframe has no opener"); |
michael@0 | 62 | is(doGet("opener", frames[0]), null, "subframe still has no opener"); |
michael@0 | 63 | |
michael@0 | 64 | is(frames[0].parent, window, "subframe has us as parent"); |
michael@0 | 65 | is(doGet("parent", frames[0]), window, "subframe still has us as parent"); |
michael@0 | 66 | |
michael@0 | 67 | // Check that postMessage doesn't throw |
michael@0 | 68 | frames[0].postMessage(null, "*"); |
michael@0 | 69 | |
michael@0 | 70 | is(frames[0].self, frames[0], "self should work"); |
michael@0 | 71 | is(doGet("self", frames[0]), frames[0], "self should still work"); |
michael@0 | 72 | |
michael@0 | 73 | is(frames[0].top, window.top, "Our subframe's top should be our top"); |
michael@0 | 74 | is(doGet("top", frames[0]), window.top, |
michael@0 | 75 | "Our subframe's top should still be our top"); |
michael@0 | 76 | |
michael@0 | 77 | is(frames[0].window, frames[0], "window getter should work"); |
michael@0 | 78 | // "window" is not a getter property yet |
michael@0 | 79 | //is(doGet("window", frames[0]), frames[0], "window getter should still work"); |
michael@0 | 80 | todo_isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined, |
michael@0 | 81 | "Should have a getter here"); |
michael@0 | 82 | |
michael@0 | 83 | // Finally, check that we can set the location |
michael@0 | 84 | frames[0].location = "about:blank"; |
michael@0 | 85 | doSet("location", frames[1], "about:blank"); |
michael@0 | 86 | |
michael@0 | 87 | SimpleTest.finish(); |
michael@0 | 88 | } |
michael@0 | 89 | </script> |
michael@0 | 90 | </head> |
michael@0 | 91 | <body> |
michael@0 | 92 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946067">Mozilla Bug 946067</a> |
michael@0 | 93 | <p id="display"></p> |
michael@0 | 94 | <div id="content" style="display: none"> |
michael@0 | 95 | |
michael@0 | 96 | </div> |
michael@0 | 97 | <pre id="test"> |
michael@0 | 98 | <iframe id="x" src="http://www.example.com/nosuchpageIhope"></iframe> |
michael@0 | 99 | <iframe id="y" src="http://www.example.com/nosuchpageIhope"></iframe> |
michael@0 | 100 | </pre> |
michael@0 | 101 | </body> |
michael@0 | 102 | </html> |