fune/toolkit/components/viewsource/test/browser/browser_srcdoc.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

28 lines
961 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const frameSource = `<a href="about:mozilla">good</a>`;
const source = `<html><iframe srcdoc='${frameSource}' id="f"></iframe></html>`;
add_task(async function() {
let url = `data:text/html,${source}`;
await BrowserTestUtils.withNewTab({ gBrowser, url }, checkFrameSource);
});
async function checkFrameSource() {
let sourceTab = await openViewFrameSourceTab("#f");
registerCleanupFunction(function() {
gBrowser.removeTab(sourceTab);
});
let browser = gBrowser.selectedBrowser;
let textContent = await SpecialPowers.spawn(browser, [], async function() {
return content.document.body.textContent;
});
is(textContent, frameSource, "Correct content loaded");
let id = await SpecialPowers.spawn(browser, [], async function() {
return content.document.body.id;
});
is(id, "viewsource", "View source mode enabled");
}