Bug 763694 - Part 2: Tests for securityChange event on <iframe mozbrowser>. r=smaug

--HG--
extra : rebase_source : a3b967e3e5b1d73bef86dbb36757cab10d5725ce
This commit is contained in:
Justin Lebar 2012-06-20 01:08:56 -04:00
Родитель ed4acfea02
Коммит f3de6f8577
6 изменённых файлов: 97 добавлений и 0 удалений

Просмотреть файл

@ -17,6 +17,7 @@ include $(topsrcdir)/config/rules.mk
# process. Default is OOP. # process. Default is OOP.
_TEST_FILES = \ _TEST_FILES = \
file_empty_script.js \
file_empty.html \ file_empty.html \
file_focus.html \ file_focus.html \
browserElementTestHelpers.js \ browserElementTestHelpers.js \
@ -54,6 +55,9 @@ _TEST_FILES = \
browserElement_OpenWindowRejected.js \ browserElement_OpenWindowRejected.js \
test_browserElement_inproc_OpenWindowRejected.html \ test_browserElement_inproc_OpenWindowRejected.html \
file_browserElement_OpenWindowRejected.html \ file_browserElement_OpenWindowRejected.html \
browserElement_SecurityChange.js \
test_browserElement_inproc_SecurityChange.html \
file_browserElement_SecurityChange.html \
$(NULL) $(NULL)
# OOP tests don't work on Windows (bug 763081). # OOP tests don't work on Windows (bug 763081).
@ -73,6 +77,7 @@ _TEST_FILES += \
test_browserElement_oop_Close.html \ test_browserElement_oop_Close.html \
test_browserElement_oop_OpenWindow.html \ test_browserElement_oop_OpenWindow.html \
test_browserElement_oop_OpenWindowRejected.html \ test_browserElement_oop_OpenWindowRejected.html \
test_browserElement_oop_SecurityChange.html \
$(NULL) $(NULL)
endif endif

Просмотреть файл

@ -0,0 +1,50 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 763694 - Test that <iframe mozbrowser> delivers proper
// mozbrowsersecuritychange events.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
var lastSecurityState;
iframe.addEventListener('mozbrowsersecuritychange', function(e) {
lastSecurityState = e.detail;
});
var filepath = 'tests/dom/browser-element/mochitest/file_browserElement_SecurityChange.html';
var count = 0;
iframe.addEventListener('mozbrowserloadend', function(e) {
count++;
var nextURL;
switch (count) {
case 1:
is(lastSecurityState.state, 'secure');
is(lastSecurityState.extendedValidation, false);
iframe.src = "http://example.com/" + filepath;
break;
case 2:
is(lastSecurityState.state, 'insecure');
is(lastSecurityState.extendedValidation, false);
iframe.src = 'https://example.com:443/' + filepath + '?broken';
break;
case 3:
is(lastSecurityState.state, 'broken');
is(lastSecurityState.extendedValidation, false);
SimpleTest.finish();
}
});
iframe.src = "https://example.com/" + filepath;
document.body.appendChild(iframe);
}
runTest();

Просмотреть файл

@ -0,0 +1,16 @@
<html>
<head>
<script>
if (location.search == '?broken') {
// Load something non-https.
var s = document.createElement('script');
s.src = 'http://example.com/dom/browser-element/mochitest/file_empty_script.js';
document.head.appendChild(s);
}
</script>
</head>
<body>
file_browserElement_SecurityChange.html.
</body>
</html>

Просмотреть файл

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_SecurityChange.js">
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_SecurityChange.js">
</script>
</body>
</html>