| 65 |
|
|
| 66 |
var logIndentLevel = 0; |
var logIndentLevel = 0; |
| 67 |
function log (s) { |
function log (s) { |
| 68 |
|
var indent = ''; |
| 69 |
for (var i = 0; i < logIndentLevel; i++) { |
for (var i = 0; i < logIndentLevel; i++) { |
| 70 |
s = ' ' + s; |
indent += ' '; |
| 71 |
} |
} |
| 72 |
|
s = indent + s.replace (/\n/g, "\n" + indent); |
| 73 |
document.logElement.appendChild (document.createTextNode (s + "\n")); |
document.logElement.appendChild (document.createTextNode (s + "\n")); |
| 74 |
} // log |
} // log |
| 75 |
|
|
| 503 |
// 2.4. If the script element has its "already executed" flag set |
// 2.4. If the script element has its "already executed" flag set |
| 504 |
if (e.manakaiAlreadyExecuted) { |
if (e.manakaiAlreadyExecuted) { |
| 505 |
// 2.5. Abort these steps at this point. |
// 2.5. Abort these steps at this point. |
| 506 |
log ('Running a script: aborted'); |
log ('Running a script: aborted (already executed)'); |
| 507 |
logIndentLevel--; |
logIndentLevel--; |
| 508 |
return e; |
return e; |
| 509 |
} |
} |
| 614 |
doc.write.apply (doc, args); |
doc.write.apply (doc, args); |
| 615 |
return ''; |
return ''; |
| 616 |
}); |
}); |
| 617 |
s = s.replace (/^\s*var\s+s\s*=\s*document\.createElement\s*\(\s*['"]script['"]\s*\)\s*;\s*s\.src\s*=\s*(?:'(javascript:[^']*)'|"(javascript:[^"]*)")\s*;\s*document\.documentElement\.appendChild\s*\(\s*s\s*\)\s*;\s*/, |
var noDocumentElement = false; |
| 618 |
|
s = s.replace (/^\s*var\s+s\s*=\s*document\.createElement\s*\(\s*['"]script['"]\s*\)\s*;\s*s\.src\s*=\s*(?:'([^']*)'|"([^"]*)")\s*;\s*document\.documentElement\.appendChild\s*\(\s*s\s*\)\s*;\s*/, |
| 619 |
function (s, t, u) { |
function (s, t, u) { |
| 620 |
matched = true; |
matched = true; |
| 621 |
var args = [unescapeJSLiteral (t ? t : u)]; |
var args = [unescapeJSLiteral (t ? t : u)]; |
| 622 |
doc._insertExternalScript.apply (doc, args); |
noDocumentElement = !doc._insertExternalScript.apply (doc, args); |
| 623 |
|
return ''; |
| 624 |
|
}); |
| 625 |
|
if (noDocumentElement) { |
| 626 |
|
log ('Script error: documentElement is null'); |
| 627 |
|
break; |
| 628 |
|
} |
| 629 |
|
s = s.replace (/^\s*w\s*\(\s*document\.documentElement\.innerHTML\s*\)\s*;\s*/, |
| 630 |
|
function (s, t) { |
| 631 |
|
matched = true; |
| 632 |
|
log (dumpTree (doc, '')); |
| 633 |
return ''; |
return ''; |
| 634 |
}); |
}); |
| 635 |
if (s == '') break; |
if (s == '') break; |
| 714 |
}; // document.open |
}; // document.open |
| 715 |
|
|
| 716 |
JSDocument.prototype.write = function () { |
JSDocument.prototype.write = function () { |
| 717 |
|
log ('document.write: start'); |
| 718 |
logIndentLevel++; |
logIndentLevel++; |
| 719 |
|
|
| 720 |
var p = this._parser; |
var p = this._parser; |
| 738 |
if (p.scriptExecutedAfterParserResumes) { |
if (p.scriptExecutedAfterParserResumes) { |
| 739 |
log ('document.write: processed later (there is an unprocessed <script src>)'); |
log ('document.write: processed later (there is an unprocessed <script src>)'); |
| 740 |
logIndentLevel--; |
logIndentLevel--; |
| 741 |
|
log ('document.write: return'); |
| 742 |
return; |
return; |
| 743 |
} |
} |
| 744 |
|
|
| 752 |
// to do something here? |
// to do something here? |
| 753 |
|
|
| 754 |
// 5. Return |
// 5. Return |
| 755 |
|
logIndentLevel--; |
| 756 |
log ('document.write: return'); |
log ('document.write: return'); |
| 757 |
|
|
|
logIndentLevel--; |
|
| 758 |
return; |
return; |
| 759 |
}; // document.write |
}; // document.write |
| 760 |
|
|
| 761 |
JSDocument.prototype._insertExternalScript = function (uri) { |
JSDocument.prototype._insertExternalScript = function (uri) { |
| 762 |
var s = new JSElement (this, 'script'); |
var s = new JSElement (this, 'script'); |
| 763 |
s.src = uri; |
s.src = uri; |
| 764 |
this.documentElement.appendChild (s); |
if (this.documentElement) { |
| 765 |
|
this.documentElement.appendChild (s); |
| 766 |
|
return true; |
| 767 |
|
} else { |
| 768 |
|
return false; |
| 769 |
|
} |
| 770 |
}; // _insertExternalScript |
}; // _insertExternalScript |
| 771 |
|
|
| 772 |
JSDocument.prototype.__defineGetter__ ('documentElement', function () { |
JSDocument.prototype.__defineGetter__ ('documentElement', function () { |
| 883 |
<li><code>var s = document.createElement ("script"); |
<li><code>var s = document.createElement ("script"); |
| 884 |
s.src = "<var>string</var>"; |
s.src = "<var>string</var>"; |
| 885 |
document.documentElement.appendChild (s);</code> |
document.documentElement.appendChild (s);</code> |
| 886 |
|
<li><code>w (document.documentElement.innerHTML);</code> (This statement |
| 887 |
|
can be used to dump the document, even when the document has no |
| 888 |
|
document element. The output format is the tree dump format used |
| 889 |
|
in html5lib test data, not <abbr>HTML</abbr>.) |
| 890 |
</ul> |
</ul> |
| 891 |
Note that strings may be delimited by <code>'</code>s instead of |
Note that strings may be delimited by <code>'</code>s instead of |
| 892 |
<code>"</code>s. |
<code>"</code>s. |