Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After one failed attempt to limit the frame discoverability (#3352), I suggest here another temporary fix which involves: * Disable the top-down, breadth-first traversal of frames to enable discoverability. * Replace it by a targeted discoverability: identify the sender of the initial postMessage message and direct it to the right frame: - if the sender is the `sidebar` iframe (server frame), the postMessage is sent *only* to the `host` frame using `window.parent`. - if the sender is an annotatable iframe(s), send the postMessage to the `sidebar` iframe. Pros: - resolves the broken ePub example - resolves the hyper-connectivity of frames Cons: - the `notebook` iframe is still not able to be discovered - introduce an artificial delay on the discoverablity of annotatable iframes that could potentially brake The client relies on an inter-frame communication system between the `host` frame, where the client is initially loaded, and a number of children iframes. For the communication to work, every frame needs to be able to discover the iframe that acts as a server by sending a `frame.postMessage`. Currently, the `sidebar` iframe is the server. The following frames must establish communication with the server `sidebar` iframe: - `host` frame (where the client is initially loaded) - `notebook` iframe - additional annotatable iframe(s) (each have an `enable-annotation` attribute) where the another client instance is injected. This layout represents the current arrangement of frames: ``` host frame (client) |-> (generally, shadow DOMed) sidebar iframe (server) |-> (generally, shadow DOMed) notebook iframe (client) |-> [annotatable iframe/s] (client) |-> [annotatable iframe/s] (client) ``` There are two problems with the current discoverability algorithm: 1. It relies on `window.frames` to list all the other frames. Because `sidebar` and `notebook` iframes are generally wrapped on a shadow DOM they are not listed on `window.frames`. 2. It is very generic: the algorithm starts from the top-most frame in the hierarchy (`window.top`) and send messages to all the frame children *recursively*. If there are several clients initialised on individual frames, this algorithm causes *all* the `host` frames to be connected to all the `sidebar` iframes.
- Loading branch information