diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/plugins/test/mochitest/pluginstream.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/plugins/test/mochitest/pluginstream.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/pluginstream.js b/dom/plugins/test/mochitest/pluginstream.js new file mode 100644 index 0000000000..c4ab769d51 --- /dev/null +++ b/dom/plugins/test/mochitest/pluginstream.js @@ -0,0 +1,46 @@ +SimpleTest.waitForExplicitFinish(); + +function frameLoaded(finishWhenCalled = true, lastObject = false) { + var testframe = document.getElementById("testframe"); + function getNode(list) { + if (list.length === 0) { + return undefined; + } + return lastObject ? list[list.length - 1] : list[0]; + } + var embed = getNode(document.getElementsByTagName("embed")); + if (undefined === embed) { + embed = getNode(document.getElementsByTagName("object")); + } + + // In the file:// URI case, this ends up being cross-origin. + // Skip these checks in that case. + if (testframe.contentDocument) { + var content = testframe.contentDocument.body.innerHTML; + if (!content.length) { + return; + } + + var filename = + embed.getAttribute("src") || + embed.getAttribute("geturl") || + embed.getAttribute("geturlnotify") || + embed.getAttribute("data"); + + var req = new XMLHttpRequest(); + req.open("GET", filename, false); + req.overrideMimeType("text/plain; charset=x-user-defined"); + req.send(null); + is(req.status, 200, "bad XMLHttpRequest status"); + is( + content, + req.responseText.replace(/\r\n/g, "\n"), + "content doesn't match" + ); + } + + is(embed.getError(), "pass", "plugin reported error"); + if (finishWhenCalled) { + SimpleTest.finish(); + } +} |