Bug 1422985. Add test to ensure details param is JSON object. r=miketaylr a=testonly

MozReview-Commit-ID: IjyT44EbRL

--HG--
extra : rebase_source : df6a0022aaae1692b5f1e85a29d64e5ec998a5a6
This commit is contained in:
Mike Taylor 2018-01-29 19:55:29 -06:00
Родитель ab14f80638
Коммит cd13369f51
2 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -1,6 +1,6 @@
/* Test that clicking on the Report Site Issue button opens a new tab
and sends a postMessaged blob to it. */
add_task(async function test_screenshot() {
add_task(async function test_opened_page() {
requestLongerTimeout(2);
// ./head.js sets the value for PREF_WC_REPORTER_ENDPOINT
@ -31,6 +31,9 @@ add_task(async function test_screenshot() {
let preview = doc.getElementById("screenshot-preview");
is(urlParam, args.TEST_PAGE, "Reported page is correctly added to the url param");
let detailsParam = doc.getElementById("details").innerText;
ok(typeof JSON.parse(detailsParam) == "object", "Details param is a stringified JSON object.");
is(preview.innerText, "Pass", "A Blob object was successfully transferred to the test page.");
ok(preview.style.backgroundImage.startsWith("url(\"data:image/png;base64,iVBOR"), "A green screenshot was successfully postMessaged");
});

Просмотреть файл

@ -4,12 +4,15 @@
#screenshot-preview {width: 200px; height: 200px;}
</style>
<div id="url"></div>
<div id="details"></div>
<div id="screenshot-preview">Fail</div>
<script>
let params = new URL(location.href).searchParams;
let preview = document.getElementById("screenshot-preview");
let url = document.getElementById("url");
url.innerText = params.get("url");
let details = document.getElementById("details");
details.innerText = params.get("details");
function getBlobAsDataURL(blob) {
return new Promise((resolve, reject) => {