Bug 1093028 - Imports should block DOMContentLoaded of the parent. r=mrbkap

This commit is contained in:
Gabor Krizsanits 2014-11-05 14:01:51 +01:00
parent 8af0d066b0
commit 7e993d103f
7 changed files with 89 additions and 0 deletions

View File

@ -149,6 +149,7 @@ ImportLoader::Updater::UpdateMainReferrer(uint32_t aNewIdx)
// Our import parent is changed, let's block the new one and later unblock
// the old one.
newMainReferrer->OwnerDoc()->ScriptLoader()->AddExecuteBlocker();
newMainReferrer->OwnerDoc()->BlockDOMContentLoaded();
}
if (mLoader->mDocument) {
@ -168,6 +169,7 @@ ImportLoader::Updater::UpdateMainReferrer(uint32_t aNewIdx)
if (mLoader->IsBlocking()) {
mLoader->mImportParent->ScriptLoader()->RemoveExecuteBlocker();
mLoader->mImportParent->UnblockDOMContentLoaded();
}
// Finally update mMainReferrer to point to the newly added link.
@ -300,6 +302,7 @@ ImportLoader::BlockScripts()
{
MOZ_ASSERT(!mBlockingScripts);
mImportParent->ScriptLoader()->AddExecuteBlocker();
mImportParent->BlockDOMContentLoaded();
mBlockingScripts = true;
}
@ -308,6 +311,7 @@ ImportLoader::UnblockScripts()
{
MOZ_ASSERT(mBlockingScripts);
mImportParent->ScriptLoader()->RemoveExecuteBlocker();
mImportParent->UnblockDOMContentLoaded();
for (uint32_t i = 0; i < mBlockedScriptLoaders.Length(); i++) {
mBlockedScriptLoaders[i]->RemoveExecuteBlocker();
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script>
order.push("AS0");
</script>
<link rel="import" href="file_blocking_DOMContentLoaded_B.html" onload="loaded()" onerror="failed()"></link>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script>
order.push("BS0");
</script>
<link rel="import" href="file_blocking_DOMContentLoaded_C.html" onload="loaded()" onerror="failed()"></link>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script>
order.push("CS0");
</script>
<link rel="import" href="file_blocking_DOMContentLoaded_D.html" onload="loaded()" onerror="failed()"></link>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script>
order.push("DS0");
</script>
</head>
<body>
</body>
</html>

View File

@ -33,6 +33,10 @@ support-files =
file_cycle_4_E.html
file_encoding.html
file_simple_import.html
file_blocking_DOMContentLoaded_A.html
file_blocking_DOMContentLoaded_B.html
file_blocking_DOMContentLoaded_C.html
file_blocking_DOMContentLoaded_D.html
[test_cycle_1.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
@ -42,5 +46,7 @@ skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_cycle_4.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_blocking_DOMContentLoaded.html]
skip-if = toolkit == 'gonk' # nested imports fail on b2g emulator
[test_encoding.html]
[test_defaultView.html]

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1093028
-->
<head>
<title>Test for Bug 1093028</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1093028">Mozilla Bug 1093028</a>
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var counter = 0;
var fcounter = 0;
var order = [];
function loaded() {
counter++;
}
function failed() {
fcounter++;
}
</script>
<link rel="import" href="file_blocking_DOMContentLoaded_A.html" onload="loaded()" onerror="failed()"></link>
<script type="text/javascript">
is(counter, 4, "Imports are loaded");
is(fcounter, 0, "No error in imports");
var expected = ["AS0","BS0","CS0","DS0"];
for (i in expected)
is(order[i], expected[i], "import " + i + " should be " + expected[i]);
SimpleTest.finish();
</script>
</body>
</html>