Bug 1264573 - Share tabs in isolation tests. r=baku, r=arthuredelstein

--HG--
extra : rebase_source : 5f51c24993639f8571450871b5b868b712a66aa5
This commit is contained in:
Jonathan Hao 2016-09-07 11:38:37 +08:00
Родитель e125aeb6c8
Коммит eb2ea553d6
2 изменённых файлов: 37 добавлений и 28 удалений

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

@ -87,8 +87,11 @@ function doTest(blobify, deblobify) {
}
}
let tests = [];
for (let blobify of [page_blobify, worker_blobify]) {
for (let deblobify of [page_deblobify, worker_deblobify]) {
IsolationTestTools.runTests(TEST_PAGE, doTest(blobify, deblobify));
tests.push(doTest(blobify, deblobify));
}
}
IsolationTestTools.runTests(TEST_PAGE, tests);

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

@ -259,11 +259,11 @@ this.IsolationTestTools = {
* The URL of the page that will be tested or an object contains 'url',
* the tested page, 'firstFrameSetting' for the frame setting of the first
* tab, and 'secondFrameSetting' for the second tab.
* @param aGetResultFunc
* A function which is responsible for returning the isolation result back
* to the framework for further checking. This function will be provided
* the browser object of the tab, that allows modifying or fetching results
* from the page content.
* @param aGetResultFuncs
* An array of functions or a single function which are responsible for
* returning the isolation result back to the framework for further checking.
* Each of these functions will be provided the browser object of the tab,
* that allows modifying or fetchings results from the page content.
* @param aCompareResultFunc
* An optional function which allows modifying the way how does framework
* check results. This function will be provided a boolean to indicate
@ -271,7 +271,7 @@ this.IsolationTestTools = {
* a boolean to tell that whether isolation is working. If this function
* is not given, the framework will take case checking by itself.
*/
runTests(aURL, aGetResultFunc, aCompareResultFunc) {
runTests(aURL, aGetResultFuncs, aCompareResultFunc) {
let pageURL;
let firstFrameSetting;
let secondFrameSetting;
@ -284,6 +284,10 @@ this.IsolationTestTools = {
secondFrameSetting = aURL.secondFrameSetting;
}
if (!Array.isArray(aGetResultFuncs)) {
aGetResultFuncs = [aGetResultFuncs];
}
let tabSettings = [
{ firstPartyDomain: "http://example.com", userContextId: 1},
{ firstPartyDomain: "http://example.org", userContextId: 2}
@ -303,32 +307,34 @@ this.IsolationTestTools = {
tabSettings[tabSettingB],
secondFrameSetting);
// Fetch results from tabs.
let resultA = yield aGetResultFunc(tabInfoA.browser);
let resultB = yield aGetResultFunc(tabInfoB.browser);
for (let getResultFunc of aGetResultFuncs) {
// Fetch results from tabs.
let resultA = yield getResultFunc(tabInfoA.browser);
let resultB = yield getResultFunc(tabInfoB.browser);
// Compare results.
let result = false;
let shouldIsolate = (aMode !== TEST_MODE_NO_ISOLATION) &&
tabSettingA !== tabSettingB;
if (aCompareResultFunc) {
result = yield aCompareResultFunc(shouldIsolate, resultA, resultB);
} else {
result = shouldIsolate ? resultA !== resultB :
resultA === resultB;
}
let msg = `Testing ${TEST_MODE_NAMES[aMode]} for ` +
`isolation ${shouldIsolate ? "on" : "off"} with TabSettingA ` +
`${tabSettingA} and tabSettingB ${tabSettingB}` +
`, resultA = ${resultA}, resultB = ${resultB}`;
ok(result, msg);
}
// Close Tabs.
yield BrowserTestUtils.removeTab(tabInfoA.tab);
yield BrowserTestUtils.removeTab(tabInfoB.tab);
// Compare results.
let result = false;
let shouldIsolate = (aMode !== TEST_MODE_NO_ISOLATION) &&
tabSettingA !== tabSettingB;
if (aCompareResultFunc) {
result = yield aCompareResultFunc(shouldIsolate, resultA, resultB);
} else {
result = shouldIsolate ? resultA !== resultB :
resultA === resultB;
}
let msg = `Testing ${TEST_MODE_NAMES[aMode]} for ` +
`isolation ${shouldIsolate ? "on" : "off"} with TabSettingA ` +
`${tabSettingA} and tabSettingB ${tabSettingB}`;
ok(result, msg);
}
});
}
};