Correção na abertura dos workload workbench quando não estiver disponível

This commit is contained in:
Paulo Porto
2026-05-06 14:32:03 -03:00
parent 5cb8961524
commit 88787a054a
3 changed files with 123 additions and 8 deletions

View File

@@ -14,6 +14,10 @@ const COMCIP_TAB_URL_PATTERN =
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_semc/live*`;
const COMCIP_TIME_ENTRY_TAB_URL_PATTERN =
`${COMCIP_ORIGIN}/ic/builder/rt/oalset_timeentrymobile/live*`;
const SPA_WORKBENCH_FRAME_URL =
"https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=workload_workbench";
const SPA_WORKBENCH_FRAME_ID = "arch-panel-extension-spa-frame";
const SPA_WORKBENCH_FRAME_HOST_ID = "arch-panel-extension-spa-frame-host";
const SPA_FRAME_DNR_RULE_ID = 92001;
void installSpaFrameHeaderRules();
@@ -169,6 +173,7 @@ async function executeSpaFrameFetch({ senderTabId, url, options = {} }) {
}
await installSpaFrameHeaderRules();
await ensureSpaFrameElementInTab(senderTabId);
await waitForSpaFramePresent(senderTabId);
await ensureSpaBridgeInFrames(senderTabId);
await waitForSpaFrameCapturedAuth(senderTabId, url);
@@ -176,6 +181,84 @@ async function executeSpaFrameFetch({ senderTabId, url, options = {} }) {
return executeSpaFrameScriptFetch(senderTabId, url, options);
}
async function ensureSpaFrameElementInTab(tabId) {
await chrome.scripting.executeScript({
target: { tabId, frameIds: [0] },
world: "MAIN",
args: [
SPA_WORKBENCH_FRAME_HOST_ID,
SPA_WORKBENCH_FRAME_ID,
SPA_WORKBENCH_FRAME_URL,
],
func: (hostId, frameId, frameUrl) => {
const desiredParent = document.body || document.documentElement;
if (!desiredParent) {
return false;
}
let host = document.getElementById(hostId);
if (!host) {
host = document.createElement("div");
host.id = hostId;
host.setAttribute("aria-hidden", "true");
}
Object.assign(host.style, {
position: "fixed",
width: "1440px",
height: "1000px",
overflow: "hidden",
opacity: "0",
pointerEvents: "none",
border: "0",
left: "-20000px",
top: "0",
zIndex: "0",
});
if (host.parentElement !== desiredParent) {
desiredParent.appendChild(host);
}
let frame = document.getElementById(frameId);
if (!(frame instanceof HTMLIFrameElement)) {
frame = document.createElement("iframe");
frame.id = frameId;
frame.name = frameId;
frame.setAttribute("aria-hidden", "true");
frame.setAttribute("referrerpolicy", "no-referrer-when-downgrade");
frame.tabIndex = -1;
}
frame.name = frameId;
frame.dataset.archPanelFrame = "spa-workbench";
Object.assign(frame.style, {
position: "absolute",
width: "1440px",
height: "1000px",
opacity: "0",
pointerEvents: "none",
border: "0",
left: "0",
top: "0",
});
if (frame.parentElement !== host) {
host.appendChild(frame);
}
if (!frame.src || frame.src === "about:blank" || frame.src !== frameUrl) {
frame.src = frameUrl;
}
return true;
},
}).catch(() => {});
}
async function waitForSpaFramePresent(tabId) {
const startedAt = Date.now();
let lastFrames = "";