Skip to content

Commit

Permalink
fix tests and wdio flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
weizman committed Jul 11, 2023
1 parent 858059e commit e19c70e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions chrome.wdio.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
global.BROWSER = 'CHROME';
exports.config = {
automationProtocol: 'devtools',
//
// ====================
// Runner Configuration
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"devDependencies": {
"@babel/core": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"@wdio/cli": "^7.5.3",
"@wdio/local-runner": "^7.5.5",
"@wdio/mocha-framework": "^7.5.3",
"@wdio/spec-reporter": "^7.5.3",
"@wdio/cli": "^8.12.2",
"@wdio/local-runner": "^8.12.1",
"@wdio/mocha-framework": "^8.12.1",
"@wdio/spec-reporter": "^8.12.2",
"babel-loader": "^8.2.2",
"chromedriver": "^113.0.0",
"geckodriver": "^3.2.0",
"wdio-chromedriver-service": "7.0.0",
"wdio-chromedriver-service": "^8.1.1",
"wdio-safaridriver-service": "^2.0.0",
"wdio-geckodriver-service": "^4.0.0",
"webpack": "^5.33.2",
Expand Down
1 change: 1 addition & 0 deletions test/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ describe('special cases', () => {
}
const result = await browser.executeAsync(function(done) {
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
if (top.TEST_UTILS.bailOnCorrectUnsafeCSP(done)) return;
(function(){
document.write('<iframe srcdoc="<iframe src=\'javascript:top.bypass([window])\'</iframe>"></iframe>');
}());
Expand Down
40 changes: 24 additions & 16 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
this.skip();
}
await browser.execute(function() {
const done = (result) => top.result = result;
const done = (result) => sessionStorage.result_1 = sessionStorage.result_1 || result;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
document.addEventListener('keydown', async () => {
window.addEventListener('keydown', async () => {
const win = await documentPictureInPicture.requestWindow();
bypass([win]);
});
}());
});
await browser.keys(['Enter']);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
const result = await browser.execute(function() {
return top.result
return sessionStorage.result_1
});
expect(['V']).toContain(result);
});
Expand All @@ -29,19 +31,21 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
this.skip();
}
await browser.execute(function() {
const done = (result) => top.result = result;
const done = (result) => sessionStorage.result_2 = sessionStorage.result_2 || result;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
document.addEventListener('keydown', async () => {
window.addEventListener('keydown', async () => {
await documentPictureInPicture.requestWindow();
const win = documentPictureInPicture.window;
bypass([win]);
});
}());
});
await browser.keys(['Enter']);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
const result = await browser.execute(function() {
return top.result
return sessionStorage.result_2
});
expect(['V']).toContain(result);
});
Expand All @@ -51,10 +55,10 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
this.skip();
}
await browser.execute(function() {
const done = (result) => top.result = result;
const done = (result) => sessionStorage.result_3 = sessionStorage.result_3 || result;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
document.addEventListener('keydown', async () => {
window.addEventListener('keydown', async () => {
documentPictureInPicture.onenter = (e) => {
bypass(['', 'currentTarget', 'srcElement', 'target']
.sort(() => Math.random() - 0.5)
Expand All @@ -64,9 +68,11 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
});
}());
});
await browser.keys(['Enter']);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
const result = await browser.execute(function() {
return top.result
return sessionStorage.result_3
});
expect(['V,V,V,V']).toContain(result);
});
Expand All @@ -76,10 +82,10 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
this.skip();
}
await browser.execute(function() {
const done = (result) => top.result = result;
const done = (result) => sessionStorage.result_4 = sessionStorage.result_4 || result;
top.bypass = (wins) => top.TEST_UTILS.bypass(wins, done);
(function(){
document.addEventListener('keydown', async () => {
window.addEventListener('keydown', async () => {
const win = await documentPictureInPicture.requestWindow();
if (!win?.location?.href) {
bypass([win]);
Expand All @@ -88,9 +94,11 @@ describe('window.documentPictureInPicture.requestWindow API', () => {
});
}());
});
await browser.keys(['Enter']);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
await browser.keys(["", "a"]);
const result = await browser.execute(function() {
return top.result
return sessionStorage.result_4
});
expect(['V']).toContain(result);
});
Expand Down

0 comments on commit e19c70e

Please sign in to comment.