fune/browser/components/sessionstore/test/browser_485482.js
Anny Gakhokidze 2bf10938e6 Bug 1698601 - Part 1: Extend existing session store test files with COOP document testing, r=smaug
Modify related test files to test documents with COOP headers enabled.

There are some tests that fail when run with new COOP configurations without
Fission enabled, prior to fixes that come in part 2. This means that some of
the COOP behaviour was already broken. Since fixing non-Fission COOP
behaviour prior to this patch is out of scope, I skipped calling `addCoopTask`
to test COOP documents in non Fission cases for such tests.

Even with COOP headers disabled, some tests fail when the document they load
is served over httpS and not http. For a single test where this behaviour was
occuring prior to fixes in part 2, I skipped testing an HTTPS non-COOP
document and filed 1703351 to fix such behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D110993
2021-04-09 17:46:52 +00:00

76 lines
1.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
if (gFissionBrowser) {
addCoopTask(
"browser_485482_sample.html",
test_xpath_exp_for_strange_documents,
HTTPSROOT
);
}
addNonCoopTask(
"browser_485482_sample.html",
test_xpath_exp_for_strange_documents,
ROOT
);
addNonCoopTask(
"browser_485482_sample.html",
test_xpath_exp_for_strange_documents,
HTTPSROOT
);
addNonCoopTask(
"browser_485482_sample.html",
test_xpath_exp_for_strange_documents,
HTTPROOT
);
/**
* Bug 485482 - Make sure that we produce valid XPath expressions even for very
* weird HTML documents.
*/
async function test_xpath_exp_for_strange_documents(aURL) {
// Load a page with weird tag names.
let tab = BrowserTestUtils.addTab(gBrowser, aURL);
let browser = tab.linkedBrowser;
await promiseBrowserLoaded(browser);
// Fill in some values.
let uniqueValue = Math.random();
await setPropertyOfFormField(
browser,
"input[type=text]",
"value",
uniqueValue
);
await setPropertyOfFormField(
browser,
"input[type=checkbox]",
"checked",
true
);
// Duplicate the tab.
let tab2 = gBrowser.duplicateTab(tab);
let browser2 = tab2.linkedBrowser;
await promiseTabRestored(tab2);
// Check that we generated valid XPath expressions to restore form values.
let text = await getPropertyOfFormField(
browser2,
"input[type=text]",
"value"
);
is("" + text, "" + uniqueValue, "generated XPath expression was valid");
let checkbox = await getPropertyOfFormField(
browser2,
"input[type=checkbox]",
"checked"
);
ok(checkbox, "generated XPath expression was valid");
// Cleanup.
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
}