Don't crash when importing a 404

Now we have a test for this case.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/682913002
This commit is contained in:
Adam Barth 2014-10-27 17:22:55 -07:00
parent de93d90cda
commit c198c32164
4 changed files with 18 additions and 3 deletions

View File

@ -353,7 +353,10 @@ void ScriptController::executeModuleScript(Document& document, const String& sou
String name = link->as();
if (!name.isEmpty()) {
module.formalDependenciesAndSource.append(v8String(m_isolate, name));
module.resolvedDependencies.append(child->document() ? child->document()->exports().v8Value() : v8Undefined());
v8::Handle<v8::Value> actual = v8::Undefined(m_isolate);
if (child->document())
actual = child->document()->exports().v8Value();
module.resolvedDependencies.append(actual);
}
}
}

View File

@ -121,8 +121,10 @@ void HTMLImportLoader::setState(State state)
m_state = state;
if (m_state == StateParsed || m_state == StateError || m_state == StateWritten)
m_document->cancelParsing();
if (m_state == StateParsed || m_state == StateError || m_state == StateWritten) {
if (m_document)
m_document->cancelParsing();
}
// Since DocumentWriter::end() can let setState() reenter, we shouldn't refer to m_state here.
if (state == StateLoaded || state == StateError)

View File

@ -0,0 +1 @@
PASS

View File

@ -0,0 +1,9 @@
<html>
<link rel="import" href="resources/does-not-exist.html" as="hello" />
<link rel="import" href="../resources/dump-as-text.html" />
<div id="result">FAIL - Script did not execute</div>
<script>
document.getElementById("result").textContent =
hello === undefined ? "PASS" : "FAIL";
</script>
</html>