Skip to content

Commit

Permalink
changing to hidden element
Browse files Browse the repository at this point in the history
  • Loading branch information
mayarajan3 committed Jun 24, 2024
1 parent 8f59eed commit 37c3369
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
18 changes: 3 additions & 15 deletions extensions/scripts/bundles/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,14 @@ async function playwrightTest(framework, bundledJsPath) {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
var detailsJSON = {};
await page.goto('about:blank');

page.on('console', async (msg) => {
const args = await Promise.all(msg.args().map(arg => arg.jsonValue()));
for (const arg of args) {
if (arg.includes("DETAILS: ")) {
let prefix = "DETAILS: ";
let jsonVal = arg.substring(prefix.length).trim();
jsonVal = JSON.parse(jsonVal.trim());
detailsJSON = jsonVal;
}
}
});

const bundledJs = fs.readFileSync(bundledJsPath, 'utf8');
await page.evaluate(`
${framework}
${bundledJs}`)
await page.waitForTimeout(1000);
await page.waitForSelector('#menuDetails', { state: 'attached' });
var detailsJSON = await page.$eval('#menuDetails', (element) => element.textContent);
detailsJSON = JSON.parse(detailsJSON);
await browser.close();
return detailsJSON;
}
Expand Down
7 changes: 5 additions & 2 deletions extensions/src/common/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ export const extension = <const TSupported extends readonly MixinName[]>(
): ExtensionWithFunctionality<[...TSupported]> & typeof ExtensionBase => {

if (details) {
let detailStr = `DETAILS: ${JSON.stringify(details)}`;
console.log(detailStr);
const element = document.createElement("div");
element.textContent = JSON.stringify(details);
element.id = "menuDetails";
element.style.display = "none";
document.body.appendChild(element);
extensionBundleEvent?.fire({ details, addOns });
}

Expand Down

0 comments on commit 37c3369

Please sign in to comment.