Closed Bug 841708 Opened 11 years ago Closed 11 years ago

moztimechange/timechange event feature detection

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: bruant.d, Unassigned)

References

Details

Currently, I don't think there is a legitimate way to feature-detect the existence of the moztimechange/timechange event from an app. A heuristic would be detecting the presence of the Time/mozTime property on the navigator, but that's a heuristic and the property may be absent (bug 838614) in low-privilege contexts.

I don't have a good idea to solve this problem. I think it's equivalent to feature-detecting DOMContentLoaded (which also doesn't have a solution).

Thoughts?
Blocks: 714358
If mozTime is available, the event should always be available.
The question is "if mozTime isn't available", can the event be available. The answer is yes for installed apps, but there is no way to detect it.
Sorry, I was under the assumption that the event was being fired on the mozTime object. I guess we could have an event handler on the document so the presence of .ontimechange on the document would mean that there is an event being supported.

But generally speaking, this problem is about the general "how to know if an event is supported" problem. I guess Olli might have some insights regarding this.
(In reply to David Bruant from comment #2)
> The question is "if mozTime isn't available", can the event be available.
> The answer is yes for installed apps, but there is no way to detect it.
Why is the event available in that case? That sounds like a bug.
(In reply to Olli Pettay [:smaug] from comment #4)
> (In reply to David Bruant from comment #2)
> > The question is "if mozTime isn't available", can the event be available.
> > The answer is yes for installed apps, but there is no way to detect it.
> Why is the event available in that case? That sounds like a bug.

No, it is not because 'timechange' event doesn't require any permission given that its an information already available by polling Date(). However, mozTime allows you to call set(), that is something we do not want to be accessed by anyone.
Ah, ok.
Well, in such case there isn't any way to detect the feature, indeed.
And the platform in general doesn't provide any good way.
(In reply to Olli Pettay [:smaug] from comment #6)
> Ah, ok.
> Well, in such case there isn't any way to detect the feature, indeed.
> And the platform in general doesn't provide any good way.

Wouldn't a event handler (like 'ontimechange') help here?
Indeed, checking for the existence of on* is what we've used elsewhere. That's what we were promoting for detecting support for the hashchange event for example.

I don't know if that works here, if not, we should make that work. I.e. 

if ("ontimechange" in window) {
  ....
}

should IMO work.
(In reply to Jonas Sicking (:sicking) from comment #9)
> Indeed, checking for the existence of on* is what we've used elsewhere.
> That's what we were promoting for detecting support for the hashchange event
> for example.
> 
> I don't know if that works here, if not, we should make that work. I.e. 
> 
> if ("ontimechange" in window) {
>   ....
> }
> 
> should IMO work.

I think the event is sent on "document" though. I don't think we have an event handler for this event. Do we have any event handler on document?
(In reply to Mounir Lamouri (:mounir) from comment #10)
> (In reply to Jonas Sicking (:sicking) from comment #9)
> > Indeed, checking for the existence of on* is what we've used elsewhere.
> > That's what we were promoting for detecting support for the hashchange event
> > for example.
> > 
> > I don't know if that works here, if not, we should make that work. I.e. 
> > 
> > if ("ontimechange" in window) {
> >   ....
> > }
> > 
> > should IMO work.
> 
> I think the event is sent on "document" though. I don't think we have an
> event handler for this event. Do we have any event handler on document?

Oups, haven't seen comment 8. Seems like this is RESOLVED WFM then.
Status: NEW → RESOLVED
Closed: 11 years ago
OS: Linux → All
Hardware: x86 → All
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.