Skip to content

Commit

Permalink
feat: support inspection of nested iframes content (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticjs authored Oct 13, 2022
1 parent 784a2e2 commit 197dfd3
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 78 deletions.
4 changes: 4 additions & 0 deletions app/html/panel/ui5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

</head>
<body>
<frame-select id="frame-select">
<label>Frame: </label>
<select hidden></select>
</frame-select>
<tabbar id="ui5-tabbar">
<tabs>
<tab id="control-tree-tab" selected>Control Inspector</tab>
Expand Down
1 change: 1 addition & 0 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"js": [
"/scripts/content/detectUI5.js"
],
"all_frames": true,
"matches": [
"http://*/*",
"https://*/*"
Expand Down
44 changes: 41 additions & 3 deletions app/scripts/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
contextMenu.onClicked = function (info, tab) {
utils.sendToAll({
action: 'do-context-menu-control-select',
target: contextMenu._rightClickTarget
target: contextMenu._rightClickTarget,
// specify the frame in which the user clicked
frameId: info.frameId
}, tab.id);
};

Expand All @@ -37,7 +39,8 @@
contextMenuCopyHtml.onClicked = function (info, tab) {
utils.sendToAll({
action: 'do-context-menu-copy-html',
target: contextMenu._rightClickTarget
target: contextMenu._rightClickTarget,
frameId: info.frameId
}, tab.id);
};

Expand Down Expand Up @@ -80,7 +83,9 @@
chrome.tabs.query({ active: true, windowId: w.id }, tabs => {
chrome.scripting.executeScript({
target: {
tabId: tabs[0].id
// inject the script only into the frame
// specified in the request from the devTools UI5 panel script
tabId: tabs[0].id, frameIds: [message.frameId]
},
files: [message.file]
});
Expand Down Expand Up @@ -112,6 +117,39 @@
'on-ui5-devtool-hide': function (message) {
contextMenu.removeAll();
contextMenuCopyHtml.removeAll();
},

'do-ping-frames': function (message, messageSender) {
var frameIds = message.frameIds;
var liveFrameIds = [];
var pingFrame = function (i) {
if (i >= frameIds.length) {
// no more frameId to ping
// => done with pinging each frame
// => send a message [to the devTools UI5 panel]
// with the updated list of 'live' frame ids
chrome.runtime.sendMessage(messageSender.id, {
action: 'on-ping-frames',
frameIds: liveFrameIds
});
return;
}

var frameId = frameIds[i];
// ping the next frame
// from the <code>frameIds</code> list
utils.sendToAll({
action: 'do-ping',
frameId: frameId
}, function (isAlive) {
if (isAlive) {
liveFrameIds.push(frameId);
}
pingFrame(i + 1);
});
};

pingFrame(0);
}
};

Expand Down
9 changes: 9 additions & 0 deletions app/scripts/content/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
*/
'on-control-tree-hover': function (message) {
highLighter.setDimensions(message.target);
},

'on-hide-highlight': function () {
highLighter.hide();
},

'do-ping': function (message, messageSender, sendResponse) {
// respond to ping
sendResponse(true /* alive status */);
}
};

Expand Down
Loading

0 comments on commit 197dfd3

Please sign in to comment.