On 07/06/2015 10:33 PM, Zibi Braniecki wrote:
Hi all,

I have a question about MO behavior.

From what I understand, MutationObserver API is designed in a way that is 
supposed to guarantee two things that I need:

1) That if I have a MO set on the document during readyState=loading, then all 
consequent elements injected by Parser into DOM will go through MO
before layout 2) And that they will block DOMContentLoaded

I don't know what "have a MO set on the document during readyState=loading" 
actually means.
MutationObserver callback is called at the end of microtask, so end of 
outermost script execution or end of a task in general.
And MutationObserver has nothing to do with DOMContentLoaded.


The first behavior is crucial for client side localization so that we can 
translate the node that is being injected before any frame
creation/layout happens.

I'm still not sure if that's the case and I'm not even sure how to test if our 
implementation guarantees that.

But now, I have more doubts because it seems that we don't do 2).

My test works like this - https://pastebin.mozilla.org/8838694

I first start a MutationObserver inline and register it on document.head. 
Whenever link with rel=localization is inserted I add `ready` property to
it.
I don't see any <link> elements in your example



Then I run a deferred script (in my tests I use external scripts, but I inlined 
them for the testcase) which collects all links with
rel=localization from document.head and operates on their `ready` property 
which should be, according to my logic, always there.

When I test this, I get nondeterministic behavior with ready being set in ~80% 
of reloads and in 20% onAddedHeadElement is executed after the
deferred script.

Is that a bug? Because if it's not, it feels like it should be. Or am I wrong?

Oh, you want to ensure MutationObservers are called before some script is 
executed? That is indeed still a bug, Bug 789315.
        





zb.


_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to