Fix: ScriptLoader didn't handle script elements moving gracefully.
Fix: ScriptLoader didn't handle script elements moving gracefully.

ScriptLoader::notifyFinished didn't take into account that dispatchErrorEvent()
can move the HTMLScriptElement to a new Document. In that case, it used to
notify the ScriptRunner of the old Document, not the ScriptRunner of the new
Document.

AFAICS, this problem has been present "forever" (moving scripts is implemented
by https://codereview.chromium.org/496443008/). There was an ASSERT in
ScriptRunner::notifyScriptLoadError which just silently failed (plus maybe
holding the PendingScript alive leaked?). My refactoring (
https://codereview.chromium.org/669603002 ) made this error case more fatal
(since we now do cleanup in ~ScriptRunner) and exposed this bug.

A test will follow in a separate CL. See bug for a reproduction case.

BUG=427108

Review URL: https://codereview.chromium.org/648393004

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@184455 bbb929c8-8fbe-4397-9dbb-9b2b20218538

primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs,primiano/blink-gitcs