Skip to content

Yaakobiben/feature/dispatch event#1

Merged
evincedbenyaakobi merged 11 commits intomasterfrom
yaakobiben/feature/dispath-event
Oct 21, 2024
Merged

Yaakobiben/feature/dispatch event#1
evincedbenyaakobi merged 11 commits intomasterfrom
yaakobiben/feature/dispath-event

Conversation

@evincedbenyaakobi
Copy link
Copy Markdown

@evincedbenyaakobi evincedbenyaakobi commented Oct 20, 2024

Description

Including:

  1. this fix
  2. these rules
  3. changed default rules repo to be ours instead of the original
  4. add session storage per tab in background
  5. reset tab's storage session on every tab reload
  6. send (once) event of finishing(error, handled or nothing) through all windows hierarchy(in case we are in iframes).
  7. Fixed an additional bug: cookie popup -> get rid of cookie popup -> HandledCMP -> Nothing -> Nothing. I fixed it so it would emit one event(HandledCMP) with finite events(HandledCMP, Error) taking precedence. |
  8. Removed wait when an HandledCMP event is emitted(since it can be in an iframe and then it is discarded and waits for nothing)

Tests

  1. Tested on https://sky.it - iframe
  2. Tested on https://business.sky.com/wholesale - iframe
  3. Tested on https://www.natwestgroup.com/

In all tests I used this to test:

window.addEventListener("message", function(event) {
  if (event.data.type === "FROM_EXTENSION") {
    console.log("Message from extension:", JSON.stringify(event.data));
  }
});

I encountered new sessions through each iframe so I had to modify the code to adapt. In that way, I send whether the event is in an iframe and what is the iframe location.

@evincedbenyaakobi evincedbenyaakobi changed the title Yaakobiben/feature/dispath event Yaakobiben/feature/dispatch event Oct 20, 2024
function sendFinishingEvent(message) {
let wind = window;
while (wind != null) {
wind.postMessage(message, "*");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You are posting to all the chain?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes. I don't know how deep in iframes I am

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But can we just post the message on the last window who's parent is null?

Copy link
Copy Markdown
Author

@evincedbenyaakobi evincedbenyaakobi Oct 20, 2024

Choose a reason for hiding this comment

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

we can(not null, but the window itself: window.parent === window), but it's safer to post on all windows

@evincedbenyaakobi evincedbenyaakobi merged commit 982eb3c into master Oct 21, 2024
@evincedbenyaakobi evincedbenyaakobi deleted the yaakobiben/feature/dispath-event branch October 21, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants