Skip to content

Commit e8d4bc9

Browse files
committed
SDK-1907: added launchOptions
1 parent da5fc16 commit e8d4bc9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

bin/accessibility-automation/plugin/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const path = require("node:path");
2+
const { decodeJWTToken } = require("../../helpers/utils");
3+
const utils = require('../../helpers/utils');
24

35
const browserstackAccessibility = (on, config) => {
46
let browser_validation = true;
@@ -30,7 +32,16 @@ const browserstackAccessibility = (on, config) => {
3032
}
3133
if (browser_validation) {
3234
const ally_path = path.dirname(process.env.ACCESSIBILITY_EXTENSION_PATH)
35+
const {_, payload} = decodeJWTToken(process.env.ACCESSIBILITY_AUTH);
3336
launchOptions.extensions.push(ally_path);
37+
if(!utils.isUndefined(payload) && !utils.isUndefined(payload.a11y_core_config) && payload.a11y_core_config.domForge === true) {
38+
launchOptions.args.push("--auto-open-devtools-for-tabs");
39+
launchOptions.preferences.default["devtools"] = launchOptions.preferences.default["devtools"] || {};
40+
launchOptions.preferences.default["devtools"]["preferences"] = launchOptions.preferences.default["devtools"]["preferences"] || {};
41+
launchOptions.preferences.default["devtools"]["preferences"][
42+
"currentDockState"
43+
] = '"undocked"';
44+
}
3445
return launchOptions
3546
}
3647
}

bin/helpers/utils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,3 +1775,24 @@ exports.getMajorVersion = (version) => {
17751775
return null;
17761776
}
17771777
}
1778+
1779+
const base64UrlDecode = (str) => {
1780+
const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
1781+
const buffer = Buffer.from(base64, 'base64');
1782+
return buffer.toString('utf-8');
1783+
};
1784+
1785+
exports.decodeJWTToken = (token) => {
1786+
try{
1787+
const parts = token.split('.');
1788+
if (parts.length < 2) {
1789+
throw new Error('Invalid JWT token');
1790+
}
1791+
const header = JSON.parse(base64UrlDecode(parts[0]));
1792+
const payload = JSON.parse(base64UrlDecode(parts[1]));
1793+
return { header, payload };
1794+
} catch (error) {
1795+
logger.err(error.message);
1796+
return {undefined, undefined};
1797+
}
1798+
}

0 commit comments

Comments
 (0)