Skip to content

Commit 81e2cc9

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

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

bin/accessibility-automation/plugin/index.js

Lines changed: 15 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;
@@ -31,6 +33,19 @@ const browserstackAccessibility = (on, config) => {
3133
if (browser_validation) {
3234
const ally_path = path.dirname(process.env.ACCESSIBILITY_EXTENSION_PATH)
3335
launchOptions.extensions.push(ally_path);
36+
try{
37+
const {_, payload} = decodeJWTToken(process.env.ACCESSIBILITY_AUTH);
38+
if(!utils.isUndefined(payload) && !utils.isUndefined(payload.a11y_core_config) && payload.a11y_core_config.domForge === true) {
39+
launchOptions.args.push("--auto-open-devtools-for-tabs");
40+
launchOptions.preferences.default["devtools"] = launchOptions.preferences.default["devtools"] || {};
41+
launchOptions.preferences.default["devtools"]["preferences"] = launchOptions.preferences.default["devtools"]["preferences"] || {};
42+
launchOptions.preferences.default["devtools"]["preferences"][
43+
"currentDockState"
44+
] = '"undocked"';
45+
}
46+
} catch(error) {
47+
console.log("Error:", error.message);
48+
}
3449
return launchOptions
3550
}
3651
}

bin/helpers/utils.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,3 +1775,25 @@ 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+
1786+
exports.decodeJWTToken = (token) => {
1787+
try{
1788+
const parts = token.split('.');
1789+
if (parts.length < 2) {
1790+
throw new Error('Invalid JWT token');
1791+
}
1792+
const header = JSON.parse(base64UrlDecode(parts[0]));
1793+
const payload = JSON.parse(base64UrlDecode(parts[1]));
1794+
return { header, payload };
1795+
} catch (error) {
1796+
logger.err(error.message);
1797+
return {undefined, undefined};
1798+
}
1799+
}

0 commit comments

Comments
 (0)