It might be a good idea to send an email to the webkitgtk mailing list by the way.<div><br></div><div>I wonder if it would make sense to add a window-object-cleared signal to WebkKitView (webkitgtk1 has it). They provide a way to run javascript code from the view and it seems being able to run it before any other js code has been executed would be a very common use case, one you wouldn't want people to write an extension for...<br>
<br>On Wednesday, 27 November 2013, Daniel Narvaez wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This makes me wonder if the current approach is actually racy by the way... I'm not sure the window object is guaranteed to be ready even on the load_finished event. Network and javascript context might be completely independent from this point of view (they are in separate processes after all).<div>
<br></div><div>I feel the best approach here is the webkit extension really, even if it requires a little bit of C code.<br><br>On Wednesday, 27 November 2013, Daniel Narvaez wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<div><br></div><div>did you try to implement it and see if it works? I probably tried this when I first implemented getEnvironment but I might have done it wrong or something. My worry is that the javascript context might not be ready yet at that time, so either the python js code would fail or affect the old view.</div>
<div><br></div><div>By the way, if you are determined to solve this and the loaded_started approach doesn't work, I know it would be possible to make it work using this</div><div><br></div><div><a href="http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitScriptWorld.html" target="_blank">http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitScriptWorld.html</a></div>
<div><br></div><div>It runs in the web process, so it tells you exactly when a new window object is created. Though using that API requires an extension written in C :/ If despite that you are interested in working on that I can give you some more pointers.<br>
<br>On Wednesday, 27 November 2013, Rogelio Mita wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I noticed existence of a WebKitWebView event which is emitted before what any resource be loaded, called <a href="http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WEBKIT-LOAD-STARTED:CAPS" target="_blank">webkit_loaded_started</a></div>
<div><table border="0" style="padding:4px;margin-left:3em;font-family:cantarell,sans-serif"><tbody><tr><td style="vertical-align:top"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
WEBKIT_LOAD_STARTED: A new load request has been made. No data has been received yet, empty structures have been allocated to perform the load; the load may still fail due to transport issues such as not being able to resolve a name, or connect to a port.</blockquote>
</td><td></td></tr></tbody></table></div><div>I did a concept proof on sugar-toolkit-gtk3 to show this behaviour and the result was:<br></div><div><br></div><div><img src="cid:ii_14297c7e109dbe09" alt="Imágenes integradas 1"><br>
</div><div><br></div><div><div>I think that this behaviour can solve the issue with env.getEnvironment and your hard dependency with sugar var provided by python code.</div><div><br></div><div>This log also show how load_event_finished is executed between successive requests, then there is no doubt about the current problem existence.</div>
<div><br></div><div>You think this may be a solution?, change the script so that it is now run in this event (load_event_started) and rewrite getEnvironment disregarding the possibility that there is no environment variable provided by the Python code, in others words ever when activity is in sugar mode, window.sugar.environment will be present</div>
</div><br clear="all"><div><br></div>-- <br>Roger<div><br><div><a href="http://activitycentral.com/" target="_blank">Activity Central</a></div></div>
</div>
</blockquote></div><br><br>-- <br>Daniel Narvaez<br><br>
</blockquote></div><br><br>-- <br>Daniel Narvaez<br><br>
</blockquote></div><br><br>-- <br>Daniel Narvaez<br><br>