Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3200: run brick in top frame of window #3201

Merged
merged 1 commit into from
Apr 19, 2022
Merged

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Apr 18, 2022

What does this PR do?

Use Case Patterns Enabled

  • Sub-frame can get context of the root page directly by running bricks in the top-level frame
  • Top-level frame can get context from a sub-frame by having the sub-frame call "Set page state" on the top level from on page load, triggers, etc.

Demo Site

Comment on lines +124 to +127
const sourceTabId = this.trace[0].tab.id;

const subRequest = { ...request, sourceTabId };
return safelyRunBrick({ tabId: sourceTabId }, subRequest);
Copy link
Contributor

@fregante fregante Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks about right. I left some notes on a possible messenger implementation:

This would let content scripts call this directly:

runBrick({ tabId: "this" }, request)

and the messenger would take care of the forwarding. safelyRunBrick wouldn't be necessary because if the tab is closed, then the main runner also closes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will give those notes a look

@twschiller twschiller merged commit f3355f3 into main Apr 19, 2022
@twschiller twschiller deleted the feature/3200-top-target branch April 19, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants