Commit ab7982be authored by Jérome Perrin's avatar Jérome Perrin

Zelenium: include all iframes in (HTML) debug link

When test fails because of assertion failure inside an iframe, it's also
helpful to dump iframe content as well.
parent 7b0c3714
......@@ -506,12 +506,43 @@ objectExtend(HtmlTestCaseRow.prototype, {
if (testFrame.currentTestCase.headerRow.trElement.textContent.indexOf("expected failure") === -1) {
var aElement = this.trElement.ownerDocument.createElement("a");
aElement.textContent = ' (HTML)';
/**
* encode a string to base64
* @param {string} str string to be encoded
* @return {string}
*/
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
aElement.href = 'data:text/html;charset=utf-8;base64,' + b64EncodeUnicode(sel$('selenium_myiframe').contentWindow.document.body.innerHTML);
/**
* converts a Document to a base64 link containing the page content.
* @param {Document} doc the document
* @return {string}
*/
function convertDocumentToDataUrl(doc){
return 'data:text/html;charset=utf-8;base64,' + b64EncodeUnicode(doc.body.innerHTML);
}
/**
* converts all iframs to a base64 link containing the page content.
* @param {Document} doc the document
* @return {string}
*/
function recursiveConvertIframeToDataUrl(doc) {
console.log("recursiveConvertIframeToDataUrl", doc)
doc.querySelectorAll('iframe').forEach(
function (frame) {
frame.src = recursiveConvertIframeToDataUrl(
frame.contentWindow.document
);;
}
)
return convertDocumentToDataUrl(doc);
}
aElement.href = recursiveConvertIframeToDataUrl(sel$('selenium_myiframe').contentWindow.document);
this.trElement.cells[2].appendChild(aElement);
}
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment