Closed Bug 648585 Opened 13 years ago Closed 13 years ago

nsIHapticFeedback not defined on desktop build of fennec

Categories

(Firefox for Android Graveyard :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 8

People

(Reporter: aamariutei, Assigned: dougt)

Details

(Whiteboard: QA?)

Attachments

(1 file, 1 obsolete file)

@ dougt's request, when using nsIHapticFeedback in a Fennec desktop build, it should fail and give back a NOT IMPLEMENTED feedback.
Attached patch patch v.1 (obsolete) — Splinter Review
Attachment #534983 - Flags: review?(Olli.Pettay)
Comment on attachment 534983 [details] [diff] [review]
patch v.1

>+++ b/dom/system/unix/nsHapticFeedback.cpp
>@@ -81,11 +81,11 @@ nsHapticFeedback::PerformSimpleAction(PR
>         dbus_connection_flush(connection);
>         dbus_message_unref(msg);
>     } else {
>         dbus_message_unref(msg);
>         return NS_ERROR_FAILURE;
>     }
>     return NS_OK;
> #else
>-    return NS_ERROR_NOT_IMPLEMENTED;
>+    return NS_OK;
> #endif
> }

I don't understand. Comment 0 says 
" it should fail and give back a NOT IMPLEMENTED feedback"
but you're changing it to return NS_OK.

Btw

return NS_OK;
#else
return NS_OK;
#endif

looks a bit silly :)



>diff --git a/dom/system/windows/Makefile.in b/dom/system/windows/Makefile.in
>--- a/dom/system/windows/Makefile.in
>+++ b/dom/system/windows/Makefile.in
>@@ -48,11 +48,12 @@ LIBRARY_NAME    = domsystemwindows_s
> LIBXUL_LIBRARY   = 1
> FORCE_STATIC_LIB = 1
> EXPORT_LIBRARY = 1
> 
> include $(topsrcdir)/config/config.mk
> 
> CPPSRCS     = \
>         nsAccelerometerSystem.cpp \
>+        nsHapticFeedback.cpp \
So this is using which nsHapticFeedback.cpp file?
Attachment #534983 - Flags: review?(Olli.Pettay) → review-
i do not think that calling this interface from script should ever throw -- so changing the return result to NS_OK is what I wanted to do.

There is a noop nsHapticFeedback.cpp in each platform directory.
olli, did you want to see another patch, or should I just make the change to the #ifdef
Attached patch patch v.1Splinter Review
entire patch w/ ifdef fixup
Attachment #534983 - Attachment is obsolete: true
Attachment #544727 - Flags: review?(Olli.Pettay)
Attachment #544727 - Flags: review?(Olli.Pettay) → review+
http://hg.mozilla.org/mozilla-central/rev/75a6aae6dd4d
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 8
Doing : Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nsIHapticFeedback).performSimpleAction(Components.interface.nsIHapticFeedback.LongPress) in error console, I get:

Components.classes['@mozilla.org/widget/hapticfeedback;1'] is undefined
javascript:%20Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nsIHapticFeedback).performSimpleAction(Components.interface.nsIHapticFeedback.LongPress)
1

I get an uncaught exception when executing the same code on android:
uncaught exception: [Exception... "Component returned failure code: 0x80570018 (NS_ERROR_XPC_BAD_IID) [nsIJSCID.getService]"  nsresult: "0x80570018 (NS_ERROR_XPC_BAD_IID)"  location: "JS frame :: javascript:%20Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nslHapticFeedback).performSimpleAction(Components.interface.nslHapticFeedback.Longpress) :: <TOP_LEVEL> :: line 1"  data: no]
Turned out that I had a typo on the android.  I get the undefined message when running on android as well as from the desktop.
Correction: 
Running :
Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nsIHapticFeedback).performSimpleAction(Components.interfaces.nsIHapticFeedback.LongPress)

On Android will give a feedback, however on desktop it will give an error:
Components.interface is undefined
javascript:%20Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nsIHapticFeedback).performSimpleAction(Components.interface.nsIHapticFeedback.LongPress)
1
(In reply to comment #11)

> On Android will give a feedback, however on desktop it will give an error:
> Components.interface is undefined
> javascript:%20Components.classes["@mozilla.org/widget/hapticfeedback;1"].
> getService(Components.interfaces.nsIHapticFeedback).
> performSimpleAction(Components.interface.nsIHapticFeedback.LongPress)
> 1

There is a typo in the code:
performSimpleAction(Components.interface.nsIHapticFeedback.LongPress)

should be:
performSimpleAction(Components.interfaces.nsIHapticFeedback.LongPress)
Components.classes['@mozilla.org/widget/hapticfeedback;1'] is undefined
javascript:%20Components.classes["@mozilla.org/widget/hapticfeedback;1"].getService(Components.interfaces.nsIHapticFeedback).performSimpleAction(Components.interfaces.nsIHapticFeedback.LongPress)
1
Whiteboard: QA?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: