2012-01-22 12:46:55 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=720157
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 720157</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="browserFrameHelpers.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=720157">Mozilla Bug 720157</a>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
Test that data: URIs work with mozbrowserlocationchange events.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
browserFrameHelpers.setEnabledPref(true);
|
|
|
|
browserFrameHelpers.addToWhitelist();
|
|
|
|
|
2012-01-26 15:03:22 -08:00
|
|
|
var iframe1 = document.createElement('iframe');
|
|
|
|
document.body.appendChild(iframe1);
|
|
|
|
iframe1.id = 'iframe1';
|
|
|
|
iframe1.addEventListener('load', function() {
|
|
|
|
iframe1.removeEventListener('load', arguments.callee);
|
|
|
|
SimpleTest.executeSoon(runTest2);
|
|
|
|
});
|
|
|
|
iframe1.src = 'http://example.org';
|
|
|
|
}
|
|
|
|
|
|
|
|
function runTest2() {
|
|
|
|
var iframe1 = document.getElementById('iframe1');
|
|
|
|
iframe1.mozbrowser = true;
|
|
|
|
|
|
|
|
var iframe2 = document.getElementById('iframe2');
|
|
|
|
|
2012-01-22 12:46:55 -08:00
|
|
|
var sawLoad = false;
|
|
|
|
var sawLocationChange = false;
|
|
|
|
|
2012-01-26 15:03:22 -08:00
|
|
|
iframe1.addEventListener('mozbrowserlocationchange', function(e) {
|
2012-01-22 12:46:55 -08:00
|
|
|
ok(!sawLocationChange, 'Just one locationchange event.');
|
|
|
|
ok(!sawLoad, 'locationchange before load.');
|
|
|
|
is(e.detail, 'data:text/html,1', "event's reported location");
|
|
|
|
sawLocationChange = true;
|
|
|
|
});
|
|
|
|
|
2012-01-26 15:03:22 -08:00
|
|
|
iframe1.addEventListener('load', function() {
|
2012-01-22 12:46:55 -08:00
|
|
|
ok(sawLocationChange, 'Load after locationchange.');
|
|
|
|
ok(!sawLoad, 'Just one load event.');
|
|
|
|
sawLoad = true;
|
|
|
|
});
|
|
|
|
|
2012-01-26 15:03:22 -08:00
|
|
|
function iframe2Load() {
|
|
|
|
if (!sawLoad || !sawLocationChange) {
|
|
|
|
// Spin if iframe1 hasn't loaded yet.
|
|
|
|
SimpleTest.executeSoon(iframe2Load);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(true, 'Got iframe2 load.');
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
iframe2.addEventListener('load', iframe2Load);
|
|
|
|
|
|
|
|
|
|
|
|
iframe1.src = 'data:text/html,1';
|
|
|
|
|
|
|
|
// Load something into iframe2 to check that it doesn't trigger a
|
|
|
|
// locationchange for our iframe1 listener.
|
|
|
|
iframe2.src = 'http://example.com';
|
2012-01-22 12:46:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2012-01-26 15:03:22 -08:00
|
|
|
<iframe id='iframe2'></iframe>
|
2012-01-22 12:46:55 -08:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|