Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/49499
Change subject: Clone Wt2Html result before letting it become asynchronous.
......................................................................
Clone Wt2Html result before letting it become asynchronous.
The parser pipeline is handled asynchronously; ie the list of testTasks
is processed with async.waterfall() which defers work to process.nextTick().
The DOMPostProcessor is going to reset its parser as soon as it emits the
'document' event, which will clear parser.document.body. We need to clone
the result before returning from the event handler to ensure that later
stages of the pipeline aren't affected by the imminent parser reset.
(This is necessary for domino and standards-compliant DOM implementations;
jsdom creates a new <body> when the parser is reset so the existing
<body> doesn't get stomped on.)
Change-Id: Ia372c5614a0b1aae846250a80374f2cabce6f202
---
M js/tests/parserTests.js
1 file changed, 7 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/99/49499/1
diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index 31e1675..ffb9b75 100644
--- a/js/tests/parserTests.js
+++ b/js/tests/parserTests.js
@@ -478,7 +478,11 @@
ParserTests.prototype.convertWt2Html = function( mode, wikitext, processHtmlCB
) {
try {
this.parserPipeline.once( 'document', function ( doc ) {
- processHtmlCB( null, doc );
+ // processHtmlCB can be asynchronous, so deep-clone
+ // document before invoking it. (the parser pipeline
+ // will attempt to reuse the document after this
+ // event is emitted)
+ processHtmlCB( null, doc.body.cloneNode(true) );
} );
} catch ( e ) {
processHtmlCB( e );
@@ -571,7 +575,7 @@
testTasks.push( function ( result, cb ) {
if ( startsAtWikitext && item.cachedHTML === null ) {
// Cache parsed HTML
- item.cachedHTML = result.body.cloneNode( true );
+ item.cachedHTML = result.cloneNode( true );
}
cb( null, result );
@@ -623,7 +627,7 @@
ParserTests.prototype.processParsedHTML = function( item, options, mode, doc,
cb ) {
item.time.end = Date.now();
// Check the result vs. the expected result.
- this.checkHTML( item, doc.body.innerHTML, options, mode );
+ this.checkHTML( item, doc.innerHTML, options, mode );
// Now schedule the next test, if any
process.nextTick( cb );
--
To view, visit https://gerrit.wikimedia.org/r/49499
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia372c5614a0b1aae846250a80374f2cabce6f202
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits