rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.76k stars 127 forks source link

Ferrum needs to listen DOM.documentUpdated in order to use NodeId values properly #86

Open betelgeuse opened 4 years ago

betelgeuse commented 4 years ago

https://chromedevtools.github.io/devtools-protocol/tot/DOM/#event-documentUpdated

Problem

Since ferrum tracks node ids in frontend but does not listen to DOM.documentUpdated it's possible that the following sequence of events happens:

  1. Ferrum::Node has node_id in memory
  2. DOM.documentUpdated happens
  3. calling methods on the node returns information for a new node that has matching id
    1. this would happen because they seem to start again from zero so they are not unique during single session

Fix

Make all Node objects listen to DOM.documentUpdated after which the objects should become stale so that all new commands issued with the node raise an exception.

brutuscat commented 4 years ago

👍 on this, documentation states:

Fired when Document has been totally updated. Node ids are no longer valid.