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 | /* Any copyright is dedicated to the public domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Bug 763694 - Test that <iframe mozbrowser> delivers proper |
michael@0 | 5 | // mozbrowsersecuritychange events. |
michael@0 | 6 | |
michael@0 | 7 | "use strict"; |
michael@0 | 8 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 9 | browserElementTestHelpers.setEnabledPref(true); |
michael@0 | 10 | browserElementTestHelpers.addPermission(); |
michael@0 | 11 | |
michael@0 | 12 | function runTest() { |
michael@0 | 13 | var iframe = document.createElement('iframe'); |
michael@0 | 14 | SpecialPowers.wrap(iframe).mozbrowser = true; |
michael@0 | 15 | |
michael@0 | 16 | var lastSecurityState; |
michael@0 | 17 | iframe.addEventListener('mozbrowsersecuritychange', function(e) { |
michael@0 | 18 | lastSecurityState = e.detail; |
michael@0 | 19 | }); |
michael@0 | 20 | |
michael@0 | 21 | var filepath = 'tests/dom/browser-element/mochitest/file_browserElement_SecurityChange.html'; |
michael@0 | 22 | |
michael@0 | 23 | var count = 0; |
michael@0 | 24 | iframe.addEventListener('mozbrowserloadend', function(e) { |
michael@0 | 25 | count++; |
michael@0 | 26 | var nextURL; |
michael@0 | 27 | switch (count) { |
michael@0 | 28 | case 1: |
michael@0 | 29 | is(lastSecurityState.state, 'secure'); |
michael@0 | 30 | is(lastSecurityState.extendedValidation, false); |
michael@0 | 31 | iframe.src = "http://example.com/" + filepath; |
michael@0 | 32 | break; |
michael@0 | 33 | case 2: |
michael@0 | 34 | is(lastSecurityState.state, 'insecure'); |
michael@0 | 35 | is(lastSecurityState.extendedValidation, false); |
michael@0 | 36 | iframe.src = 'https://example.com:443/' + filepath + '?broken'; |
michael@0 | 37 | break; |
michael@0 | 38 | case 3: |
michael@0 | 39 | is(lastSecurityState.state, 'broken'); |
michael@0 | 40 | is(lastSecurityState.extendedValidation, false); |
michael@0 | 41 | SimpleTest.finish(); |
michael@0 | 42 | } |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | iframe.src = "https://example.com/" + filepath; |
michael@0 | 46 | document.body.appendChild(iframe); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | addEventListener('testready', runTest); |