Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B0558D9CE for ; Tue, 4 Sep 2012 15:11:23 +0000 (UTC) Received: (qmail 36430 invoked by uid 500); 4 Sep 2012 15:11:23 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 36397 invoked by uid 500); 4 Sep 2012 15:11:23 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 36386 invoked by uid 99); 4 Sep 2012 15:11:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2012 15:11:23 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FRT_ADOBE2,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of agrieve@google.com designates 209.85.223.175 as permitted sender) Received: from [209.85.223.175] (HELO mail-ie0-f175.google.com) (209.85.223.175) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2012 15:11:17 +0000 Received: by iebc11 with SMTP id c11so5255486ieb.6 for ; Tue, 04 Sep 2012 08:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record; bh=I69uErRjrydlCiqAvxd3ojyJch2peTwgBy4aX6Ut+fo=; b=ijnTKdl8UV5jAtst+RaB4QtdFRUEqDQqW24aIkz13ycxRgxh8BBz5d1dQtMrhmxPiA 6nrov/uI4AltPfadw8IjNL/bOtbCVvLVZalHWfqfYMkpIFZP9VuQ/e5HeWTKhumlRtrn deCEoEWEk2KAY0kEoBNkYtnjgJwzpHyEhzYKF1M6RmcFk9jnlrWf5WvCgfIMAS9l2Wge fSlTh1APe3AWt3DjASjRI3gDEZqe8uXp2VTQ3YzNOjs3LZu9g9FLw8Xuc6WPw0qfc3Sq QCZJJyguh0c6owg6VClyIxzns+R6v2ztflFQTb3tRBjr14Hp9W/8PTvNTMUZnu4DOi9M nAQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record:x-gm-message-state; bh=I69uErRjrydlCiqAvxd3ojyJch2peTwgBy4aX6Ut+fo=; b=c6BH0rdfhzucz8+xT41B1ljZ0HASELfoq6nPjN+xe8eSUX7rwjPVdXFVb/7wnmXvLB TIOvL7BO7PC+Rls+U1Giw/6mOnC4FaThtfh7WnxW52YusCT07J/w5IlY3xseIIWJ8qZn 9uG0eZe7sSHZDHYalFqNb1WtXXsZSa9UIaT2N6dXVWU0Scnuw7RT/ZO7toQ8d8OEeJEQ 02NmXAjHVrzaIfG1In2176/AiWOlWtPSRbGoLQ42fboKrpzGDZP87f9+PW1JjsPrpPOn i9v2eWc6ou0F4yXsqQWwFuZTT4ogPc6k+uVzWouHLE5wgWITrzce+XEdlFKcVg97Kavn 3qQw== Received: by 10.182.190.69 with SMTP id go5mr16669427obc.43.1346771456434; Tue, 04 Sep 2012 08:10:56 -0700 (PDT) Received: by 10.182.190.69 with SMTP id go5mr16669425obc.43.1346771456322; Tue, 04 Sep 2012 08:10:56 -0700 (PDT) MIME-Version: 1.0 Sender: agrieve@google.com Received: by 10.182.125.71 with HTTP; Tue, 4 Sep 2012 08:10:36 -0700 (PDT) In-Reply-To: References: From: Andrew Grieve Date: Tue, 4 Sep 2012 11:10:36 -0400 X-Google-Sender-Auth: L40_BMiagT3vqRGTg0Y_Mkjw1RI Message-ID: Subject: Re: online events To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=f46d04426d223f6d8904c8e1aa37 X-System-Of-Record: true X-Gm-Message-State: ALoCoQklmRlyFIki/QchgMBA7qaJdHiCs9jlQniz1GDk29bZzr2H9ePNyDmaTtnaLVDRw6xO/0KS9QzjOGXh/l/ffXyoohQgR/5eVsmcHQ1CuswekUjAtIoB2bKmJ8wJy8SnqgW63CPi/SoT3w9sbsYW69NBiqambJRpL2AbZ4rxk4q6nPqcqhHqwlacX+Ez4xuCgdWfha4W3kdhYfGw1adQvwHDWfooQw== --f46d04426d223f6d8904c8e1aa37 Content-Type: text/plain; charset=ISO-8859-1 __proto__ just sets the prototype of an object. It's non-standard and IE doesn't support it, but the following is equivalent: function ClassWithNavigatorAsPrototype() {} ClassWithNavigatorAsPrototype.prototype = navigator; var newNavigator = new ClassWithNavigatorAsPrototype(); The idea is that we're not trying to overwrite onLine or connection. We're overwriting window.navigator with an object that has the old navigator in it's prototype chain. I'll make a bug to put this into bootstrap.js post 2.1. On Mon, Sep 3, 2012 at 4:29 PM, Brian LeRoux wrote: > waaaaaat! how is this working? > > does the __proto__ allow to hack around writable data descriptor? > > (awesome stuff andrew) > > > On Sat, Sep 1, 2012 at 8:26 AM, Andrew Grieve > wrote: > > Figured out a work-around for clobbering things on navigator on Android > > (tested on 2.1 and 2.3): > > > > var newNavigator = {}; > > newNavigator.__proto__ = navigator; > > newNavigator.__defineGetter__('onLine', function() { > > return network.type != 'none'; > > }); > > newNavigator.connection = {type: 'wifi'}; > > window.navigator = newNavigator; > > > > I'll hook this up so that connection and onLine will work properly > (woohoo!) > > > > As for events, I don't think document.body is common, but I think > > window.addEventListener is quite common since it works on both mobile > > safari and android browser. I'll add this to the API review list on the > > wiki, but I do need to do something here in the short term since I need > to > > listen to the browser-fired window online/offline events to implement the > > ONLINE_EVENTS exec bridge. How about just put in an android > > only work-around for now: > > > > cordova.addWindowEventHandler('online'); > > cordova.addWindowEventHandler('offline'); > > function proxyEvent(e) { cordova.fireWindowEvent(e.type); } > > document.addEventListener('online', proxyEvent, false); > > document.addEventListener('offline', proxyEvent, false); > > > > > > > > > > On Fri, Aug 31, 2012 at 4:27 PM, Filip Maj wrote: > > > >> My vote is to keep what we currently document > (document.addEventListener) > >> - for now. > >> > >> We should be compiling an "API Review List" on the wiki or something and > >> taking notes of all these spec changes, and recommended implementation > >> routes for the project. > >> > >> On 8/31/12 1:21 PM, "Simon MacDonald" > wrote: > >> > >> >Yeah, specs change. Here is the one we originally implemented: > >> > > >> >http://www.w3.org/TR/netinfo-api/ > >> > > >> >sharp eyes will note they are using navigator.connection.type and we > are > >> >using navigator.network.connection.type. That's because the Android web > >> >view would not allow us to over-ride navigator.connection. It seems to > be > >> >a > >> >read only object. > >> > > >> >Simon Mac Donald > >> >http://hi.im/simonmacdonald > >> > > >> > > >> >On Fri, Aug 31, 2012 at 3:49 PM, Andrew Grieve > >> wrote: > >> > > >> >> It looks like there is code in network.js that fire online & offline > >> >>events > >> >> when the network status changes. On any platform that already > supports > >> >> online events, the browser will fire an event, and then the network > >> >>plugin > >> >> will also fire an event. > >> >> > >> >> There is also the fact that the event is fired only on document. The > >> >>spec > >> >> says that listening on window should work as well (as well as > >> >> document.body): http://www.whatwg.org/specs/web-apps/current-work/ > >> >> > >> >> I made a test page: > >> >> https://dl.dropbox.com/u/6648754/webtests/online_events.html > >> >> Running it on android browser shows that the only two listener > methods > >> >>that > >> >> work are: > >> >> -window.addEventListener > >> >> -document.body.ononline = > >> >> > >> >> So, clearly it's a bit broken. I'm wondering though, if we should do > >> >>some > >> >> clean-up with these events. > >> >> > >> >> Options: > >> >> > >> >> 1. Live with duplicate events for browsers that support them, but > also > >> >>fire > >> >> them on document.body and window. > >> >> 2. Don't fire online/offline events from this plugin. Fire a custom > >> >> "networktypechange" event > >> >> 3. Intercept all event registration an window/document/body so that > the > >> >> browser's native events don't take effect. Have the only source of > these > >> >> events be the network plugin. > >> >> > >> >> > >> >> Votes? Comments? > >> >> > >> > >> > --f46d04426d223f6d8904c8e1aa37--