document.write is dangerous if it happens to be called from async loaded scripts (we forbid it in general, and only use it from very select cases in core.
document.writeln is a bit safer if I remember correctly.

DJ


On 30 jul. 2014, at 14:50, Gautam Chandna <gautamc@opera.com> wrote:

Hmm.. document.write() seems to work just fine on Opera Mini, even when loaded from external scripts/inlined/etc. The only problem seems to be about timing, ie. if a page takes too long to load, the scripts will be left behind.

I haven't had a chance to checkout your code and run it locally, but could you confirm that Opera Mini actually gets the document.write()?

When visiting this directly, on various user-agents, I don't see a document.write
 www.mediawiki.org/w/index.php?title=Special:ZeroRatedMobileAccess&zcmd=js-banner
 (I obviously get just this: window.mw.zeroConfig={"enabled":false,"id":null}; )

I'm waiting for a colleague to test and report from a network where Wikipedia is actually free.


For your second question: Since the webpage/session/cookies are all sitting on the server, all AJAX/inline requests will originate from the Mini Server and not the client. The IP address will belong to our servers, and the x-forwarded-for will be set as the client's ip.

Best regards,
Gautam


On Tue, Jul 29, 2014 at 11:27 PM, Yuri Astrakhan <yastrakhan@wikimedia.org> wrote:
Gautam, another question for you - in addition to the previous - if I have a script that runs onload, which pulls some data from web servers, which origin IP will that request have?  E.g., a regular request from a non-opera client either has the ip of the client, or the client's ip is somewhere in the X-Forwarded-For header. When the opera mini server executes javascript that makes an AJAX request on behalf of a client, does it set XFF header to the client ip? Or does it originate from its own IP?

Thanks!

On Tue, Jul 29, 2014 at 11:20 AM, Yuri Astrakhan <yastrakhan@wikimedia.org> wrote:
Jon, TimS suggested we use this approach, because we don't have ESI, and we need to inject a Zero banner which is client IP dependent, without varying article's HTML.

See this RFC for details on why we do it and how.

Gautam, the code is, as always, fully open source :)  See the this RFC (banner generation) first and also here's the Repository, code that generates <script> & <noscript>, and this code outputs the actual javascript.

Thanks!


On Mon, Jul 28, 2014 at 11:14 PM, Jon Robson <jdlrobson@gmail.com> wrote:
Also don't use document.write :)
Out of interest what is this document.write code needed for?



On Mon, Jul 28, 2014 at 12:09 PM, Gautam Chandna <gautamc@opera.com> wrote:
> Opera mini doesn't support inlined scripts, as it needs to finish processing
> the page as fast as possible for transcoding.
>
> The session/cookies/dom/etc all sits on the server while the client simply
> sees the rendered page. To make this possible, we have to give up on a lot
> of scripted functionality.
>
> It does execute the onload event for upto 5 seconds, so you could try using
> that. If you're open to sharing your code, I could try and help.
>
> Best regards,
> Gautam Chandna
> +47 4567 1789
> Sent from my iPhone
>
> On 28 Jul 2014, at 20:45, Yuri Astrakhan <yastrakhan@wikimedia.org> wrote:
>
> Hi, I'm running into an opera mini strangeness. I have a <script src="...">
> tag inside <body>, which is suppose to return document.write("some HTML");
> This works fine except on opera mini, which does not seem to even call the
> server, because I looked at server:source and saw the unsubstituted <script>
> tag.  Any suggestions?
>
> _______________________________________________
> Mobile-l mailing list
> Mobile-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/mobile-l
>
>
> _______________________________________________
> Mobile-l mailing list
> Mobile-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/mobile-l
>



--
Jon Robson
* http://jonrobson.me.uk
* https://www.facebook.com/jonrobson
* @rakugojon

_______________________________________________
Mobile-l mailing list
Mobile-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mobile-l





--
Gautam Chandna | Director - Technical Partner Management | gautamc@opera.com | +47-4567-1789
_______________________________________________
Mobile-l mailing list
Mobile-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mobile-l