Tests using the forward- and backwards commands in Marionette are known to cause intermittents. We suspect this is because they are not implemented in a synchronous manner, e.g. they don’t wait for the document to reach the expected state before returning.
Because navigating backwards and forwards may either reload a document from bfcache or navigate internally in a document (if push state or internal anchors have been used), we _do not_ expect a document load event to occur. I’m not entirely sure what the right fix is, but suspect the fix might involve updating the WebDriver standard to be more specific.
This can be seen in https://treeherder.mozilla.org/#/jobs?repo=autoland&fromchange=fa592f5df0fe2281950d5ca980cc3ca9737b999d&tochange=5bf281bce89679ddd6d01091a6606028672a3d3a&filter-searchStr=marionette&group_state=expanded.
https://bugzilla.mozilla.org/show_bug.cgi?id=1291320 is for fixing the Refresh command. The refresh command, in contrast to Back and Forward, always expect the document to reload and for the document load events to fire.
Keep in mind that also JS code can trigger navigating back and forward. For those and like other commands (click, keypress) which cause a load of a page, it will be hard to check that in Marionette server with the current algorithm.
In Mozmill I solved this problem by assigning a uuid for each page load. Once a page gets unloaded it gets reset (and the current value backup'ed), and once loaded a new value is set. With that we were able to see that a page load was happening for a tab. So this was able to also handle external page loads triggered by whatever the user is doing.