diff options
Diffstat (limited to 'widget')
154 files changed, 20 insertions, 48650 deletions
diff --git a/widget/CompositorWidget.h b/widget/CompositorWidget.h index 93269eac6..eb657ba7f 100644 --- a/widget/CompositorWidget.h +++ b/widget/CompositorWidget.h @@ -30,7 +30,6 @@ namespace widget { class WinCompositorWidget; class X11CompositorWidget; -class AndroidCompositorWidget; class CompositorWidgetInitData; // Gecko widgets usually need to communicate with the CompositorWidget with @@ -56,12 +55,9 @@ class CompositorWidgetChild; class WidgetRenderingContext { public: -#if defined(XP_MACOSX) +#ifdef XP_MACOSX WidgetRenderingContext() : mLayerManager(nullptr) {} layers::LayerManagerComposite* mLayerManager; -#elif defined(MOZ_WIDGET_ANDROID) - WidgetRenderingContext() : mCompositor(nullptr) {} - layers::Compositor* mCompositor; #endif }; @@ -262,9 +258,6 @@ public: virtual X11CompositorWidget* AsX11() { return nullptr; } - virtual AndroidCompositorWidget* AsAndroid() { - return nullptr; - } /** * Return the platform-specific delegate for the widget, if any. diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 890a26dcd..7ff16c484 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -379,9 +379,6 @@ NS_EVENT_MESSAGE(eDeviceMotion) NS_EVENT_MESSAGE(eDeviceProximity) NS_EVENT_MESSAGE(eUserProximity) NS_EVENT_MESSAGE(eDeviceLight) -#if defined(MOZ_WIDGET_ANDROID) -NS_EVENT_MESSAGE(eOrientationChange) -#endif // WebVR events NS_EVENT_MESSAGE(eVRDisplayConnect) diff --git a/widget/GfxDriverInfo.h b/widget/GfxDriverInfo.h index 99d560b81..256142c87 100644 --- a/widget/GfxDriverInfo.h +++ b/widget/GfxDriverInfo.h @@ -58,7 +58,6 @@ enum class OperatingSystem { OSX10_10, OSX10_11, OSX10_12, - Android, Ios }; @@ -283,12 +282,6 @@ ParseDriverVersion(const nsAString& aVersion, uint64_t *aNumericVersion) *aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d); MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions); return true; -#elif defined(ANDROID) - // Can't use aVersion.ToInteger() because that's not compiled into our code - // unless we have XPCOM_GLUE_AVOID_NSPR disabled. - *aNumericVersion = atoi(NS_LossyConvertUTF16toASCII(aVersion).get()); - MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions); - return true; #else return false; #endif diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index e20de8277..4c2d83018 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -274,8 +274,6 @@ BlacklistOSToOperatingSystem(const nsAString& os) return OperatingSystem::OSX10_11; else if (os.EqualsLiteral("Darwin 16")) return OperatingSystem::OSX10_12; - else if (os.EqualsLiteral("Android")) - return OperatingSystem::Android; // For historical reasons, "All" in blocklist means "All Windows" else if (os.EqualsLiteral("All")) return OperatingSystem::Windows; @@ -691,7 +689,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info, } } -#if defined(XP_WIN) || defined(ANDROID) +#ifdef XP_WIN uint64_t driverVersion; ParseDriverVersion(adapterDriverVersionString, &driverVersion); #endif @@ -730,7 +728,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info, continue; } -#if defined(XP_WIN) || defined(ANDROID) +#ifdef XP_WIN switch (info[i].mComparisonOp) { case DRIVER_LESS_THAN: match = driverVersion < info[i].mDriverVersion; diff --git a/widget/InProcessCompositorWidget.cpp b/widget/InProcessCompositorWidget.cpp index 9b301fc48..df7250d9f 100644 --- a/widget/InProcessCompositorWidget.cpp +++ b/widget/InProcessCompositorWidget.cpp @@ -5,10 +5,6 @@ #include "InProcessCompositorWidget.h" #include "nsBaseWidget.h" -#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING) -#include "mozilla/widget/AndroidCompositorWidget.h" -#endif - namespace mozilla { namespace widget { @@ -19,11 +15,7 @@ namespace widget { CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget) { MOZ_ASSERT(aWidget); -#ifdef MOZ_WIDGET_ANDROID - return new AndroidCompositorWidget(static_cast<nsBaseWidget*>(aWidget)); -#else return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget)); -#endif } #endif diff --git a/widget/NativeKeyToDOMCodeName.h b/widget/NativeKeyToDOMCodeName.h index cd326a0d8..159b0773c 100644 --- a/widget/NativeKeyToDOMCodeName.h +++ b/widget/NativeKeyToDOMCodeName.h @@ -21,8 +21,6 @@ #define CODE_MAP_MAC(aCPPCodeName, aNativeKey) // GTK and Qt on Linux #define CODE_MAP_X11(aCPPCodeName, aNativeKey) -// Android and Gonk -#define CODE_MAP_ANDROID(aCPPCodeName, aNativeKey) #if defined(XP_WIN) #undef CODE_MAP_WIN @@ -42,780 +40,613 @@ #define CODE_MAP_X11(aCPPCodeName, aNativeKey) \ NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \ CODE_NAME_INDEX_##aCPPCodeName) -#elif defined(ANDROID) -#undef CODE_MAP_ANDROID -// aNativeKey is scan code -#define CODE_MAP_ANDROID(aCPPCodeName, aNativeKey) \ - NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \ - CODE_NAME_INDEX_##aCPPCodeName) #endif // Writing system keys CODE_MAP_WIN(Backquote, 0x0029) CODE_MAP_MAC(Backquote, kVK_ANSI_Grave) CODE_MAP_X11(Backquote, 0x0031) -CODE_MAP_ANDROID(Backquote, 0x0029) CODE_MAP_WIN(Backslash, 0x002B) CODE_MAP_MAC(Backslash, kVK_ANSI_Backslash) CODE_MAP_X11(Backslash, 0x0033) -CODE_MAP_ANDROID(Backslash, 0x002B) CODE_MAP_WIN(Backspace, 0x000E) CODE_MAP_MAC(Backspace, kVK_Delete) CODE_MAP_X11(Backspace, 0x0016) -CODE_MAP_ANDROID(Backspace, 0x000E) CODE_MAP_WIN(BracketLeft, 0x001A) CODE_MAP_MAC(BracketLeft, kVK_ANSI_LeftBracket) CODE_MAP_X11(BracketLeft, 0x0022) -CODE_MAP_ANDROID(BracketLeft, 0x001A) CODE_MAP_WIN(BracketRight, 0x001B) CODE_MAP_MAC(BracketRight, kVK_ANSI_RightBracket) CODE_MAP_X11(BracketRight, 0x0023) -CODE_MAP_ANDROID(BracketRight, 0x001B) CODE_MAP_WIN(Comma, 0x0033) CODE_MAP_MAC(Comma, kVK_ANSI_Comma) CODE_MAP_X11(Comma, 0x003B) -CODE_MAP_ANDROID(Comma, 0x00033) CODE_MAP_WIN(Digit0, 0x000B) CODE_MAP_MAC(Digit0, kVK_ANSI_0) CODE_MAP_X11(Digit0, 0x0013) -CODE_MAP_ANDROID(Digit0, 0x000B) CODE_MAP_WIN(Digit1, 0x0002) CODE_MAP_MAC(Digit1, kVK_ANSI_1) CODE_MAP_X11(Digit1, 0x000A) -CODE_MAP_ANDROID(Digit1, 0x0002) CODE_MAP_WIN(Digit2, 0x0003) CODE_MAP_MAC(Digit2, kVK_ANSI_2) CODE_MAP_X11(Digit2, 0x000B) -CODE_MAP_ANDROID(Digit2, 0x0003) CODE_MAP_WIN(Digit3, 0x0004) CODE_MAP_MAC(Digit3, kVK_ANSI_3) CODE_MAP_X11(Digit3, 0x000C) -CODE_MAP_ANDROID(Digit3, 0x0004) CODE_MAP_WIN(Digit4, 0x0005) CODE_MAP_MAC(Digit4, kVK_ANSI_4) CODE_MAP_X11(Digit4, 0x000D) -CODE_MAP_ANDROID(Digit4, 0x0005) CODE_MAP_WIN(Digit5, 0x0006) CODE_MAP_MAC(Digit5, kVK_ANSI_5) CODE_MAP_X11(Digit5, 0x000E) -CODE_MAP_ANDROID(Digit5, 0x0006) CODE_MAP_WIN(Digit6, 0x0007) CODE_MAP_MAC(Digit6, kVK_ANSI_6) CODE_MAP_X11(Digit6, 0x000F) -CODE_MAP_ANDROID(Digit6, 0x0007) CODE_MAP_WIN(Digit7, 0x0008) CODE_MAP_MAC(Digit7, kVK_ANSI_7) CODE_MAP_X11(Digit7, 0x0010) -CODE_MAP_ANDROID(Digit7, 0x0008) CODE_MAP_WIN(Digit8, 0x0009) CODE_MAP_MAC(Digit8, kVK_ANSI_8) CODE_MAP_X11(Digit8, 0x0011) -CODE_MAP_ANDROID(Digit8, 0x0009) CODE_MAP_WIN(Digit9, 0x000A) CODE_MAP_MAC(Digit9, kVK_ANSI_9) CODE_MAP_X11(Digit9, 0x0012) -CODE_MAP_ANDROID(Digit9, 0x000A) CODE_MAP_WIN(Equal, 0x000D) CODE_MAP_MAC(Equal, kVK_ANSI_Equal) CODE_MAP_X11(Equal, 0x0015) -CODE_MAP_ANDROID(Equal, 0x000D) CODE_MAP_WIN(IntlBackslash, 0x0056) CODE_MAP_MAC(IntlBackslash, kVK_ISO_Section) CODE_MAP_X11(IntlBackslash, 0x005E) -CODE_MAP_ANDROID(IntlBackslash, 0x0056) // Win: IntlHash's scan code is shared with "Backslash" key. // Mac: IntlHash's virtual key code is shared with "Backslash" key. // X11: IntlHash's scan code is shared with "Backslash" key. -// Android: IntlHash's scan code is shared with "Backslash" key. CODE_MAP_WIN(IntlRo, 0x0073) CODE_MAP_MAC(IntlRo, kVK_JIS_Underscore) CODE_MAP_X11(IntlRo, 0x0061) -CODE_MAP_ANDROID(IntlRo, 0x0059) CODE_MAP_WIN(IntlYen, 0x007D) CODE_MAP_MAC(IntlYen, kVK_JIS_Yen) CODE_MAP_X11(IntlYen, 0x0084) -CODE_MAP_ANDROID(IntlYen, 0x007C) CODE_MAP_WIN(KeyA, 0x001E) CODE_MAP_MAC(KeyA, kVK_ANSI_A) CODE_MAP_X11(KeyA, 0x0026) -CODE_MAP_ANDROID(KeyA, 0x001E) CODE_MAP_WIN(KeyB, 0x0030) CODE_MAP_MAC(KeyB, kVK_ANSI_B) CODE_MAP_X11(KeyB, 0x0038) -CODE_MAP_ANDROID(KeyB, 0x0030) CODE_MAP_WIN(KeyC, 0x002E) CODE_MAP_MAC(KeyC, kVK_ANSI_C) CODE_MAP_X11(KeyC, 0x0036) -CODE_MAP_ANDROID(KeyC, 0x002E) CODE_MAP_WIN(KeyD, 0x0020) CODE_MAP_MAC(KeyD, kVK_ANSI_D) CODE_MAP_X11(KeyD, 0x0028) -CODE_MAP_ANDROID(KeyD, 0x0020) CODE_MAP_WIN(KeyE, 0x0012) CODE_MAP_MAC(KeyE, kVK_ANSI_E) CODE_MAP_X11(KeyE, 0x001A) -CODE_MAP_ANDROID(KeyE, 0x0012) CODE_MAP_WIN(KeyF, 0x0021) CODE_MAP_MAC(KeyF, kVK_ANSI_F) CODE_MAP_X11(KeyF, 0x0029) -CODE_MAP_ANDROID(KeyF, 0x0021) CODE_MAP_WIN(KeyG, 0x0022) CODE_MAP_MAC(KeyG, kVK_ANSI_G) CODE_MAP_X11(KeyG, 0x002A) -CODE_MAP_ANDROID(KeyG, 0x0022) CODE_MAP_WIN(KeyH, 0x0023) CODE_MAP_MAC(KeyH, kVK_ANSI_H) CODE_MAP_X11(KeyH, 0x002B) -CODE_MAP_ANDROID(KeyH, 0x0023) CODE_MAP_WIN(KeyI, 0x0017) CODE_MAP_MAC(KeyI, kVK_ANSI_I) CODE_MAP_X11(KeyI, 0x001F) -CODE_MAP_ANDROID(KeyI, 0x0017) CODE_MAP_WIN(KeyJ, 0x0024) CODE_MAP_MAC(KeyJ, kVK_ANSI_J) CODE_MAP_X11(KeyJ, 0x002C) -CODE_MAP_ANDROID(KeyJ, 0x0024) CODE_MAP_WIN(KeyK, 0x0025) CODE_MAP_MAC(KeyK, kVK_ANSI_K) CODE_MAP_X11(KeyK, 0x002D) -CODE_MAP_ANDROID(KeyK, 0x0025) CODE_MAP_WIN(KeyL, 0x0026) CODE_MAP_MAC(KeyL, kVK_ANSI_L) CODE_MAP_X11(KeyL, 0x002E) -CODE_MAP_ANDROID(KeyL, 0x0026) CODE_MAP_WIN(KeyM, 0x0032) CODE_MAP_MAC(KeyM, kVK_ANSI_M) CODE_MAP_X11(KeyM, 0x003A) -CODE_MAP_ANDROID(KeyM, 0x0032) CODE_MAP_WIN(KeyN, 0x0031) CODE_MAP_MAC(KeyN, kVK_ANSI_N) CODE_MAP_X11(KeyN, 0x0039) -CODE_MAP_ANDROID(KeyN, 0x0031) CODE_MAP_WIN(KeyO, 0x0018) CODE_MAP_MAC(KeyO, kVK_ANSI_O) CODE_MAP_X11(KeyO, 0x0020) -CODE_MAP_ANDROID(KeyO, 0x0018) CODE_MAP_WIN(KeyP, 0x0019) CODE_MAP_MAC(KeyP, kVK_ANSI_P) CODE_MAP_X11(KeyP, 0x0021) -CODE_MAP_ANDROID(KeyP, 0x0019) CODE_MAP_WIN(KeyQ, 0x0010) CODE_MAP_MAC(KeyQ, kVK_ANSI_Q) CODE_MAP_X11(KeyQ, 0x0018) -CODE_MAP_ANDROID(KeyQ, 0x0010) CODE_MAP_WIN(KeyR, 0x0013) CODE_MAP_MAC(KeyR, kVK_ANSI_R) CODE_MAP_X11(KeyR, 0x001B) -CODE_MAP_ANDROID(KeyR, 0x0013) CODE_MAP_WIN(KeyS, 0x001F) CODE_MAP_MAC(KeyS, kVK_ANSI_S) CODE_MAP_X11(KeyS, 0x0027) -CODE_MAP_ANDROID(KeyS, 0x001F) CODE_MAP_WIN(KeyT, 0x0014) CODE_MAP_MAC(KeyT, kVK_ANSI_T) CODE_MAP_X11(KeyT, 0x001C) -CODE_MAP_ANDROID(KeyT, 0x0014) CODE_MAP_WIN(KeyU, 0x0016) CODE_MAP_MAC(KeyU, kVK_ANSI_U) CODE_MAP_X11(KeyU, 0x001E) -CODE_MAP_ANDROID(KeyU, 0x0016) CODE_MAP_WIN(KeyV, 0x002F) CODE_MAP_MAC(KeyV, kVK_ANSI_V) CODE_MAP_X11(KeyV, 0x0037) -CODE_MAP_ANDROID(KeyV, 0x002F) CODE_MAP_WIN(KeyW, 0x0011) CODE_MAP_MAC(KeyW, kVK_ANSI_W) CODE_MAP_X11(KeyW, 0x0019) -CODE_MAP_ANDROID(KeyW, 0x0011) CODE_MAP_WIN(KeyX, 0x002D) CODE_MAP_MAC(KeyX, kVK_ANSI_X) CODE_MAP_X11(KeyX, 0x0035) -CODE_MAP_ANDROID(KeyX, 0x002D) CODE_MAP_WIN(KeyY, 0x0015) CODE_MAP_MAC(KeyY, kVK_ANSI_Y) CODE_MAP_X11(KeyY, 0x001D) -CODE_MAP_ANDROID(KeyY, 0x0015) CODE_MAP_WIN(KeyZ, 0x002C) CODE_MAP_MAC(KeyZ, kVK_ANSI_Z) CODE_MAP_X11(KeyZ, 0x0034) -CODE_MAP_ANDROID(KeyZ, 0x002C) CODE_MAP_WIN(Minus, 0x000C) CODE_MAP_MAC(Minus, kVK_ANSI_Minus) CODE_MAP_X11(Minus, 0x0014) -CODE_MAP_ANDROID(Minus, 0x000C) CODE_MAP_WIN(Period, 0x0034) CODE_MAP_MAC(Period, kVK_ANSI_Period) CODE_MAP_X11(Period, 0x003C) -CODE_MAP_ANDROID(Period, 0x0034) CODE_MAP_WIN(Quote, 0x0028) CODE_MAP_MAC(Quote, kVK_ANSI_Quote) CODE_MAP_X11(Quote, 0x0030) -CODE_MAP_ANDROID(Quote, 0x0028) CODE_MAP_WIN(Semicolon, 0x0027) CODE_MAP_MAC(Semicolon, kVK_ANSI_Semicolon) CODE_MAP_X11(Semicolon, 0x002F) -CODE_MAP_ANDROID(Semicolon, 0x0027) CODE_MAP_WIN(Slash, 0x0035) CODE_MAP_MAC(Slash, kVK_ANSI_Slash) CODE_MAP_X11(Slash, 0x003D) -CODE_MAP_ANDROID(Slash, 0x0035) // Functional keys CODE_MAP_WIN(AltLeft, 0x0038) CODE_MAP_MAC(AltLeft, kVK_Option) CODE_MAP_X11(AltLeft, 0x0040) -CODE_MAP_ANDROID(AltLeft, 0x0038) CODE_MAP_WIN(AltRight, 0xE038) CODE_MAP_MAC(AltRight, kVK_RightOption) CODE_MAP_X11(AltRight, 0x006C) -CODE_MAP_ANDROID(AltRight, 0x0064) CODE_MAP_WIN(CapsLock, 0x003A) CODE_MAP_MAC(CapsLock, kVK_CapsLock) CODE_MAP_X11(CapsLock, 0x0042) -CODE_MAP_ANDROID(CapsLock, 0x003A) CODE_MAP_WIN(ContextMenu, 0xE05D) CODE_MAP_MAC(ContextMenu, kVK_PC_ContextMenu) CODE_MAP_X11(ContextMenu, 0x0087) -CODE_MAP_ANDROID(ContextMenu, 0x007F) CODE_MAP_WIN(ControlLeft, 0x001D) CODE_MAP_MAC(ControlLeft, kVK_Control) CODE_MAP_X11(ControlLeft, 0x0025) -CODE_MAP_ANDROID(ControlLeft, 0x001D) CODE_MAP_WIN(ControlRight, 0xE01D) CODE_MAP_MAC(ControlRight, kVK_RightControl) CODE_MAP_X11(ControlRight, 0x0069) -CODE_MAP_ANDROID(ControlRight, 0x0061) CODE_MAP_WIN(Enter, 0x001C) CODE_MAP_MAC(Enter, kVK_Return) CODE_MAP_X11(Enter, 0x0024) -CODE_MAP_ANDROID(Enter, 0x001C) CODE_MAP_WIN(OSLeft, 0xE05B) CODE_MAP_MAC(OSLeft, kVK_Command) CODE_MAP_X11(OSLeft, 0x0085) -CODE_MAP_ANDROID(OSLeft, 0x007D) CODE_MAP_WIN(OSRight, 0xE05C) CODE_MAP_MAC(OSRight, kVK_RightCommand) CODE_MAP_X11(OSRight, 0x0086) -CODE_MAP_ANDROID(OSRight, 0x007E) CODE_MAP_WIN(ShiftLeft, 0x002A) CODE_MAP_MAC(ShiftLeft, kVK_Shift) CODE_MAP_X11(ShiftLeft, 0x0032) -CODE_MAP_ANDROID(ShiftLeft, 0x002A) CODE_MAP_WIN(ShiftRight, 0x0036) CODE_MAP_MAC(ShiftRight, kVK_RightShift) CODE_MAP_X11(ShiftRight, 0x003E) -CODE_MAP_ANDROID(ShiftRight, 0x0036) CODE_MAP_WIN(Space, 0x0039) CODE_MAP_MAC(Space, kVK_Space) CODE_MAP_X11(Space, 0x0041) -CODE_MAP_ANDROID(Space, 0x0039) CODE_MAP_WIN(Tab, 0x000F) CODE_MAP_MAC(Tab, kVK_Tab) CODE_MAP_X11(Tab, 0x0017) -CODE_MAP_ANDROID(Tab, 0x000F) // IME keys CODE_MAP_WIN(Convert, 0x0079) CODE_MAP_X11(Convert, 0x0064) -CODE_MAP_ANDROID(Convert, 0x005C) CODE_MAP_WIN(Lang1, 0x0072) // for non-Korean layout CODE_MAP_WIN(Lang1, 0xE0F2) // for Korean layout CODE_MAP_MAC(Lang1, kVK_JIS_Kana) CODE_MAP_X11(Lang1, 0x0082) -CODE_MAP_ANDROID(Lang1, 0x007A) CODE_MAP_WIN(Lang2, 0x0071) // for non-Korean layout CODE_MAP_WIN(Lang2, 0xE0F1) // for Korean layout CODE_MAP_MAC(Lang2, kVK_JIS_Eisu) CODE_MAP_X11(Lang2, 0x0083) -CODE_MAP_ANDROID(Lang2, 0x007B) CODE_MAP_WIN(KanaMode, 0x0070) CODE_MAP_X11(KanaMode, 0x0065) -CODE_MAP_ANDROID(KanaMode, 0x005D) CODE_MAP_WIN(NonConvert, 0x007B) CODE_MAP_X11(NonConvert, 0x0066) -CODE_MAP_ANDROID(NonConvert, 0x005E) // Control pad section CODE_MAP_WIN(Delete, 0xE053) CODE_MAP_MAC(Delete, kVK_ForwardDelete) CODE_MAP_X11(Delete, 0x0077) -CODE_MAP_ANDROID(Delete, 0x006F) CODE_MAP_WIN(End, 0xE04F) CODE_MAP_MAC(End, kVK_End) CODE_MAP_X11(End, 0x0073) -CODE_MAP_ANDROID(End, 0x006B) CODE_MAP_MAC(Help, kVK_Help) // Insert key on PC keyboard CODE_MAP_X11(Help, 0x0092) // Help key on Sun keyboard -CODE_MAP_ANDROID(Help, 0x008A) // Help key on Sun keyboard CODE_MAP_WIN(Home, 0xE047) CODE_MAP_MAC(Home, kVK_Home) CODE_MAP_X11(Home, 0x006E) -CODE_MAP_ANDROID(Home, 0x0066) CODE_MAP_WIN(Insert, 0xE052) CODE_MAP_X11(Insert, 0x0076) -CODE_MAP_ANDROID(Insert, 0x006E) CODE_MAP_WIN(PageDown, 0xE051) CODE_MAP_MAC(PageDown, kVK_PageDown) CODE_MAP_X11(PageDown, 0x0075) -CODE_MAP_ANDROID(PageDown, 0x006D) CODE_MAP_WIN(PageUp, 0xE049) CODE_MAP_MAC(PageUp, kVK_PageUp) CODE_MAP_X11(PageUp, 0x0070) -CODE_MAP_ANDROID(PageUp, 0x0068) // Arrow pad section CODE_MAP_WIN(ArrowDown, 0xE050) CODE_MAP_MAC(ArrowDown, kVK_DownArrow) CODE_MAP_X11(ArrowDown, 0x0074) -CODE_MAP_ANDROID(ArrowDown, 0x006C) CODE_MAP_WIN(ArrowLeft, 0xE04B) CODE_MAP_MAC(ArrowLeft, kVK_LeftArrow) CODE_MAP_X11(ArrowLeft, 0x0071) -CODE_MAP_ANDROID(ArrowLeft, 0x0069) CODE_MAP_WIN(ArrowRight, 0xE04D) CODE_MAP_MAC(ArrowRight, kVK_RightArrow) CODE_MAP_X11(ArrowRight, 0x0072) -CODE_MAP_ANDROID(ArrowRight, 0x006A) CODE_MAP_WIN(ArrowUp, 0xE048) CODE_MAP_MAC(ArrowUp, kVK_UpArrow) CODE_MAP_X11(ArrowUp, 0x006F) -CODE_MAP_ANDROID(ArrowUp, 0x0067) // Numpad section CODE_MAP_WIN(NumLock, 0xE045) // MSDN says 0x0045, though... CODE_MAP_MAC(NumLock, kVK_ANSI_KeypadClear) CODE_MAP_X11(NumLock, 0x004D) -CODE_MAP_ANDROID(NumLock, 0x0045) CODE_MAP_WIN(Numpad0, 0x0052) CODE_MAP_MAC(Numpad0, kVK_ANSI_Keypad0) CODE_MAP_X11(Numpad0, 0x005A) -CODE_MAP_ANDROID(Numpad0, 0x0052) CODE_MAP_WIN(Numpad1, 0x004F) CODE_MAP_MAC(Numpad1, kVK_ANSI_Keypad1) CODE_MAP_X11(Numpad1, 0x0057) -CODE_MAP_ANDROID(Numpad1, 0x004F) CODE_MAP_WIN(Numpad2, 0x0050) CODE_MAP_MAC(Numpad2, kVK_ANSI_Keypad2) CODE_MAP_X11(Numpad2, 0x0058) -CODE_MAP_ANDROID(Numpad2, 0x0050) CODE_MAP_WIN(Numpad3, 0x0051) CODE_MAP_MAC(Numpad3, kVK_ANSI_Keypad3) CODE_MAP_X11(Numpad3, 0x0059) -CODE_MAP_ANDROID(Numpad3, 0x0051) CODE_MAP_WIN(Numpad4, 0x004B) CODE_MAP_MAC(Numpad4, kVK_ANSI_Keypad4) CODE_MAP_X11(Numpad4, 0x0053) -CODE_MAP_ANDROID(Numpad4, 0x004B) CODE_MAP_WIN(Numpad5, 0x004C) CODE_MAP_MAC(Numpad5, kVK_ANSI_Keypad5) CODE_MAP_X11(Numpad5, 0x0054) -CODE_MAP_ANDROID(Numpad5, 0x004C) CODE_MAP_WIN(Numpad6, 0x004D) CODE_MAP_MAC(Numpad6, kVK_ANSI_Keypad6) CODE_MAP_X11(Numpad6, 0x0055) -CODE_MAP_ANDROID(Numpad6, 0x004D) CODE_MAP_WIN(Numpad7, 0x0047) CODE_MAP_MAC(Numpad7, kVK_ANSI_Keypad7) CODE_MAP_X11(Numpad7, 0x004F) -CODE_MAP_ANDROID(Numpad7, 0x0047) CODE_MAP_WIN(Numpad8, 0x0048) CODE_MAP_MAC(Numpad8, kVK_ANSI_Keypad8) CODE_MAP_X11(Numpad8, 0x0050) -CODE_MAP_ANDROID(Numpad8, 0x0048) CODE_MAP_WIN(Numpad9, 0x0049) CODE_MAP_MAC(Numpad9, kVK_ANSI_Keypad9) CODE_MAP_X11(Numpad9, 0x0051) -CODE_MAP_ANDROID(Numpad9, 0x0049) CODE_MAP_WIN(NumpadAdd, 0x004E) CODE_MAP_MAC(NumpadAdd, kVK_ANSI_KeypadPlus) CODE_MAP_X11(NumpadAdd, 0x0056) -CODE_MAP_ANDROID(NumpadAdd, 0x004E) CODE_MAP_WIN(NumpadComma, 0x007E) CODE_MAP_MAC(NumpadComma, kVK_JIS_KeypadComma) CODE_MAP_X11(NumpadComma, 0x0081) -CODE_MAP_ANDROID(NumpadComma, 0x0079) CODE_MAP_WIN(NumpadDecimal, 0x0053) CODE_MAP_MAC(NumpadDecimal, kVK_ANSI_KeypadDecimal) CODE_MAP_X11(NumpadDecimal, 0x005B) -CODE_MAP_ANDROID(NumpadDecimal, 0x0053) CODE_MAP_WIN(NumpadDivide, 0xE035) CODE_MAP_MAC(NumpadDivide, kVK_ANSI_KeypadDivide) CODE_MAP_X11(NumpadDivide, 0x006A) -CODE_MAP_ANDROID(NumpadDivide, 0x0062) CODE_MAP_WIN(NumpadEnter, 0xE01C) CODE_MAP_MAC(NumpadEnter, kVK_ANSI_KeypadEnter) CODE_MAP_MAC(NumpadEnter, kVK_Powerbook_KeypadEnter) CODE_MAP_X11(NumpadEnter, 0x0068) -CODE_MAP_ANDROID(NumpadEnter, 0x0060) CODE_MAP_WIN(NumpadEqual, 0x0059) CODE_MAP_MAC(NumpadEqual, kVK_ANSI_KeypadEquals) CODE_MAP_X11(NumpadEqual, 0x007D) -CODE_MAP_ANDROID(NumpadEqual, 0x0075) CODE_MAP_WIN(NumpadMultiply, 0x0037) CODE_MAP_MAC(NumpadMultiply, kVK_ANSI_KeypadMultiply) CODE_MAP_X11(NumpadMultiply, 0x003F) -CODE_MAP_ANDROID(NumpadMultiply, 0x0037) CODE_MAP_WIN(NumpadSubtract, 0x004A) CODE_MAP_MAC(NumpadSubtract, kVK_ANSI_KeypadMinus) CODE_MAP_X11(NumpadSubtract, 0x0052) -CODE_MAP_ANDROID(NumpadSubtract, 0x004A) // Function section CODE_MAP_WIN(Escape, 0x0001) CODE_MAP_MAC(Escape, kVK_Escape) CODE_MAP_X11(Escape, 0x0009) -CODE_MAP_ANDROID(Escape, 0x0001) CODE_MAP_WIN(F1, 0x003B) CODE_MAP_MAC(F1, kVK_F1) CODE_MAP_X11(F1, 0x0043) -CODE_MAP_ANDROID(F1, 0x003B) CODE_MAP_WIN(F2, 0x003C) CODE_MAP_MAC(F2, kVK_F2) CODE_MAP_X11(F2, 0x0044) -CODE_MAP_ANDROID(F2, 0x003C) CODE_MAP_WIN(F3, 0x003D) CODE_MAP_MAC(F3, kVK_F3) CODE_MAP_X11(F3, 0x0045) -CODE_MAP_ANDROID(F3, 0x003D) CODE_MAP_WIN(F4, 0x003E) CODE_MAP_MAC(F4, kVK_F4) CODE_MAP_X11(F4, 0x0046) -CODE_MAP_ANDROID(F4, 0x003E) CODE_MAP_WIN(F5, 0x003F) CODE_MAP_MAC(F5, kVK_F5) CODE_MAP_X11(F5, 0x0047) -CODE_MAP_ANDROID(F5, 0x003F) CODE_MAP_WIN(F6, 0x0040) CODE_MAP_MAC(F6, kVK_F6) CODE_MAP_X11(F6, 0x0048) -CODE_MAP_ANDROID(F6, 0x0040) CODE_MAP_WIN(F7, 0x0041) CODE_MAP_MAC(F7, kVK_F7) CODE_MAP_X11(F7, 0x0049) -CODE_MAP_ANDROID(F7, 0x0041) CODE_MAP_WIN(F8, 0x0042) CODE_MAP_MAC(F8, kVK_F8) CODE_MAP_X11(F8, 0x004A) -CODE_MAP_ANDROID(F8, 0x0042) CODE_MAP_WIN(F9, 0x0043) CODE_MAP_MAC(F9, kVK_F9) CODE_MAP_X11(F9, 0x004B) -CODE_MAP_ANDROID(F9, 0x0043) CODE_MAP_WIN(F10, 0x0044) CODE_MAP_MAC(F10, kVK_F10) CODE_MAP_X11(F10, 0x004C) -CODE_MAP_ANDROID(F10, 0x0044) CODE_MAP_WIN(F11, 0x0057) CODE_MAP_MAC(F11, kVK_F11) CODE_MAP_X11(F11, 0x005F) -CODE_MAP_ANDROID(F11, 0x0057) CODE_MAP_WIN(F12, 0x0058) CODE_MAP_MAC(F12, kVK_F12) CODE_MAP_X11(F12, 0x0060) -CODE_MAP_ANDROID(F12, 0x0058) CODE_MAP_WIN(F13, 0x0064) CODE_MAP_MAC(F13, kVK_F13) // PrintScreen on PC keyboard CODE_MAP_X11(F13, 0x00BF) -CODE_MAP_ANDROID(F13, 0x00B7) CODE_MAP_WIN(F14, 0x0065) CODE_MAP_MAC(F14, kVK_F14) // ScrollLock on PC keyboard CODE_MAP_X11(F14, 0x00C0) -CODE_MAP_ANDROID(F14, 0x00B8) CODE_MAP_WIN(F15, 0x0066) CODE_MAP_MAC(F15, kVK_F15) // Pause on PC keyboard CODE_MAP_X11(F15, 0x00C1) -CODE_MAP_ANDROID(F15, 0x00B9) CODE_MAP_WIN(F16, 0x0067) CODE_MAP_MAC(F16, kVK_F16) CODE_MAP_X11(F16, 0x00C2) -CODE_MAP_ANDROID(F16, 0x00BA) CODE_MAP_WIN(F17, 0x0068) CODE_MAP_MAC(F17, kVK_F17) CODE_MAP_X11(F17, 0x00C3) -CODE_MAP_ANDROID(F17, 0x00BB) CODE_MAP_WIN(F18, 0x0069) CODE_MAP_MAC(F18, kVK_F18) CODE_MAP_X11(F18, 0x00C4) -CODE_MAP_ANDROID(F18, 0x00BC) CODE_MAP_WIN(F19, 0x006A) CODE_MAP_MAC(F19, kVK_F19) CODE_MAP_X11(F19, 0x00C5) -CODE_MAP_ANDROID(F19, 0x00BD) CODE_MAP_WIN(F20, 0x006B) CODE_MAP_MAC(F20, kVK_F20) CODE_MAP_X11(F20, 0x00C6) -CODE_MAP_ANDROID(F20, 0x00BE) CODE_MAP_WIN(F21, 0x006C) CODE_MAP_X11(F21, 0x00C7) -CODE_MAP_ANDROID(F21, 0x00BF) CODE_MAP_WIN(F22, 0x006D) CODE_MAP_X11(F22, 0x00C8) -CODE_MAP_ANDROID(F22, 0x00C0) CODE_MAP_WIN(F23, 0x006E) CODE_MAP_X11(F23, 0x00C9) -CODE_MAP_ANDROID(F23, 0x00C1) CODE_MAP_WIN(F24, 0x0076) CODE_MAP_X11(F24, 0x00CA) -CODE_MAP_ANDROID(F24, 0x00C2) CODE_MAP_MAC(Fn, kVK_Function) // not available? -CODE_MAP_ANDROID(Fn, 0x01D0) CODE_MAP_WIN(PrintScreen, 0xE037) CODE_MAP_WIN(PrintScreen, 0x0054) // Alt + PrintScreen CODE_MAP_X11(PrintScreen, 0x006B) -CODE_MAP_ANDROID(PrintScreen, 0x0063) CODE_MAP_WIN(ScrollLock, 0x0046) CODE_MAP_X11(ScrollLock, 0x004E) -CODE_MAP_ANDROID(ScrollLock, 0x0046) CODE_MAP_WIN(Pause, 0x0045) CODE_MAP_WIN(Pause, 0xE046) // Ctrl + Pause CODE_MAP_X11(Pause, 0x007F) -CODE_MAP_ANDROID(Pause, 0x0077) // Media keys CODE_MAP_WIN(BrowserBack, 0xE06A) CODE_MAP_X11(BrowserBack, 0x00A6) -CODE_MAP_ANDROID(BrowserBack, 0x009E) CODE_MAP_WIN(BrowserFavorites, 0xE066) CODE_MAP_X11(BrowserFavorites, 0x00A4) -CODE_MAP_ANDROID(BrowserFavorites, 0x009C) CODE_MAP_WIN(BrowserForward, 0xE069) CODE_MAP_X11(BrowserForward, 0x00A7) -CODE_MAP_ANDROID(BrowserForward, 0x009F) CODE_MAP_WIN(BrowserHome, 0xE032) CODE_MAP_X11(BrowserHome, 0x00B4) -// CODE_MAP_ANDROID(BrowserHome) // not available? works as Home key. CODE_MAP_WIN(BrowserRefresh, 0xE067) CODE_MAP_X11(BrowserRefresh, 0x00B5) -CODE_MAP_ANDROID(BrowserRefresh, 0x00AD) CODE_MAP_WIN(BrowserSearch, 0xE065) CODE_MAP_X11(BrowserSearch, 0x00E1) -CODE_MAP_ANDROID(BrowserSearch, 0x00D9) CODE_MAP_WIN(BrowserStop, 0xE068) CODE_MAP_X11(BrowserStop, 0x0088) -CODE_MAP_ANDROID(BrowserStop, 0x0080) // CODE_MAP_WIN(Eject) // not available? // CODE_MAP_MAC(Eject) // not available? CODE_MAP_X11(Eject, 0x00A9) -CODE_MAP_ANDROID(Eject, 0x00A1) CODE_MAP_WIN(LaunchApp1, 0xE06B) CODE_MAP_X11(LaunchApp1, 0x0098) -CODE_MAP_ANDROID(LaunchApp1, 0x0090) CODE_MAP_WIN(LaunchApp2, 0xE021) CODE_MAP_X11(LaunchApp2, 0x0094) -// CODE_MAP_ANDROID(LaunchApp2) // not available? CODE_MAP_WIN(LaunchMail, 0xE06C) CODE_MAP_X11(LaunchMail, 0x00A3) -// CODE_MAP_ANDROID(LaunchMail) // not available? CODE_MAP_WIN(MediaPlayPause, 0xE022) CODE_MAP_X11(MediaPlayPause, 0x00AC) -CODE_MAP_ANDROID(MediaPlayPause, 0x00A4) CODE_MAP_WIN(MediaSelect, 0xE06D) CODE_MAP_X11(MediaSelect, 0x00B3) -// CODE_MAP_ANDROID(MediaSelect) // not available? CODE_MAP_WIN(MediaStop, 0xE024) CODE_MAP_X11(MediaStop, 0x00AE) -CODE_MAP_ANDROID(MediaStop, 0x00A6) CODE_MAP_WIN(MediaTrackNext, 0xE019) CODE_MAP_X11(MediaTrackNext, 0x00AB) -CODE_MAP_ANDROID(MediaTrackNext, 0x00A3) CODE_MAP_WIN(MediaTrackPrevious, 0xE010) CODE_MAP_X11(MediaTrackPrevious, 0x00AD) -CODE_MAP_ANDROID(MediaTrackPrevious, 0x00A5) CODE_MAP_WIN(Power, 0xE05E) CODE_MAP_MAC(Power, 0x007F) // On 10.7 and 10.8 only // CODE_MAP_X11(Power) // not available? -CODE_MAP_ANDROID(Power, 0x0074) // CODE_MAP_WIN(Sleep) // not available? // CODE_MAP_X11(Sleep) // not available? -CODE_MAP_ANDROID(Sleep, 0x008E) CODE_MAP_WIN(VolumeDown, 0xE02E) CODE_MAP_MAC(VolumeDown, kVK_VolumeDown) // not available? CODE_MAP_X11(VolumeDown, 0x007A) -CODE_MAP_ANDROID(VolumeDown, 0x0072) CODE_MAP_WIN(VolumeMute, 0xE020) CODE_MAP_MAC(VolumeMute, kVK_Mute) // not available? CODE_MAP_X11(VolumeMute, 0x0079) -CODE_MAP_ANDROID(VolumeMute, 0x0071) CODE_MAP_WIN(VolumeUp, 0xE030) CODE_MAP_MAC(VolumeUp, kVK_VolumeUp) // not available? CODE_MAP_X11(VolumeUp, 0x007B) -CODE_MAP_ANDROID(VolumeUp, 0x0073) // side of body, not on keyboard // CODE_MAP_WIN(WakeUp) // not available? CODE_MAP_X11(WakeUp, 0x0097) -CODE_MAP_ANDROID(WakeUp, 0x008F) // Legacy editing keys CODE_MAP_X11(Again, 0x0089) // Again key on Sun keyboard -CODE_MAP_ANDROID(Again, 0x0081) // Again key on Sun keyboard CODE_MAP_X11(Copy, 0x008D) // Copy key on Sun keyboard -CODE_MAP_ANDROID(Copy, 0x0085) // Copy key on Sun keyboard CODE_MAP_X11(Cut, 0x0091) // Cut key on Sun keyboard -CODE_MAP_ANDROID(Cut, 0x0089) // Cut key on Sun keyboard CODE_MAP_X11(Find, 0x0090) // Find key on Sun keyboard -CODE_MAP_ANDROID(Find, 0x0088) // Find key on Sun keyboard CODE_MAP_X11(Open, 0x008E) // Open key on Sun keyboard -CODE_MAP_ANDROID(Open, 0x0086) // Open key on Sun keyboard CODE_MAP_X11(Paste, 0x008F) // Paste key on Sun keyboard -CODE_MAP_ANDROID(Paste, 0x0087) // Paste key on Sun keyboard CODE_MAP_X11(Props, 0x008A) // Props key on Sun keyboard -CODE_MAP_ANDROID(Props, 0x0082) // Props key on Sun keyboard CODE_MAP_X11(Select, 0x008C) // Front key on Sun keyboard -CODE_MAP_ANDROID(Select, 0x0084) // Front key on Sun keyboard CODE_MAP_X11(Undo, 0x008B) // Undo key on Sun keyboard -CODE_MAP_ANDROID(Undo, 0x0083) // Undo key on Sun keyboard #undef CODE_MAP_WIN #undef CODE_MAP_MAC #undef CODE_MAP_X11 -#undef CODE_MAP_ANDROID diff --git a/widget/NativeKeyToDOMKeyName.h b/widget/NativeKeyToDOMKeyName.h index a818108db..ce1e3c3a4 100644 --- a/widget/NativeKeyToDOMKeyName.h +++ b/widget/NativeKeyToDOMKeyName.h @@ -25,7 +25,6 @@ #define KEY_MAP_COCOA(aCPPKeyName, aNativeKey) // GTK #define KEY_MAP_GTK(aCPPKeyName, aNativeKey) -#define KEY_MAP_ANDROID(aCPPKeyName, aNativeKey) #if defined(XP_WIN) #if defined(NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX) @@ -71,10 +70,6 @@ #undef KEY_MAP_GTK #define KEY_MAP_GTK(aCPPKeyName, aNativeKey) \ NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) -#elif defined(ANDROID) -#undef KEY_MAP_ANDROID -#define KEY_MAP_ANDROID(aCPPKeyName, aNativeKey) \ - NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) #endif /****************************************************************************** @@ -88,8 +83,6 @@ KEY_MAP_COCOA (Alt, kVK_Option) KEY_MAP_COCOA (Alt, kVK_RightOption) KEY_MAP_GTK (Alt, GDK_Alt_L) KEY_MAP_GTK (Alt, GDK_Alt_R) -KEY_MAP_ANDROID (Alt, AKEYCODE_ALT_LEFT) -KEY_MAP_ANDROID (Alt, AKEYCODE_ALT_RIGHT) // AltGraph KEY_MAP_GTK (AltGraph, GDK_Mode_switch /* same as GDK_kana_switch, @@ -109,7 +102,6 @@ KEY_MAP_GTK (AltGraph, GDK_ISO_Level5_Lock) KEY_MAP_WIN (CapsLock, VK_CAPITAL) KEY_MAP_COCOA (CapsLock, kVK_CapsLock) KEY_MAP_GTK (CapsLock, GDK_Caps_Lock) -KEY_MAP_ANDROID (CapsLock, AKEYCODE_CAPS_LOCK) // Control KEY_MAP_WIN (Control, VK_CONTROL) @@ -119,25 +111,19 @@ KEY_MAP_COCOA (Control, kVK_Control) KEY_MAP_COCOA (Control, kVK_RightControl) KEY_MAP_GTK (Control, GDK_Control_L) KEY_MAP_GTK (Control, GDK_Control_R) -KEY_MAP_ANDROID (Control, AKEYCODE_CTRL_LEFT) -KEY_MAP_ANDROID (Control, AKEYCODE_CTRL_RIGHT) // Fn KEY_MAP_COCOA (Fn, kVK_Function) -KEY_MAP_ANDROID (Fn, AKEYCODE_FUNCTION) // Meta KEY_MAP_COCOA (Meta, kVK_Command) KEY_MAP_COCOA (Meta, kVK_RightCommand) KEY_MAP_GTK (Meta, GDK_Meta_L) KEY_MAP_GTK (Meta, GDK_Meta_R) -KEY_MAP_ANDROID (Meta, AKEYCODE_META_LEFT) -KEY_MAP_ANDROID (Meta, AKEYCODE_META_RIGHT) // NumLock KEY_MAP_WIN (NumLock, VK_NUMLOCK) KEY_MAP_GTK (NumLock, GDK_Num_Lock) -KEY_MAP_ANDROID (NumLock, AKEYCODE_NUM_LOCK) // OS KEY_MAP_WIN (OS, VK_LWIN) @@ -150,7 +136,6 @@ KEY_MAP_GTK (OS, GDK_Hyper_R) // ScrollLock KEY_MAP_WIN (ScrollLock, VK_SCROLL) KEY_MAP_GTK (ScrollLock, GDK_Scroll_Lock) -KEY_MAP_ANDROID (ScrollLock, AKEYCODE_SCROLL_LOCK) // Shift KEY_MAP_WIN (Shift, VK_SHIFT) @@ -161,11 +146,8 @@ KEY_MAP_COCOA (Shift, kVK_RightShift) KEY_MAP_GTK (Shift, GDK_Shift_L) KEY_MAP_GTK (Shift, GDK_Shift_R) KEY_MAP_GTK (Shift, GDK_Shift_Lock) // Let's treat as Shift key (bug 769159) -KEY_MAP_ANDROID (Shift, AKEYCODE_SHIFT_LEFT) -KEY_MAP_ANDROID (Shift, AKEYCODE_SHIFT_RIGHT) // Symbol -KEY_MAP_ANDROID (Symbol, AKEYCODE_SYM) /****************************************************************************** * Whitespace Keys @@ -179,8 +161,6 @@ KEY_MAP_GTK (Enter, GDK_Return) KEY_MAP_GTK (Enter, GDK_KP_Enter) KEY_MAP_GTK (Enter, GDK_ISO_Enter) KEY_MAP_GTK (Enter, GDK_3270_Enter) -KEY_MAP_ANDROID (Enter, AKEYCODE_ENTER) -KEY_MAP_ANDROID (Enter, AKEYCODE_NUMPAD_ENTER) // Tab KEY_MAP_WIN (Tab, VK_TAB) @@ -188,7 +168,6 @@ KEY_MAP_COCOA (Tab, kVK_Tab) KEY_MAP_GTK (Tab, GDK_Tab) KEY_MAP_GTK (Tab, GDK_ISO_Left_Tab) // Shift+Tab KEY_MAP_GTK (Tab, GDK_KP_Tab) -KEY_MAP_ANDROID (Tab, AKEYCODE_TAB) /****************************************************************************** * Navigation Keys @@ -198,56 +177,48 @@ KEY_MAP_WIN (ArrowDown, VK_DOWN) KEY_MAP_COCOA (ArrowDown, kVK_DownArrow) KEY_MAP_GTK (ArrowDown, GDK_Down) KEY_MAP_GTK (ArrowDown, GDK_KP_Down) -KEY_MAP_ANDROID (ArrowDown, AKEYCODE_DPAD_DOWN) // ArrowLeft KEY_MAP_WIN (ArrowLeft, VK_LEFT) KEY_MAP_COCOA (ArrowLeft, kVK_LeftArrow) KEY_MAP_GTK (ArrowLeft, GDK_Left) KEY_MAP_GTK (ArrowLeft, GDK_KP_Left) -KEY_MAP_ANDROID (ArrowLeft, AKEYCODE_DPAD_LEFT) // ArrowRight KEY_MAP_WIN (ArrowRight, VK_RIGHT) KEY_MAP_COCOA (ArrowRight, kVK_RightArrow) KEY_MAP_GTK (ArrowRight, GDK_Right) KEY_MAP_GTK (ArrowRight, GDK_KP_Right) -KEY_MAP_ANDROID (ArrowRight, AKEYCODE_DPAD_RIGHT) // ArrowUp KEY_MAP_WIN (ArrowUp, VK_UP) KEY_MAP_COCOA (ArrowUp, kVK_UpArrow) KEY_MAP_GTK (ArrowUp, GDK_Up) KEY_MAP_GTK (ArrowUp, GDK_KP_Up) -KEY_MAP_ANDROID (ArrowUp, AKEYCODE_DPAD_UP) // End KEY_MAP_WIN (End, VK_END) KEY_MAP_COCOA (End, kVK_End) KEY_MAP_GTK (End, GDK_End) KEY_MAP_GTK (End, GDK_KP_End) -KEY_MAP_ANDROID (End, AKEYCODE_MOVE_END) // Home KEY_MAP_WIN (Home, VK_HOME) KEY_MAP_COCOA (Home, kVK_Home) KEY_MAP_GTK (Home, GDK_Home) KEY_MAP_GTK (Home, GDK_KP_Home) -KEY_MAP_ANDROID (Home, AKEYCODE_MOVE_HOME) // PageDown KEY_MAP_WIN (PageDown, VK_NEXT) KEY_MAP_COCOA (PageDown, kVK_PageDown) KEY_MAP_GTK (PageDown, GDK_Page_Down /* same as GDK_Next */) KEY_MAP_GTK (PageDown, GDK_KP_Page_Down /* same as GDK_KP_Next */) -KEY_MAP_ANDROID (PageDown, AKEYCODE_PAGE_DOWN) // PageUp KEY_MAP_WIN (PageUp, VK_PRIOR) KEY_MAP_COCOA (PageUp, kVK_PageUp) KEY_MAP_GTK (PageUp, GDK_Page_Up /* same as GDK_Prior */) KEY_MAP_GTK (PageUp, GDK_KP_Page_Up /* same as GDK_KP_Prior */) -KEY_MAP_ANDROID (PageUp, AKEYCODE_PAGE_UP) /****************************************************************************** * Editing Keys @@ -256,14 +227,12 @@ KEY_MAP_ANDROID (PageUp, AKEYCODE_PAGE_UP) KEY_MAP_WIN (Backspace, VK_BACK) KEY_MAP_COCOA (Backspace, kVK_PC_Backspace) KEY_MAP_GTK (Backspace, GDK_BackSpace) -KEY_MAP_ANDROID (Backspace, AKEYCODE_DEL) // Clear KEY_MAP_WIN (Clear, VK_CLEAR) KEY_MAP_WIN (Clear, VK_OEM_CLEAR) KEY_MAP_COCOA (Clear, kVK_ANSI_KeypadClear) KEY_MAP_GTK (Clear, GDK_Clear) -KEY_MAP_ANDROID (Clear, AKEYCODE_CLEAR) // Copy KEY_MAP_WIN_CMD (Copy, APPCOMMAND_COPY) @@ -282,7 +251,6 @@ KEY_MAP_WIN (Delete, VK_DELETE) KEY_MAP_COCOA (Delete, kVK_PC_Delete) KEY_MAP_GTK (Delete, GDK_Delete) KEY_MAP_GTK (Delete, GDK_KP_Delete) -KEY_MAP_ANDROID (Delete, AKEYCODE_FORWARD_DEL) // EraseEof KEY_MAP_WIN (EraseEof, VK_EREOF) @@ -296,7 +264,6 @@ KEY_MAP_GTK (ExSel, GDK_3270_ExSelect) // legacy IBM keyboard layout KEY_MAP_WIN (Insert, VK_INSERT) KEY_MAP_GTK (Insert, GDK_Insert) KEY_MAP_GTK (Insert, GDK_KP_Insert) -KEY_MAP_ANDROID (Insert, AKEYCODE_INSERT) // Paste KEY_MAP_WIN_CMD (Paste, APPCOMMAND_PASTE) @@ -315,7 +282,6 @@ KEY_MAP_GTK (Undo, GDK_Undo) ******************************************************************************/ // Accept KEY_MAP_WIN (Accept, VK_ACCEPT) -KEY_MAP_ANDROID (Accept, AKEYCODE_DPAD_CENTER) // Attn KEY_MAP_WIN_OTH (Attn, VK_ATTN) // not valid with Japanese keyboard layout @@ -329,13 +295,11 @@ KEY_MAP_GTK (Cancel, GDK_Cancel) KEY_MAP_WIN (ContextMenu, VK_APPS) KEY_MAP_COCOA (ContextMenu, kVK_PC_ContextMenu) KEY_MAP_GTK (ContextMenu, GDK_Menu) -KEY_MAP_ANDROID (ContextMenu, AKEYCODE_MENU) // Escape KEY_MAP_WIN (Escape, VK_ESCAPE) KEY_MAP_COCOA (Escape, kVK_Escape) KEY_MAP_GTK (Escape, GDK_Escape) -KEY_MAP_ANDROID (Escape, AKEYCODE_ESCAPE) // Execute KEY_MAP_WIN (Execute, VK_EXECUTE) @@ -350,14 +314,12 @@ KEY_MAP_WIN (Help, VK_HELP) KEY_MAP_WIN_CMD (Help, APPCOMMAND_HELP) KEY_MAP_COCOA (Help, kVK_Help) KEY_MAP_GTK (Help, GDK_Help) -KEY_MAP_ANDROID (Help, AKEYCODE_ASSIST) // Pause KEY_MAP_WIN (Pause, VK_PAUSE) KEY_MAP_GTK (Pause, GDK_Pause) // Break is typically mapped to Alt+Pause or Ctrl+Pause on GTK. KEY_MAP_GTK (Pause, GDK_Break) -KEY_MAP_ANDROID (Pause, AKEYCODE_BREAK) // Play KEY_MAP_WIN (Play, VK_PLAY) @@ -369,11 +331,9 @@ KEY_MAP_GTK (Select, GDK_Select) // ZoomIn KEY_MAP_GTK (ZoomIn, GDK_ZoomIn) -KEY_MAP_ANDROID (ZoomIn, AKEYCODE_ZOOM_IN) // ZoomOut KEY_MAP_GTK (ZoomOut, GDK_ZoomOut) -KEY_MAP_ANDROID (ZoomOut, AKEYCODE_ZOOM_OUT) /****************************************************************************** * Device Keys @@ -386,13 +346,11 @@ KEY_MAP_GTK (BrightnessUp, GDK_MonBrightnessUp) // Eject KEY_MAP_GTK (Eject, GDK_Eject) -KEY_MAP_ANDROID (Eject, AKEYCODE_MEDIA_EJECT) // LogOff KEY_MAP_GTK (LogOff, GDK_LogOff) // Power -KEY_MAP_ANDROID (Power, AKEYCODE_POWER) // PowerOff KEY_MAP_GTK (PowerOff, GDK_PowerDown) @@ -403,7 +361,6 @@ KEY_MAP_WIN (PrintScreen, VK_SNAPSHOT) KEY_MAP_GTK (PrintScreen, GDK_3270_PrintScreen) KEY_MAP_GTK (PrintScreen, GDK_Print) KEY_MAP_GTK (PrintScreen, GDK_Sys_Req) -KEY_MAP_ANDROID (PrintScreen, AKEYCODE_SYSRQ) // Hibernate KEY_MAP_GTK (Hibernate, GDK_Hibernate) @@ -437,7 +394,6 @@ KEY_MAP_GTK (Compose, GDK_Multi_key) // "Multi Key" is "Compose key" on X // Convert KEY_MAP_WIN (Convert, VK_CONVERT) KEY_MAP_GTK (Convert, GDK_Henkan) -KEY_MAP_ANDROID (Convert, AKEYCODE_HENKAN) // Dead KEY_MAP_GTK (Dead, GDK_dead_grave) @@ -497,19 +453,16 @@ KEY_MAP_GTK (GroupLast, GDK_ISO_Last_Group) // GroupNext KEY_MAP_GTK (GroupNext, GDK_ISO_Next_Group) -KEY_MAP_ANDROID (GroupNext, AKEYCODE_LANGUAGE_SWITCH) // GroupPrevious KEY_MAP_GTK (GroupPrevious, GDK_ISO_Prev_Group) // ModeChange KEY_MAP_WIN (ModeChange, VK_MODECHANGE) -KEY_MAP_ANDROID (ModeChange, AKEYCODE_SWITCH_CHARSET) // NonConvert KEY_MAP_WIN (NonConvert, VK_NONCONVERT) KEY_MAP_GTK (NonConvert, GDK_Muhenkan) -KEY_MAP_ANDROID (NonConvert, AKEYCODE_MUHENKAN) // PreviousCandidate KEY_MAP_GTK (PreviousCandidate, GDK_PreviousCandidate) // OADG 109, Mae Koho @@ -534,7 +487,6 @@ KEY_MAP_WIN (JunjaMode, VK_JUNJA) ******************************************************************************/ // Eisu KEY_MAP_COCOA (Eisu, kVK_JIS_Eisu) -KEY_MAP_ANDROID (Eisu, AKEYCODE_EISU) // Hankaku KEY_MAP_WIN_JPN (Hankaku, VK_OEM_AUTO) @@ -546,7 +498,6 @@ KEY_MAP_GTK (Hiragana, GDK_Hiragana) // HiraganaKatakana KEY_MAP_GTK (HiraganaKatakana, GDK_Hiragana_Katakana) -KEY_MAP_ANDROID (HiraganaKatakana, AKEYCODE_KATAKANA_HIRAGANA) // KanaMode // VK_KANA is never used with modern Japanese keyboard, however, IE maps it to @@ -560,8 +511,6 @@ KEY_MAP_GTK (KanaMode, GDK_Kana_Shift) KEY_MAP_WIN_JPN (KanjiMode, VK_KANJI /* same as VK_HANJA */) KEY_MAP_COCOA (KanjiMode, kVK_JIS_Kana) // Kana key opens IME KEY_MAP_GTK (KanjiMode, GDK_Kanji) // Typically, Alt + Hankaku/Zenkaku key -// Assuming that KANA key of Android is the Kana key on Mac keyboard. -KEY_MAP_ANDROID (KanjiMode, AKEYCODE_KANA) // Katakana KEY_MAP_WIN_JPN (Katakana, VK_OEM_FINISH) @@ -577,7 +526,6 @@ KEY_MAP_GTK (Zenkaku, GDK_Zenkaku) // ZenkakuHankaku KEY_MAP_GTK (ZenkakuHankaku, GDK_Zenkaku_Hankaku) -KEY_MAP_ANDROID (ZenkakuHankaku, AKEYCODE_ZENKAKU_HANKAKU) /****************************************************************************** * General-Purpose Function Keys @@ -587,76 +535,64 @@ KEY_MAP_WIN (F1, VK_F1) KEY_MAP_COCOA (F1, kVK_F1) KEY_MAP_GTK (F1, GDK_F1) KEY_MAP_GTK (F1, GDK_KP_F1) -KEY_MAP_ANDROID (F1, AKEYCODE_F1) // F2 KEY_MAP_WIN (F2, VK_F2) KEY_MAP_COCOA (F2, kVK_F2) KEY_MAP_GTK (F2, GDK_F2) KEY_MAP_GTK (F2, GDK_KP_F2) -KEY_MAP_ANDROID (F2, AKEYCODE_F2) // F3 KEY_MAP_WIN (F3, VK_F3) KEY_MAP_COCOA (F3, kVK_F3) KEY_MAP_GTK (F3, GDK_F3) KEY_MAP_GTK (F3, GDK_KP_F3) -KEY_MAP_ANDROID (F3, AKEYCODE_F3) // F4 KEY_MAP_WIN (F4, VK_F4) KEY_MAP_COCOA (F4, kVK_F4) KEY_MAP_GTK (F4, GDK_F4) KEY_MAP_GTK (F4, GDK_KP_F4) -KEY_MAP_ANDROID (F4, AKEYCODE_F4) // F5 KEY_MAP_WIN (F5, VK_F5) KEY_MAP_COCOA (F5, kVK_F5) KEY_MAP_GTK (F5, GDK_F5) -KEY_MAP_ANDROID (F5, AKEYCODE_F5) // F6 KEY_MAP_WIN (F6, VK_F6) KEY_MAP_COCOA (F6, kVK_F6) KEY_MAP_GTK (F6, GDK_F6) -KEY_MAP_ANDROID (F6, AKEYCODE_F6) // F7 KEY_MAP_WIN (F7, VK_F7) KEY_MAP_COCOA (F7, kVK_F7) KEY_MAP_GTK (F7, GDK_F7) -KEY_MAP_ANDROID (F7, AKEYCODE_F7) // F8 KEY_MAP_WIN (F8, VK_F8) KEY_MAP_COCOA (F8, kVK_F8) KEY_MAP_GTK (F8, GDK_F8) -KEY_MAP_ANDROID (F8, AKEYCODE_F8) // F9 KEY_MAP_WIN (F9, VK_F9) KEY_MAP_COCOA (F9, kVK_F9) KEY_MAP_GTK (F9, GDK_F9) -KEY_MAP_ANDROID (F9, AKEYCODE_F9) // F10 KEY_MAP_WIN (F10, VK_F10) KEY_MAP_COCOA (F10, kVK_F10) KEY_MAP_GTK (F10, GDK_F10) -KEY_MAP_ANDROID (F10, AKEYCODE_F10) // F11 KEY_MAP_WIN (F11, VK_F11) KEY_MAP_COCOA (F11, kVK_F11) KEY_MAP_GTK (F11, GDK_F11 /* same as GDK_L1 */) -KEY_MAP_ANDROID (F11, AKEYCODE_F11) // F12 KEY_MAP_WIN (F12, VK_F12) KEY_MAP_COCOA (F12, kVK_F12) KEY_MAP_GTK (F12, GDK_F12 /* same as GDK_L2 */) -KEY_MAP_ANDROID (F12, AKEYCODE_F12) // F13 KEY_MAP_WIN (F13, VK_F13) @@ -751,11 +687,9 @@ KEY_MAP_GTK (F35, GDK_F35 /* same as GDK_R15 */) ******************************************************************************/ // ChannelDown KEY_MAP_WIN_CMD (ChannelDown, APPCOMMAND_MEDIA_CHANNEL_DOWN) -KEY_MAP_ANDROID (ChannelDown, AKEYCODE_CHANNEL_DOWN) // ChannelUp KEY_MAP_WIN_CMD (ChannelUp, APPCOMMAND_MEDIA_CHANNEL_UP) -KEY_MAP_ANDROID (ChannelUp, AKEYCODE_CHANNEL_UP) // Close // NOTE: This is not a key to close disk tray, this is a key to close document @@ -778,45 +712,37 @@ KEY_MAP_GTK (MailSend, GDK_Send) // MediaPause KEY_MAP_WIN_CMD (MediaPause, APPCOMMAND_MEDIA_PAUSE) KEY_MAP_GTK (MediaPause, GDK_AudioPause) -KEY_MAP_ANDROID (MediaPause, AKEYCODE_MEDIA_PAUSE) // MediaPlay KEY_MAP_WIN_CMD (MediaPlay, APPCOMMAND_MEDIA_PLAY) KEY_MAP_GTK (MediaPlay, GDK_AudioPlay) -KEY_MAP_ANDROID (MediaPlay, AKEYCODE_MEDIA_PLAY) // MediaPlayPause KEY_MAP_WIN (MediaPlayPause, VK_MEDIA_PLAY_PAUSE) KEY_MAP_WIN_CMD (MediaPlayPause, APPCOMMAND_MEDIA_PLAY_PAUSE) -KEY_MAP_ANDROID (MediaPlayPause, AKEYCODE_MEDIA_PLAY_PAUSE) // MediaRecord KEY_MAP_WIN_CMD (MediaRecord, APPCOMMAND_MEDIA_RECORD) KEY_MAP_GTK (MediaRecord, GDK_AudioRecord) -KEY_MAP_ANDROID (MediaRecord, AKEYCODE_MEDIA_RECORD) // MediaRewind KEY_MAP_WIN_CMD (MediaRewind, APPCOMMAND_MEDIA_REWIND) KEY_MAP_GTK (MediaRewind, GDK_AudioRewind) -KEY_MAP_ANDROID (MediaRewind, AKEYCODE_MEDIA_REWIND) // MediaStop KEY_MAP_WIN (MediaStop, VK_MEDIA_STOP) KEY_MAP_WIN_CMD (MediaStop, APPCOMMAND_MEDIA_STOP) KEY_MAP_GTK (MediaStop, GDK_AudioStop) -KEY_MAP_ANDROID (MediaStop, AKEYCODE_MEDIA_STOP) // MediaTrackNext KEY_MAP_WIN (MediaTrackNext, VK_MEDIA_NEXT_TRACK) KEY_MAP_WIN_CMD (MediaTrackNext, APPCOMMAND_MEDIA_NEXTTRACK) KEY_MAP_GTK (MediaTrackNext, GDK_AudioNext) -KEY_MAP_ANDROID (MediaTrackNext, AKEYCODE_MEDIA_NEXT) // MediaTrackPrevious KEY_MAP_WIN (MediaTrackPrevious, VK_MEDIA_PREV_TRACK) KEY_MAP_WIN_CMD (MediaTrackPrevious, APPCOMMAND_MEDIA_PREVIOUSTRACK) KEY_MAP_GTK (MediaTrackPrevious, GDK_AudioPrev) -KEY_MAP_ANDROID (MediaTrackPrevious, AKEYCODE_MEDIA_PREVIOUS) // New KEY_MAP_WIN_CMD (New, APPCOMMAND_NEW) @@ -851,38 +777,32 @@ KEY_MAP_WIN (AudioVolumeDown, VK_VOLUME_DOWN) KEY_MAP_WIN_CMD (AudioVolumeDown, APPCOMMAND_VOLUME_DOWN) KEY_MAP_COCOA (AudioVolumeDown, kVK_VolumeDown) KEY_MAP_GTK (AudioVolumeDown, GDK_AudioLowerVolume) -KEY_MAP_ANDROID (AudioVolumeDown, AKEYCODE_VOLUME_DOWN) // AudioVolumeUp KEY_MAP_WIN (AudioVolumeUp, VK_VOLUME_UP) KEY_MAP_WIN_CMD (AudioVolumeUp, APPCOMMAND_VOLUME_UP) KEY_MAP_COCOA (AudioVolumeUp, kVK_VolumeUp) KEY_MAP_GTK (AudioVolumeUp, GDK_AudioRaiseVolume) -KEY_MAP_ANDROID (AudioVolumeUp, AKEYCODE_VOLUME_UP) // AudioVolumeMute KEY_MAP_WIN (AudioVolumeMute, VK_VOLUME_MUTE) KEY_MAP_WIN_CMD (AudioVolumeMute, APPCOMMAND_VOLUME_MUTE) KEY_MAP_COCOA (AudioVolumeMute, kVK_Mute) KEY_MAP_GTK (AudioVolumeMute, GDK_AudioMute) -KEY_MAP_ANDROID (AudioVolumeMute, AKEYCODE_VOLUME_MUTE) /****************************************************************************** * Application Keys ******************************************************************************/ // LaunchCalculator KEY_MAP_GTK (LaunchCalculator, GDK_Calculator) -KEY_MAP_ANDROID (LaunchCalculator, AKEYCODE_CALCULATOR) // LaunchCalendar KEY_MAP_GTK (LaunchCalendar, GDK_Calendar) -KEY_MAP_ANDROID (LaunchCalendar, AKEYCODE_CALENDAR) // LaunchMail KEY_MAP_WIN (LaunchMail, VK_LAUNCH_MAIL) KEY_MAP_WIN_CMD (LaunchMail, APPCOMMAND_LAUNCH_MAIL) KEY_MAP_GTK (LaunchMail, GDK_Mail) -KEY_MAP_ANDROID (LaunchMail, AKEYCODE_ENVELOPE) // LaunchMediaPlayer KEY_MAP_WIN (LaunchMediaPlayer, VK_LAUNCH_MEDIA_SELECT) @@ -895,7 +815,6 @@ KEY_MAP_GTK (LaunchMediaPlayer, GDK_AudioMedia) // LaunchMusicPlayer KEY_MAP_GTK (LaunchMusicPlayer, GDK_Music) -KEY_MAP_ANDROID (LaunchMusicPlayer, AKEYCODE_MUSIC) // LaunchMyComputer KEY_MAP_GTK (LaunchMyComputer, GDK_MyComputer) @@ -909,7 +828,6 @@ KEY_MAP_GTK (LaunchSpreadsheet, GDK_Excel) // LaunchWebBrowser KEY_MAP_GTK (LaunchWebBrowser, GDK_WWW) -KEY_MAP_ANDROID (LaunchWebBrowser, AKEYCODE_EXPLORER) // LaunchWebCam KEY_MAP_GTK (LaunchWebCam, GDK_WebCam) @@ -980,18 +898,15 @@ KEY_MAP_GTK (LaunchApplication16, GDK_LaunchF) KEY_MAP_WIN (BrowserBack, VK_BROWSER_BACK) KEY_MAP_WIN_CMD (BrowserBack, APPCOMMAND_BROWSER_BACKWARD) KEY_MAP_GTK (BrowserBack, GDK_Back) -KEY_MAP_ANDROID (BrowserBack, AKEYCODE_BACK) // BrowserFavorites KEY_MAP_WIN (BrowserFavorites, VK_BROWSER_FAVORITES) KEY_MAP_WIN_CMD (BrowserFavorites, APPCOMMAND_BROWSER_FAVORITES) -KEY_MAP_ANDROID (BrowserFavorites, AKEYCODE_BOOKMARK) // BrowserForward KEY_MAP_WIN (BrowserForward, VK_BROWSER_FORWARD) KEY_MAP_WIN_CMD (BrowserForward, APPCOMMAND_BROWSER_FORWARD) KEY_MAP_GTK (BrowserForward, GDK_Forward) -KEY_MAP_ANDROID (BrowserForward, AKEYCODE_FORWARD) // BrowserHome KEY_MAP_WIN (BrowserHome, VK_BROWSER_HOME) @@ -1008,7 +923,6 @@ KEY_MAP_GTK (BrowserRefresh, GDK_Reload) KEY_MAP_WIN (BrowserSearch, VK_BROWSER_SEARCH) KEY_MAP_WIN_CMD (BrowserSearch, APPCOMMAND_BROWSER_SEARCH) KEY_MAP_GTK (BrowserSearch, GDK_Search) -KEY_MAP_ANDROID (BrowserSearch, AKEYCODE_SEARCH) // BrowserStop KEY_MAP_WIN (BrowserStop, VK_BROWSER_STOP) @@ -1019,88 +933,67 @@ KEY_MAP_GTK (BrowserStop, GDK_Stop) * Mobile Phone Keys ******************************************************************************/ // Call -KEY_MAP_ANDROID (Call, AKEYCODE_CALL) // Camera -KEY_MAP_ANDROID (Camera, AKEYCODE_CAMERA) // CameraFocus -KEY_MAP_ANDROID (CameraFocus, AKEYCODE_FOCUS) // GoHome -KEY_MAP_ANDROID (GoHome, AKEYCODE_HOME) /****************************************************************************** * TV Keys ******************************************************************************/ // TV -KEY_MAP_ANDROID (TV, AKEYCODE_TV) // TVInput -KEY_MAP_ANDROID (TVInput, AKEYCODE_TV_INPUT) // TVPower -KEY_MAP_ANDROID (TVPower, AKEYCODE_TV_POWER) /****************************************************************************** * Media Controller Keys ******************************************************************************/ // AVRInput -KEY_MAP_ANDROID (AVRInput, AKEYCODE_AVR_INPUT) // AVRPower -KEY_MAP_ANDROID (AVRPower, AKEYCODE_AVR_POWER) // ColorF0Red KEY_MAP_GTK (ColorF0Red, GDK_Red) -KEY_MAP_ANDROID (ColorF0Red, AKEYCODE_PROG_RED) // ColorF1Green KEY_MAP_GTK (ColorF1Green, GDK_Green) -KEY_MAP_ANDROID (ColorF1Green, AKEYCODE_PROG_GREEN) // ColorF2Yellow KEY_MAP_GTK (ColorF2Yellow, GDK_Yellow) -KEY_MAP_ANDROID (ColorF2Yellow, AKEYCODE_PROG_YELLOW) // ColorF3Blue KEY_MAP_GTK (ColorF3Blue, GDK_Blue) -KEY_MAP_ANDROID (ColorF3Blue, AKEYCODE_PROG_BLUE) // Dimmer KEY_MAP_GTK (Dimmer, GDK_BrightnessAdjust) // Guide -KEY_MAP_ANDROID (Guide, AKEYCODE_GUIDE) // Info -KEY_MAP_ANDROID (Info, AKEYCODE_INFO) // MediaFastForward KEY_MAP_WIN_CMD (MediaFastForward, APPCOMMAND_MEDIA_FAST_FORWARD) KEY_MAP_GTK (MediaFastForward, GDK_AudioForward) -KEY_MAP_ANDROID (MediaFastForward, AKEYCODE_MEDIA_FAST_FORWARD) // MediaLast // PinPToggle -KEY_MAP_ANDROID (PinPToggle, AKEYCODE_WINDOW) // RandomToggle KEY_MAP_GTK (RandomToggle, GDK_AudioRandomPlay) // Settings -KEY_MAP_ANDROID (Settings, AKEYCODE_SETTINGS) // STBInput -KEY_MAP_ANDROID (STBInput, AKEYCODE_STB_INPUT) // STBPower -KEY_MAP_ANDROID (STBPower, AKEYCODE_STB_POWER) // Subtitle KEY_MAP_GTK (Subtitle, GDK_Subtitle) -KEY_MAP_ANDROID (Subtitle, AKEYCODE_CAPTIONS) // VideoModeNext KEY_MAP_GTK (VideoModeNext, GDK_Next_VMode) @@ -1112,10 +1005,8 @@ KEY_MAP_WIN (ZoomToggle, VK_ZOOM) * Keys not defined by any standards ******************************************************************************/ // SoftLeft -KEY_MAP_ANDROID (SoftLeft, AKEYCODE_SOFT_LEFT) // SoftRight -KEY_MAP_ANDROID (SoftRight, AKEYCODE_SOFT_RIGHT) #undef KEY_MAP_WIN #undef KEY_MAP_WIN_JPN @@ -1124,4 +1015,3 @@ KEY_MAP_ANDROID (SoftRight, AKEYCODE_SOFT_RIGHT) #undef KEY_MAP_WIN_CMD #undef KEY_MAP_COCOA #undef KEY_MAP_GTK -#undef KEY_MAP_ANDROID diff --git a/widget/android/ANRReporter.cpp b/widget/android/ANRReporter.cpp deleted file mode 100644 index 30d9b3d76..000000000 --- a/widget/android/ANRReporter.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "ANRReporter.h" -#include "GeckoProfiler.h" - -#include <unistd.h> - -namespace mozilla { - -bool -ANRReporter::RequestNativeStack(bool aUnwind) -{ - if (profiler_is_active()) { - // Don't proceed if profiler is already running - return false; - } - // WARNING: we are on the ANR reporter thread at this point and it is - // generally unsafe to use the profiler from off the main thread. However, - // the risk here is limited because for most users, the profiler is not run - // elsewhere. See the discussion in Bug 863777, comment 13 - const char *NATIVE_STACK_FEATURES[] = - {"leaf", "threads", "privacy"}; - const char *NATIVE_STACK_UNWIND_FEATURES[] = - {"leaf", "threads", "privacy", "stackwalk"}; - - const char **features = NATIVE_STACK_FEATURES; - size_t features_size = sizeof(NATIVE_STACK_FEATURES); - if (aUnwind) { - features = NATIVE_STACK_UNWIND_FEATURES; - features_size = sizeof(NATIVE_STACK_UNWIND_FEATURES); - // We want the new unwinder if the unwind mode has not been set yet - putenv("MOZ_PROFILER_NEW=1"); - } - - const char *NATIVE_STACK_THREADS[] = - {"GeckoMain", "Compositor"}; - // Buffer one sample and let the profiler wait a long time - profiler_start(100, 10000, features, features_size / sizeof(char*), - NATIVE_STACK_THREADS, sizeof(NATIVE_STACK_THREADS) / sizeof(char*)); - return true; -} - -jni::String::LocalRef -ANRReporter::GetNativeStack() -{ - if (!profiler_is_active()) { - // Maybe profiler support is disabled? - return nullptr; - } - - // Timeout if we don't get a profiler sample after 5 seconds. - const PRIntervalTime timeout = PR_SecondsToInterval(5); - const PRIntervalTime startTime = PR_IntervalNow(); - - // Pointer to a profile JSON string - typedef mozilla::UniquePtr<char[]> ProfilePtr; - - ProfilePtr profile(profiler_get_profile()); - - while (profile && !strstr(profile.get(), "\"samples\":[{")) { - // no sample yet? - if (PR_IntervalNow() - startTime >= timeout) { - return nullptr; - } - usleep(100000ul); // Sleep for 100ms - profile = ProfilePtr(profiler_get_profile()); - } - - if (profile) { - return jni::String::Param(profile.get()); - } - return nullptr; -} - -void -ANRReporter::ReleaseNativeStack() -{ - if (!profiler_is_active()) { - // Maybe profiler support is disabled? - return; - } - profiler_stop(); -} - -} // namespace - diff --git a/widget/android/ANRReporter.h b/widget/android/ANRReporter.h deleted file mode 100644 index d3e5cc7e8..000000000 --- a/widget/android/ANRReporter.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef ANRReporter_h__ -#define ANRReporter_h__ - -#include "FennecJNINatives.h" - -namespace mozilla { - -class ANRReporter : public java::ANRReporter::Natives<ANRReporter> -{ -private: - ANRReporter(); - -public: - static bool RequestNativeStack(bool aUnwind); - static jni::String::LocalRef GetNativeStack(); - static void ReleaseNativeStack(); -}; - -} // namespace - -#endif // ANRReporter_h__ diff --git a/widget/android/AndroidAlerts.cpp b/widget/android/AndroidAlerts.cpp deleted file mode 100644 index 8d5074672..000000000 --- a/widget/android/AndroidAlerts.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "AndroidAlerts.h" -#include "GeneratedJNIWrappers.h" -#include "nsAlertsUtils.h" - -namespace mozilla { -namespace widget { - -NS_IMPL_ISUPPORTS(AndroidAlerts, nsIAlertsService) - -StaticAutoPtr<AndroidAlerts::ListenerMap> AndroidAlerts::sListenerMap; - -NS_IMETHODIMP -AndroidAlerts::ShowAlertNotification(const nsAString & aImageUrl, - const nsAString & aAlertTitle, - const nsAString & aAlertText, - bool aAlertTextClickable, - const nsAString & aAlertCookie, - nsIObserver * aAlertListener, - const nsAString & aAlertName, - const nsAString & aBidi, - const nsAString & aLang, - const nsAString & aData, - nsIPrincipal * aPrincipal, - bool aInPrivateBrowsing, - bool aRequireInteraction) -{ - MOZ_ASSERT_UNREACHABLE("Should be implemented by nsAlertsService."); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -AndroidAlerts::ShowAlert(nsIAlertNotification* aAlert, - nsIObserver* aAlertListener) -{ - return ShowPersistentNotification(EmptyString(), aAlert, aAlertListener); -} - -NS_IMETHODIMP -AndroidAlerts::ShowPersistentNotification(const nsAString& aPersistentData, - nsIAlertNotification* aAlert, - nsIObserver* aAlertListener) -{ - // nsAlertsService disables our alerts backend if we ever return failure - // here. To keep the backend enabled, we always return NS_OK even if we - // encounter an error here. - nsresult rv; - - nsAutoString imageUrl; - rv = aAlert->GetImageURL(imageUrl); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsAutoString title; - rv = aAlert->GetTitle(title); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsAutoString text; - rv = aAlert->GetText(text); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsAutoString cookie; - rv = aAlert->GetCookie(cookie); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsAutoString name; - rv = aAlert->GetName(name); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsCOMPtr<nsIPrincipal> principal; - rv = aAlert->GetPrincipal(getter_AddRefs(principal)); - NS_ENSURE_SUCCESS(rv, NS_OK); - - nsAutoString host; - nsAlertsUtils::GetSourceHostPort(principal, host); - - if (aPersistentData.IsEmpty() && aAlertListener) { - if (!sListenerMap) { - sListenerMap = new ListenerMap(); - } - // This will remove any observers already registered for this name. - sListenerMap->Put(name, aAlertListener); - } - - java::GeckoAppShell::ShowNotification( - name, cookie, title, text, host, imageUrl, - !aPersistentData.IsEmpty() ? jni::StringParam(aPersistentData) - : jni::StringParam(nullptr)); - return NS_OK; -} - -NS_IMETHODIMP -AndroidAlerts::CloseAlert(const nsAString& aAlertName, - nsIPrincipal* aPrincipal) -{ - // We delete the entry in sListenerMap later, when CloseNotification calls - // NotifyListener. - java::GeckoAppShell::CloseNotification(aAlertName); - return NS_OK; -} - -void -AndroidAlerts::NotifyListener(const nsAString& aName, const char* aTopic, - const char16_t* aCookie) -{ - if (!sListenerMap) { - return; - } - - nsCOMPtr<nsIObserver> listener = sListenerMap->Get(aName); - if (!listener) { - return; - } - - listener->Observe(nullptr, aTopic, aCookie); - - if (NS_LITERAL_CSTRING("alertfinished").Equals(aTopic)) { - sListenerMap->Remove(aName); - } -} - -} // namespace widget -} // namespace mozilla diff --git a/widget/android/AndroidAlerts.h b/widget/android/AndroidAlerts.h deleted file mode 100644 index 16af15ce0..000000000 --- a/widget/android/AndroidAlerts.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_widget_AndroidAlerts_h__ -#define mozilla_widget_AndroidAlerts_h__ - -#include "nsInterfaceHashtable.h" -#include "nsCOMPtr.h" -#include "nsHashKeys.h" -#include "nsIAlertsService.h" -#include "nsIObserver.h" - -#include "mozilla/StaticPtr.h" - -namespace mozilla { -namespace widget { - -class AndroidAlerts : public nsIAlertsService -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIALERTSSERVICE - - AndroidAlerts() {} - - static void NotifyListener(const nsAString& aName, const char* aTopic, - const char16_t* aCookie); - -protected: - virtual ~AndroidAlerts() - { - sListenerMap = nullptr; - } - - using ListenerMap = nsInterfaceHashtable<nsStringHashKey, nsIObserver>; - static StaticAutoPtr<ListenerMap> sListenerMap; -}; - -} // namespace widget -} // namespace mozilla - -#endif // nsAndroidAlerts_h__ diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp deleted file mode 100644 index dd2cce39a..000000000 --- a/widget/android/AndroidBridge.cpp +++ /dev/null @@ -1,1126 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include <android/log.h> -#include <dlfcn.h> -#include <math.h> -#include <GLES2/gl2.h> - -#include "mozilla/layers/CompositorBridgeChild.h" -#include "mozilla/layers/CompositorBridgeParent.h" - -#include "mozilla/Hal.h" -#include "nsXULAppAPI.h" -#include <prthread.h> -#include "nsXPCOMStrings.h" -#include "AndroidBridge.h" -#include "AndroidJNIWrapper.h" -#include "AndroidBridgeUtilities.h" -#include "nsAlertsUtils.h" -#include "nsAppShell.h" -#include "nsOSHelperAppService.h" -#include "nsWindow.h" -#include "mozilla/Preferences.h" -#include "nsThreadUtils.h" -#include "nsIThreadManager.h" -#include "gfxPlatform.h" -#include "gfxContext.h" -#include "mozilla/gfx/2D.h" -#include "gfxUtils.h" -#include "nsPresContext.h" -#include "nsIDocShell.h" -#include "nsPIDOMWindow.h" -#include "mozilla/dom/ScreenOrientation.h" -#include "nsIDOMWindowUtils.h" -#include "nsIDOMClientRect.h" -#include "mozilla/ClearOnShutdown.h" -#include "nsPrintfCString.h" -#include "NativeJSContainer.h" -#include "nsContentUtils.h" -#include "nsIScriptError.h" -#include "nsIHttpChannel.h" - -#include "MediaCodec.h" -#include "SurfaceTexture.h" -#include "GLContextProvider.h" - -#include "mozilla/TimeStamp.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/dom/ContentChild.h" -#include "nsIObserverService.h" -#include "nsISupportsPrimitives.h" -#include "MediaPrefs.h" -#include "WidgetUtils.h" - -#include "FennecJNIWrappers.h" - -using namespace mozilla; -using namespace mozilla::gfx; -using namespace mozilla::jni; -using namespace mozilla::java; - -AndroidBridge* AndroidBridge::sBridge = nullptr; -static jobject sGlobalContext = nullptr; -nsDataHashtable<nsStringHashKey, nsString> AndroidBridge::sStoragePaths; - -jmethodID AndroidBridge::GetMethodID(JNIEnv* env, jclass jClass, - const char* methodName, const char* methodType) -{ - jmethodID methodID = env->GetMethodID(jClass, methodName, methodType); - if (!methodID) { - ALOG(">>> FATAL JNI ERROR! GetMethodID(methodName=\"%s\", " - "methodType=\"%s\") failed. Did ProGuard optimize away something it shouldn't have?", - methodName, methodType); - env->ExceptionDescribe(); - MOZ_CRASH(); - } - return methodID; -} - -jmethodID AndroidBridge::GetStaticMethodID(JNIEnv* env, jclass jClass, - const char* methodName, const char* methodType) -{ - jmethodID methodID = env->GetStaticMethodID(jClass, methodName, methodType); - if (!methodID) { - ALOG(">>> FATAL JNI ERROR! GetStaticMethodID(methodName=\"%s\", " - "methodType=\"%s\") failed. Did ProGuard optimize away something it shouldn't have?", - methodName, methodType); - env->ExceptionDescribe(); - MOZ_CRASH(); - } - return methodID; -} - -jfieldID AndroidBridge::GetFieldID(JNIEnv* env, jclass jClass, - const char* fieldName, const char* fieldType) -{ - jfieldID fieldID = env->GetFieldID(jClass, fieldName, fieldType); - if (!fieldID) { - ALOG(">>> FATAL JNI ERROR! GetFieldID(fieldName=\"%s\", " - "fieldType=\"%s\") failed. Did ProGuard optimize away something it shouldn't have?", - fieldName, fieldType); - env->ExceptionDescribe(); - MOZ_CRASH(); - } - return fieldID; -} - -jfieldID AndroidBridge::GetStaticFieldID(JNIEnv* env, jclass jClass, - const char* fieldName, const char* fieldType) -{ - jfieldID fieldID = env->GetStaticFieldID(jClass, fieldName, fieldType); - if (!fieldID) { - ALOG(">>> FATAL JNI ERROR! GetStaticFieldID(fieldName=\"%s\", " - "fieldType=\"%s\") failed. Did ProGuard optimize away something it shouldn't have?", - fieldName, fieldType); - env->ExceptionDescribe(); - MOZ_CRASH(); - } - return fieldID; -} - -void -AndroidBridge::ConstructBridge() -{ - /* NSS hack -- bionic doesn't handle recursive unloads correctly, - * because library finalizer functions are called with the dynamic - * linker lock still held. This results in a deadlock when trying - * to call dlclose() while we're already inside dlclose(). - * Conveniently, NSS has an env var that can prevent it from unloading. - */ - putenv("NSS_DISABLE_UNLOAD=1"); - - MOZ_ASSERT(!sBridge); - sBridge = new AndroidBridge(); - - MediaPrefs::GetSingleton(); -} - -void -AndroidBridge::DeconstructBridge() -{ - if (sBridge) { - delete sBridge; - // AndroidBridge destruction requires sBridge to still be valid, - // so we set sBridge to nullptr after deleting it. - sBridge = nullptr; - } -} - -AndroidBridge::~AndroidBridge() -{ -} - -AndroidBridge::AndroidBridge() - : mUiTaskQueueLock("UiTaskQueue") -{ - ALOG_BRIDGE("AndroidBridge::Init"); - - JNIEnv* const jEnv = jni::GetGeckoThreadEnv(); - AutoLocalJNIFrame jniFrame(jEnv); - - mMessageQueue = java::GeckoThread::MsgQueue(); - auto msgQueueClass = Class::LocalRef::Adopt( - jEnv, jEnv->GetObjectClass(mMessageQueue.Get())); - // mMessageQueueNext must not be null - mMessageQueueNext = GetMethodID( - jEnv, msgQueueClass.Get(), "next", "()Landroid/os/Message;"); - // mMessageQueueMessages may be null (e.g. due to proguard optimization) - mMessageQueueMessages = jEnv->GetFieldID( - msgQueueClass.Get(), "mMessages", "Landroid/os/Message;"); - - AutoJNIClass string(jEnv, "java/lang/String"); - jStringClass = string.getGlobalRef(); - - if (!GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &mAPIVersion, jEnv)) { - ALOG_BRIDGE("Failed to find API version"); - } - - AutoJNIClass channels(jEnv, "java/nio/channels/Channels"); - jChannels = channels.getGlobalRef(); - jChannelCreate = channels.getStaticMethod("newChannel", "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;"); - - AutoJNIClass readableByteChannel(jEnv, "java/nio/channels/ReadableByteChannel"); - jReadableByteChannel = readableByteChannel.getGlobalRef(); - jByteBufferRead = readableByteChannel.getMethod("read", "(Ljava/nio/ByteBuffer;)I"); - - AutoJNIClass inputStream(jEnv, "java/io/InputStream"); - jInputStream = inputStream.getGlobalRef(); - jClose = inputStream.getMethod("close", "()V"); - jAvailable = inputStream.getMethod("available", "()I"); -} - -// Raw JNIEnv variants. -jstring AndroidBridge::NewJavaString(JNIEnv* env, const char16_t* string, uint32_t len) { - jstring ret = env->NewString(reinterpret_cast<const jchar*>(string), len); - if (env->ExceptionCheck()) { - ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__); - env->ExceptionDescribe(); - env->ExceptionClear(); - return nullptr; - } - return ret; -} - -jstring AndroidBridge::NewJavaString(JNIEnv* env, const nsAString& string) { - return NewJavaString(env, string.BeginReading(), string.Length()); -} - -jstring AndroidBridge::NewJavaString(JNIEnv* env, const char* string) { - return NewJavaString(env, NS_ConvertUTF8toUTF16(string)); -} - -jstring AndroidBridge::NewJavaString(JNIEnv* env, const nsACString& string) { - return NewJavaString(env, NS_ConvertUTF8toUTF16(string)); -} - -// AutoLocalJNIFrame variants.. -jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const char16_t* string, uint32_t len) { - return NewJavaString(frame->GetEnv(), string, len); -} - -jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const nsAString& string) { - return NewJavaString(frame, string.BeginReading(), string.Length()); -} - -jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const char* string) { - return NewJavaString(frame, NS_ConvertUTF8toUTF16(string)); -} - -jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const nsACString& string) { - return NewJavaString(frame, NS_ConvertUTF8toUTF16(string)); -} - -static void -getHandlersFromStringArray(JNIEnv *aJNIEnv, jobjectArray jArr, jsize aLen, - nsIMutableArray *aHandlersArray, - nsIHandlerApp **aDefaultApp, - const nsAString& aAction = EmptyString(), - const nsACString& aMimeType = EmptyCString()) -{ - nsString empty = EmptyString(); - for (jsize i = 0; i < aLen; i+=4) { - - AutoLocalJNIFrame jniFrame(aJNIEnv, 4); - nsJNIString name( - static_cast<jstring>(aJNIEnv->GetObjectArrayElement(jArr, i)), aJNIEnv); - nsJNIString isDefault( - static_cast<jstring>(aJNIEnv->GetObjectArrayElement(jArr, i + 1)), aJNIEnv); - nsJNIString packageName( - static_cast<jstring>(aJNIEnv->GetObjectArrayElement(jArr, i + 2)), aJNIEnv); - nsJNIString className( - static_cast<jstring>(aJNIEnv->GetObjectArrayElement(jArr, i + 3)), aJNIEnv); - nsIHandlerApp* app = nsOSHelperAppService:: - CreateAndroidHandlerApp(name, className, packageName, - className, aMimeType, aAction); - - aHandlersArray->AppendElement(app, false); - if (aDefaultApp && isDefault.Length() > 0) - *aDefaultApp = app; - } -} - -bool -AndroidBridge::GetHandlersForMimeType(const nsAString& aMimeType, - nsIMutableArray *aHandlersArray, - nsIHandlerApp **aDefaultApp, - const nsAString& aAction) -{ - ALOG_BRIDGE("AndroidBridge::GetHandlersForMimeType"); - - auto arr = GeckoAppShell::GetHandlersForMimeType(aMimeType, aAction); - if (!arr) - return false; - - JNIEnv* const env = arr.Env(); - jsize len = env->GetArrayLength(arr.Get()); - - if (!aHandlersArray) - return len > 0; - - getHandlersFromStringArray(env, arr.Get(), len, aHandlersArray, - aDefaultApp, aAction, - NS_ConvertUTF16toUTF8(aMimeType)); - return true; -} - -bool -AndroidBridge::GetHWEncoderCapability() -{ - ALOG_BRIDGE("AndroidBridge::GetHWEncoderCapability"); - - bool value = GeckoAppShell::GetHWEncoderCapability(); - - return value; -} - - -bool -AndroidBridge::GetHWDecoderCapability() -{ - ALOG_BRIDGE("AndroidBridge::GetHWDecoderCapability"); - - bool value = GeckoAppShell::GetHWDecoderCapability(); - - return value; -} - -bool -AndroidBridge::GetHandlersForURL(const nsAString& aURL, - nsIMutableArray* aHandlersArray, - nsIHandlerApp **aDefaultApp, - const nsAString& aAction) -{ - ALOG_BRIDGE("AndroidBridge::GetHandlersForURL"); - - auto arr = GeckoAppShell::GetHandlersForURL(aURL, aAction); - if (!arr) - return false; - - JNIEnv* const env = arr.Env(); - jsize len = env->GetArrayLength(arr.Get()); - - if (!aHandlersArray) - return len > 0; - - getHandlersFromStringArray(env, arr.Get(), len, aHandlersArray, - aDefaultApp, aAction); - return true; -} - -void -AndroidBridge::GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString& aMimeType) -{ - ALOG_BRIDGE("AndroidBridge::GetMimeTypeFromExtensions"); - - auto jstrType = GeckoAppShell::GetMimeTypeFromExtensions(aFileExt); - - if (jstrType) { - aMimeType = jstrType->ToCString(); - } -} - -void -AndroidBridge::GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt) -{ - ALOG_BRIDGE("AndroidBridge::GetExtensionFromMimeType"); - - auto jstrExt = GeckoAppShell::GetExtensionFromMimeType(aMimeType); - - if (jstrExt) { - aFileExt = jstrExt->ToCString(); - } -} - -bool -AndroidBridge::GetClipboardText(nsAString& aText) -{ - ALOG_BRIDGE("AndroidBridge::GetClipboardText"); - - auto text = Clipboard::GetText(); - - if (text) { - aText = text->ToString(); - } - return !!text; -} - -int -AndroidBridge::GetDPI() -{ - static int sDPI = 0; - if (sDPI) - return sDPI; - - const int DEFAULT_DPI = 160; - - sDPI = GeckoAppShell::GetDpi(); - if (!sDPI) { - return DEFAULT_DPI; - } - - return sDPI; -} - -int -AndroidBridge::GetScreenDepth() -{ - ALOG_BRIDGE("%s", __PRETTY_FUNCTION__); - - static int sDepth = 0; - if (sDepth) - return sDepth; - - const int DEFAULT_DEPTH = 16; - - if (jni::IsAvailable()) { - sDepth = GeckoAppShell::GetScreenDepth(); - } - if (!sDepth) - return DEFAULT_DEPTH; - - return sDepth; -} -void -AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern) -{ - ALOG_BRIDGE("%s", __PRETTY_FUNCTION__); - - uint32_t len = aPattern.Length(); - if (!len) { - ALOG_BRIDGE(" invalid 0-length array"); - return; - } - - // It's clear if this worth special-casing, but it creates less - // java junk, so dodges the GC. - if (len == 1) { - jlong d = aPattern[0]; - if (d < 0) { - ALOG_BRIDGE(" invalid vibration duration < 0"); - return; - } - GeckoAppShell::Vibrate(d); - return; - } - - // First element of the array vibrate() expects is how long to wait - // *before* vibrating. For us, this is always 0. - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - AutoLocalJNIFrame jniFrame(env, 1); - - jlongArray array = env->NewLongArray(len + 1); - if (!array) { - ALOG_BRIDGE(" failed to allocate array"); - return; - } - - jlong* elts = env->GetLongArrayElements(array, nullptr); - elts[0] = 0; - for (uint32_t i = 0; i < aPattern.Length(); ++i) { - jlong d = aPattern[i]; - if (d < 0) { - ALOG_BRIDGE(" invalid vibration duration < 0"); - env->ReleaseLongArrayElements(array, elts, JNI_ABORT); - return; - } - elts[i + 1] = d; - } - env->ReleaseLongArrayElements(array, elts, 0); - - GeckoAppShell::Vibrate(LongArray::Ref::From(array), -1 /* don't repeat */); -} - -void -AndroidBridge::GetSystemColors(AndroidSystemColors *aColors) -{ - - NS_ASSERTION(aColors != nullptr, "AndroidBridge::GetSystemColors: aColors is null!"); - if (!aColors) - return; - - auto arr = GeckoAppShell::GetSystemColors(); - if (!arr) - return; - - JNIEnv* const env = arr.Env(); - uint32_t len = static_cast<uint32_t>(env->GetArrayLength(arr.Get())); - jint *elements = env->GetIntArrayElements(arr.Get(), 0); - - uint32_t colorsCount = sizeof(AndroidSystemColors) / sizeof(nscolor); - if (len < colorsCount) - colorsCount = len; - - // Convert Android colors to nscolor by switching R and B in the ARGB 32 bit value - nscolor *colors = (nscolor*)aColors; - - for (uint32_t i = 0; i < colorsCount; i++) { - uint32_t androidColor = static_cast<uint32_t>(elements[i]); - uint8_t r = (androidColor & 0x00ff0000) >> 16; - uint8_t b = (androidColor & 0x000000ff); - colors[i] = (androidColor & 0xff00ff00) | (b << 16) | r; - } - - env->ReleaseIntArrayElements(arr.Get(), elements, 0); -} - -void -AndroidBridge::GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf) -{ - ALOG_BRIDGE("AndroidBridge::GetIconForExtension"); - NS_ASSERTION(aBuf != nullptr, "AndroidBridge::GetIconForExtension: aBuf is null!"); - if (!aBuf) - return; - - auto arr = GeckoAppShell::GetIconForExtension(NS_ConvertUTF8toUTF16(aFileExt), aIconSize); - - NS_ASSERTION(arr != nullptr, "AndroidBridge::GetIconForExtension: Returned pixels array is null!"); - if (!arr) - return; - - JNIEnv* const env = arr.Env(); - uint32_t len = static_cast<uint32_t>(env->GetArrayLength(arr.Get())); - jbyte *elements = env->GetByteArrayElements(arr.Get(), 0); - - uint32_t bufSize = aIconSize * aIconSize * 4; - NS_ASSERTION(len == bufSize, "AndroidBridge::GetIconForExtension: Pixels array is incomplete!"); - if (len == bufSize) - memcpy(aBuf, elements, bufSize); - - env->ReleaseByteArrayElements(arr.Get(), elements, 0); -} - -bool -AndroidBridge::GetStaticIntField(const char *className, const char *fieldName, int32_t* aInt, JNIEnv* jEnv /* = nullptr */) -{ - ALOG_BRIDGE("AndroidBridge::GetStaticIntField %s", fieldName); - - if (!jEnv) { - if (!jni::IsAvailable()) { - return false; - } - jEnv = jni::GetGeckoThreadEnv(); - } - - AutoJNIClass cls(jEnv, className); - jfieldID field = cls.getStaticField(fieldName, "I"); - - if (!field) { - return false; - } - - *aInt = static_cast<int32_t>(jEnv->GetStaticIntField(cls.getRawRef(), field)); - return true; -} - -bool -AndroidBridge::GetStaticStringField(const char *className, const char *fieldName, nsAString &result, JNIEnv* jEnv /* = nullptr */) -{ - ALOG_BRIDGE("AndroidBridge::GetStaticStringField %s", fieldName); - - if (!jEnv) { - if (!jni::IsAvailable()) { - return false; - } - jEnv = jni::GetGeckoThreadEnv(); - } - - AutoLocalJNIFrame jniFrame(jEnv, 1); - AutoJNIClass cls(jEnv, className); - jfieldID field = cls.getStaticField(fieldName, "Ljava/lang/String;"); - - if (!field) { - return false; - } - - jstring jstr = (jstring) jEnv->GetStaticObjectField(cls.getRawRef(), field); - if (!jstr) - return false; - - result.Assign(nsJNIString(jstr, jEnv)); - return true; -} - -namespace mozilla { - class TracerRunnable : public Runnable{ - public: - TracerRunnable() { - mTracerLock = new Mutex("TracerRunnable"); - mTracerCondVar = new CondVar(*mTracerLock, "TracerRunnable"); - mMainThread = do_GetMainThread(); - - } - ~TracerRunnable() { - delete mTracerCondVar; - delete mTracerLock; - mTracerLock = nullptr; - mTracerCondVar = nullptr; - } - - virtual nsresult Run() { - MutexAutoLock lock(*mTracerLock); - if (!AndroidBridge::Bridge()) - return NS_OK; - - mHasRun = true; - mTracerCondVar->Notify(); - return NS_OK; - } - - bool Fire() { - if (!mTracerLock || !mTracerCondVar) - return false; - MutexAutoLock lock(*mTracerLock); - mHasRun = false; - mMainThread->Dispatch(this, NS_DISPATCH_NORMAL); - while (!mHasRun) - mTracerCondVar->Wait(); - return true; - } - - void Signal() { - MutexAutoLock lock(*mTracerLock); - mHasRun = true; - mTracerCondVar->Notify(); - } - private: - Mutex* mTracerLock; - CondVar* mTracerCondVar; - bool mHasRun; - nsCOMPtr<nsIThread> mMainThread; - - }; - StaticRefPtr<TracerRunnable> sTracerRunnable; - - bool InitWidgetTracing() { - if (!sTracerRunnable) - sTracerRunnable = new TracerRunnable(); - return true; - } - - void CleanUpWidgetTracing() { - sTracerRunnable = nullptr; - } - - bool FireAndWaitForTracerEvent() { - if (sTracerRunnable) - return sTracerRunnable->Fire(); - return false; - } - - void SignalTracerThread() - { - if (sTracerRunnable) - return sTracerRunnable->Signal(); - } - -} - - -void -AndroidBridge::GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo) -{ - ALOG_BRIDGE("AndroidBridge::GetCurrentBatteryInformation"); - - // To prevent calling too many methods through JNI, the Java method returns - // an array of double even if we actually want a double and a boolean. - auto arr = GeckoAppShell::GetCurrentBatteryInformation(); - - JNIEnv* const env = arr.Env(); - if (!arr || env->GetArrayLength(arr.Get()) != 3) { - return; - } - - jdouble* info = env->GetDoubleArrayElements(arr.Get(), 0); - - aBatteryInfo->level() = info[0]; - aBatteryInfo->charging() = info[1] == 1.0f; - aBatteryInfo->remainingTime() = info[2]; - - env->ReleaseDoubleArrayElements(arr.Get(), info, 0); -} - -void -AndroidBridge::HandleGeckoMessage(JSContext* cx, JS::HandleObject object) -{ - ALOG_BRIDGE("%s", __PRETTY_FUNCTION__); - - auto message = widget::CreateNativeJSContainer(cx, object); - GeckoAppShell::HandleGeckoMessage(message); -} - -void -AndroidBridge::GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo) -{ - ALOG_BRIDGE("AndroidBridge::GetCurrentNetworkInformation"); - - // To prevent calling too many methods through JNI, the Java method returns - // an array of double even if we actually want an integer, a boolean, and an integer. - - auto arr = GeckoAppShell::GetCurrentNetworkInformation(); - - JNIEnv* const env = arr.Env(); - if (!arr || env->GetArrayLength(arr.Get()) != 3) { - return; - } - - jdouble* info = env->GetDoubleArrayElements(arr.Get(), 0); - - aNetworkInfo->type() = info[0]; - aNetworkInfo->isWifi() = info[1] == 1.0f; - aNetworkInfo->dhcpGateway() = info[2]; - - env->ReleaseDoubleArrayElements(arr.Get(), info, 0); -} - -jobject -AndroidBridge::GetGlobalContextRef() { - if (sGlobalContext) { - return sGlobalContext; - } - - JNIEnv* const env = GetEnvForThread(); - AutoLocalJNIFrame jniFrame(env, 4); - - auto context = GeckoAppShell::GetContext(); - if (!context) { - ALOG_BRIDGE("%s: Could not GetContext()", __FUNCTION__); - return 0; - } - jclass contextClass = env->FindClass("android/content/Context"); - if (!contextClass) { - ALOG_BRIDGE("%s: Could not find Context class.", __FUNCTION__); - return 0; - } - jmethodID mid = env->GetMethodID(contextClass, "getApplicationContext", - "()Landroid/content/Context;"); - if (!mid) { - ALOG_BRIDGE("%s: Could not find getApplicationContext.", __FUNCTION__); - return 0; - } - jobject appContext = env->CallObjectMethod(context.Get(), mid); - if (!appContext) { - ALOG_BRIDGE("%s: getApplicationContext failed.", __FUNCTION__); - return 0; - } - - sGlobalContext = env->NewGlobalRef(appContext); - MOZ_ASSERT(sGlobalContext); - return sGlobalContext; -} - -/* Implementation file */ -NS_IMPL_ISUPPORTS(nsAndroidBridge, nsIAndroidBridge) - -nsAndroidBridge::nsAndroidBridge() -{ - AddObservers(); -} - -nsAndroidBridge::~nsAndroidBridge() -{ - RemoveObservers(); -} - -NS_IMETHODIMP nsAndroidBridge::HandleGeckoMessage(JS::HandleValue val, - JSContext *cx) -{ - if (val.isObject()) { - JS::RootedObject object(cx, &val.toObject()); - AndroidBridge::Bridge()->HandleGeckoMessage(cx, object); - return NS_OK; - } - - // Now handle legacy JSON messages. - if (!val.isString()) { - return NS_ERROR_INVALID_ARG; - } - JS::RootedString jsonStr(cx, val.toString()); - - JS::RootedValue jsonVal(cx); - if (!JS_ParseJSON(cx, jsonStr, &jsonVal) || !jsonVal.isObject()) { - return NS_ERROR_INVALID_ARG; - } - - // Spit out a warning before sending the message. - nsContentUtils::ReportToConsoleNonLocalized( - NS_LITERAL_STRING("Use of JSON is deprecated. " - "Please pass Javascript objects directly to handleGeckoMessage."), - nsIScriptError::warningFlag, - NS_LITERAL_CSTRING("nsIAndroidBridge"), - nullptr); - - JS::RootedObject object(cx, &jsonVal.toObject()); - AndroidBridge::Bridge()->HandleGeckoMessage(cx, object); - return NS_OK; -} - -NS_IMETHODIMP nsAndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow) -{ - AndroidBridge::Bridge()->ContentDocumentChanged(aWindow); - return NS_OK; -} - -NS_IMETHODIMP nsAndroidBridge::IsContentDocumentDisplayed(mozIDOMWindowProxy* aWindow, - bool *aRet) -{ - *aRet = AndroidBridge::Bridge()->IsContentDocumentDisplayed(aWindow); - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidBridge::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) -{ - if (!strcmp(aTopic, "xpcom-shutdown")) { - RemoveObservers(); - } else if (!strcmp(aTopic, "media-playback")) { - ALOG_BRIDGE("nsAndroidBridge::Observe, get media-playback event."); - - nsCOMPtr<nsISupportsPRUint64> wrapper = do_QueryInterface(aSubject); - if (!wrapper) { - return NS_OK; - } - - uint64_t windowId = 0; - nsresult rv = wrapper->GetData(&windowId); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - nsAutoString activeStr(aData); - bool isPlaying = activeStr.EqualsLiteral("active"); - UpdateAudioPlayingWindows(windowId, isPlaying); - } - return NS_OK; -} - -void -nsAndroidBridge::UpdateAudioPlayingWindows(uint64_t aWindowId, - bool aPlaying) -{ - // Request audio focus for the first audio playing window and abandon focus - // for the last audio playing window. - if (aPlaying && !mAudioPlayingWindows.Contains(aWindowId)) { - mAudioPlayingWindows.AppendElement(aWindowId); - if (mAudioPlayingWindows.Length() == 1) { - ALOG_BRIDGE("nsAndroidBridge, request audio focus."); - AudioFocusAgent::NotifyStartedPlaying(); - } - } else if (!aPlaying && mAudioPlayingWindows.Contains(aWindowId)) { - mAudioPlayingWindows.RemoveElement(aWindowId); - if (mAudioPlayingWindows.Length() == 0) { - ALOG_BRIDGE("nsAndroidBridge, abandon audio focus."); - AudioFocusAgent::NotifyStoppedPlaying(); - } - } -} - -void -nsAndroidBridge::AddObservers() -{ - nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); - if (obs) { - obs->AddObserver(this, "xpcom-shutdown", false); - if (jni::IsFennec()) { // No AudioFocusAgent in non-Fennec environment. - obs->AddObserver(this, "media-playback", false); - } - } -} - -void -nsAndroidBridge::RemoveObservers() -{ - nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); - if (obs) { - obs->RemoveObserver(this, "xpcom-shutdown"); - if (jni::IsFennec()) { // No AudioFocusAgent in non-Fennec environment. - obs->RemoveObserver(this, "media-playback"); - } - } -} - -uint32_t -AndroidBridge::GetScreenOrientation() -{ - ALOG_BRIDGE("AndroidBridge::GetScreenOrientation"); - - int16_t orientation = GeckoAppShell::GetScreenOrientation(); - - if (!orientation) - return dom::eScreenOrientation_None; - - return static_cast<dom::ScreenOrientationInternal>(orientation); -} - -uint16_t -AndroidBridge::GetScreenAngle() -{ - return GeckoAppShell::GetScreenAngle(); -} - -nsresult -AndroidBridge::GetProxyForURI(const nsACString & aSpec, - const nsACString & aScheme, - const nsACString & aHost, - const int32_t aPort, - nsACString & aResult) -{ - if (!jni::IsAvailable()) { - return NS_ERROR_FAILURE; - } - - auto jstrRet = GeckoAppShell::GetProxyForURI(aSpec, aScheme, aHost, aPort); - - if (!jstrRet) - return NS_ERROR_FAILURE; - - aResult = jstrRet->ToCString(); - return NS_OK; -} - -bool -AndroidBridge::PumpMessageLoop() -{ - JNIEnv* const env = jni::GetGeckoThreadEnv(); - - if (mMessageQueueMessages) { - auto msg = Object::LocalRef::Adopt(env, - env->GetObjectField(mMessageQueue.Get(), - mMessageQueueMessages)); - // if queue.mMessages is null, queue.next() will block, which we don't - // want. It turns out to be an order of magnitude more performant to do - // this extra check here and block less vs. one fewer checks here and - // more blocking. - if (!msg) { - return false; - } - } - - auto msg = Object::LocalRef::Adopt( - env, env->CallObjectMethod(mMessageQueue.Get(), mMessageQueueNext)); - if (!msg) { - return false; - } - - return GeckoThread::PumpMessageLoop(msg); -} - -NS_IMETHODIMP nsAndroidBridge::GetBrowserApp(nsIAndroidBrowserApp * *aBrowserApp) -{ - nsAppShell* const appShell = nsAppShell::Get(); - if (appShell) - NS_IF_ADDREF(*aBrowserApp = appShell->GetBrowserApp()); - return NS_OK; -} - -NS_IMETHODIMP nsAndroidBridge::SetBrowserApp(nsIAndroidBrowserApp *aBrowserApp) -{ - nsAppShell* const appShell = nsAppShell::Get(); - if (appShell) - appShell->SetBrowserApp(aBrowserApp); - return NS_OK; -} - -extern "C" -__attribute__ ((visibility("default"))) -jobject JNICALL -Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(JNIEnv *env, jclass, jlong size); - -static jni::DependentRef<java::GeckoLayerClient> -GetJavaLayerClient(mozIDOMWindowProxy* aWindow) -{ - MOZ_ASSERT(aWindow); - - nsCOMPtr<nsPIDOMWindowOuter> domWindow = nsPIDOMWindowOuter::From(aWindow); - nsCOMPtr<nsIWidget> widget = - widget::WidgetUtils::DOMWindowToWidget(domWindow); - MOZ_ASSERT(widget); - - return static_cast<nsWindow*>(widget.get())->GetLayerClient(); -} - -void -AndroidBridge::ContentDocumentChanged(mozIDOMWindowProxy* aWindow) -{ - auto layerClient = GetJavaLayerClient(aWindow); - if (!layerClient) { - return; - } - layerClient->ContentDocumentChanged(); -} - -bool -AndroidBridge::IsContentDocumentDisplayed(mozIDOMWindowProxy* aWindow) -{ - auto layerClient = GetJavaLayerClient(aWindow); - if (!layerClient) { - return false; - } - return layerClient->IsContentDocumentDisplayed(); -} - -class AndroidBridge::DelayedTask -{ - using TimeStamp = mozilla::TimeStamp; - using TimeDuration = mozilla::TimeDuration; - -public: - DelayedTask(already_AddRefed<Runnable> aTask) - : mTask(aTask) - , mRunTime() // Null timestamp representing no delay. - {} - - DelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) - : mTask(aTask) - , mRunTime(TimeStamp::Now() + TimeDuration::FromMilliseconds(aDelayMs)) - {} - - bool IsEarlierThan(const DelayedTask& aOther) const - { - if (mRunTime) { - return aOther.mRunTime ? mRunTime < aOther.mRunTime : false; - } - // In the case of no delay, we're earlier if aOther has a delay. - // Otherwise, we're not earlier, to maintain task order. - return !!aOther.mRunTime; - } - - int64_t MillisecondsToRunTime() const - { - if (mRunTime) { - return int64_t((mRunTime - TimeStamp::Now()).ToMilliseconds()); - } - return 0; - } - - already_AddRefed<Runnable> TakeTask() - { - return mTask.forget(); - } - -private: - RefPtr<Runnable> mTask; - const TimeStamp mRunTime; -}; - - -void -AndroidBridge::PostTaskToUiThread(already_AddRefed<Runnable> aTask, int aDelayMs) -{ - // add the new task into the mUiTaskQueue, sorted with - // the earliest task first in the queue - size_t i; - DelayedTask newTask(aDelayMs ? DelayedTask(mozilla::Move(aTask), aDelayMs) - : DelayedTask(mozilla::Move(aTask))); - - { - MutexAutoLock lock(mUiTaskQueueLock); - - for (i = 0; i < mUiTaskQueue.Length(); i++) { - if (newTask.IsEarlierThan(mUiTaskQueue[i])) { - mUiTaskQueue.InsertElementAt(i, mozilla::Move(newTask)); - break; - } - } - - if (i == mUiTaskQueue.Length()) { - // We didn't insert the task, which means we should append it. - mUiTaskQueue.AppendElement(mozilla::Move(newTask)); - } - } - - if (i == 0) { - // if we're inserting it at the head of the queue, notify Java because - // we need to get a callback at an earlier time than the last scheduled - // callback - GeckoThread::RequestUiThreadCallback(int64_t(aDelayMs)); - } -} - -int64_t -AndroidBridge::RunDelayedUiThreadTasks() -{ - MutexAutoLock lock(mUiTaskQueueLock); - - while (!mUiTaskQueue.IsEmpty()) { - const int64_t timeLeft = mUiTaskQueue[0].MillisecondsToRunTime(); - if (timeLeft > 0) { - // this task (and therefore all remaining tasks) - // have not yet reached their runtime. return the - // time left until we should be called again - return timeLeft; - } - - // Retrieve task before unlocking/running. - RefPtr<Runnable> nextTask(mUiTaskQueue[0].TakeTask()); - mUiTaskQueue.RemoveElementAt(0); - - // Unlock to allow posting new tasks reentrantly. - MutexAutoUnlock unlock(mUiTaskQueueLock); - nextTask->Run(); - } - return -1; -} - -Object::LocalRef AndroidBridge::ChannelCreate(Object::Param stream) { - JNIEnv* const env = GetEnvForThread(); - auto rv = Object::LocalRef::Adopt(env, env->CallStaticObjectMethod( - sBridge->jChannels, sBridge->jChannelCreate, stream.Get())); - MOZ_CATCH_JNI_EXCEPTION(env); - return rv; -} - -void AndroidBridge::InputStreamClose(Object::Param obj) { - JNIEnv* const env = GetEnvForThread(); - env->CallVoidMethod(obj.Get(), sBridge->jClose); - MOZ_CATCH_JNI_EXCEPTION(env); -} - -uint32_t AndroidBridge::InputStreamAvailable(Object::Param obj) { - JNIEnv* const env = GetEnvForThread(); - auto rv = env->CallIntMethod(obj.Get(), sBridge->jAvailable); - MOZ_CATCH_JNI_EXCEPTION(env); - return rv; -} - -nsresult AndroidBridge::InputStreamRead(Object::Param obj, char *aBuf, uint32_t aCount, uint32_t *aRead) { - JNIEnv* const env = GetEnvForThread(); - auto arr = ByteBuffer::New(aBuf, aCount); - jint read = env->CallIntMethod(obj.Get(), sBridge->jByteBufferRead, arr.Get()); - - if (env->ExceptionCheck()) { - env->ExceptionClear(); - return NS_ERROR_FAILURE; - } - - if (read <= 0) { - *aRead = 0; - return NS_OK; - } - *aRead = read; - return NS_OK; -} diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h deleted file mode 100644 index 73dc1b5ff..000000000 --- a/widget/android/AndroidBridge.h +++ /dev/null @@ -1,419 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidBridge_h__ -#define AndroidBridge_h__ - -#include <jni.h> -#include <android/log.h> -#include <cstdlib> -#include <pthread.h> - -#include "APKOpen.h" - -#include "nsCOMPtr.h" -#include "nsCOMArray.h" - -#include "GeneratedJNIWrappers.h" - -#include "nsIMutableArray.h" -#include "nsIMIMEInfo.h" -#include "nsColor.h" -#include "gfxRect.h" - -#include "nsIAndroidBridge.h" -#include "nsIDOMDOMCursor.h" - -#include "mozilla/Likely.h" -#include "mozilla/Mutex.h" -#include "mozilla/Types.h" -#include "mozilla/gfx/Point.h" -#include "mozilla/jni/Utils.h" -#include "nsIObserver.h" -#include "nsDataHashtable.h" - -#include "Units.h" - -// Some debug #defines -// #define DEBUG_ANDROID_EVENTS -// #define DEBUG_ANDROID_WIDGET - -class nsPIDOMWindowOuter; - -namespace base { -class Thread; -} // end namespace base - -typedef void* EGLSurface; - -namespace mozilla { - -class AutoLocalJNIFrame; -class Runnable; - -namespace hal { -class BatteryInformation; -class NetworkInformation; -} // namespace hal - -// The order and number of the members in this structure must correspond -// to the attrsAppearance array in GeckoAppShell.getSystemColors() -typedef struct AndroidSystemColors { - nscolor textColorPrimary; - nscolor textColorPrimaryInverse; - nscolor textColorSecondary; - nscolor textColorSecondaryInverse; - nscolor textColorTertiary; - nscolor textColorTertiaryInverse; - nscolor textColorHighlight; - nscolor colorForeground; - nscolor colorBackground; - nscolor panelColorForeground; - nscolor panelColorBackground; -} AndroidSystemColors; - -class MessageCursorContinueCallback : public nsICursorContinueCallback -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSICURSORCONTINUECALLBACK - - MessageCursorContinueCallback(int aRequestId) - : mRequestId(aRequestId) - { - } -private: - virtual ~MessageCursorContinueCallback() - { - } - - int mRequestId; -}; - -class AndroidBridge final -{ -public: - enum { - // Values for NotifyIME, in addition to values from the Gecko - // IMEMessage enum; use negative values here to prevent conflict - NOTIFY_IME_OPEN_VKB = -2, - NOTIFY_IME_REPLY_EVENT = -1, - }; - - enum { - LAYER_CLIENT_TYPE_NONE = 0, - LAYER_CLIENT_TYPE_GL = 2 // AndroidGeckoGLLayerClient - }; - - static bool IsJavaUiThread() { - return pthread_equal(pthread_self(), ::getJavaUiThread()); - } - - static void ConstructBridge(); - static void DeconstructBridge(); - - static AndroidBridge *Bridge() { - return sBridge; - } - - void ContentDocumentChanged(mozIDOMWindowProxy* aDOMWindow); - bool IsContentDocumentDisplayed(mozIDOMWindowProxy* aDOMWindow); - - bool GetHandlersForURL(const nsAString& aURL, - nsIMutableArray* handlersArray = nullptr, - nsIHandlerApp **aDefaultApp = nullptr, - const nsAString& aAction = EmptyString()); - - bool GetHandlersForMimeType(const nsAString& aMimeType, - nsIMutableArray* handlersArray = nullptr, - nsIHandlerApp **aDefaultApp = nullptr, - const nsAString& aAction = EmptyString()); - - bool GetHWEncoderCapability(); - bool GetHWDecoderCapability(); - - void GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString& aMimeType); - void GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt); - - bool GetClipboardText(nsAString& aText); - - int GetDPI(); - int GetScreenDepth(); - - void Vibrate(const nsTArray<uint32_t>& aPattern); - - void GetSystemColors(AndroidSystemColors *aColors); - - void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf); - - bool GetStaticStringField(const char *classID, const char *field, nsAString &result, JNIEnv* env = nullptr); - - bool GetStaticIntField(const char *className, const char *fieldName, int32_t* aInt, JNIEnv* env = nullptr); - - // Returns a global reference to the Context for Fennec's Activity. The - // caller is responsible for ensuring this doesn't leak by calling - // DeleteGlobalRef() when the context is no longer needed. - jobject GetGlobalContextRef(void); - - void HandleGeckoMessage(JSContext* cx, JS::HandleObject message); - - void GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo); - - void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo); - - // These methods don't use a ScreenOrientation because it's an - // enum and that would require including the header which requires - // include IPC headers which requires including basictypes.h which - // requires a lot of changes... - uint32_t GetScreenOrientation(); - uint16_t GetScreenAngle(); - - int GetAPIVersion() { return mAPIVersion; } - - nsresult GetProxyForURI(const nsACString & aSpec, - const nsACString & aScheme, - const nsACString & aHost, - const int32_t aPort, - nsACString & aResult); - - bool PumpMessageLoop(); - - // Utility methods. - static jstring NewJavaString(JNIEnv* env, const char16_t* string, uint32_t len); - static jstring NewJavaString(JNIEnv* env, const nsAString& string); - static jstring NewJavaString(JNIEnv* env, const char* string); - static jstring NewJavaString(JNIEnv* env, const nsACString& string); - - static jstring NewJavaString(AutoLocalJNIFrame* frame, const char16_t* string, uint32_t len); - static jstring NewJavaString(AutoLocalJNIFrame* frame, const nsAString& string); - static jstring NewJavaString(AutoLocalJNIFrame* frame, const char* string); - static jstring NewJavaString(AutoLocalJNIFrame* frame, const nsACString& string); - - static jfieldID GetFieldID(JNIEnv* env, jclass jClass, const char* fieldName, const char* fieldType); - static jfieldID GetStaticFieldID(JNIEnv* env, jclass jClass, const char* fieldName, const char* fieldType); - static jmethodID GetMethodID(JNIEnv* env, jclass jClass, const char* methodName, const char* methodType); - static jmethodID GetStaticMethodID(JNIEnv* env, jclass jClass, const char* methodName, const char* methodType); - - static jni::Object::LocalRef ChannelCreate(jni::Object::Param); - - static void InputStreamClose(jni::Object::Param obj); - static uint32_t InputStreamAvailable(jni::Object::Param obj); - static nsresult InputStreamRead(jni::Object::Param obj, char *aBuf, uint32_t aCount, uint32_t *aRead); - -protected: - static nsDataHashtable<nsStringHashKey, nsString> sStoragePaths; - - static AndroidBridge* sBridge; - - AndroidBridge(); - ~AndroidBridge(); - - int mAPIVersion; - - // intput stream - jclass jReadableByteChannel; - jclass jChannels; - jmethodID jChannelCreate; - jmethodID jByteBufferRead; - - jclass jInputStream; - jmethodID jClose; - jmethodID jAvailable; - - jmethodID jCalculateLength; - - // some convinient types to have around - jclass jStringClass; - - jni::Object::GlobalRef mMessageQueue; - jfieldID mMessageQueueMessages; - jmethodID mMessageQueueNext; - -private: - class DelayedTask; - nsTArray<DelayedTask> mUiTaskQueue; - mozilla::Mutex mUiTaskQueueLock; - -public: - void PostTaskToUiThread(already_AddRefed<Runnable> aTask, int aDelayMs); - int64_t RunDelayedUiThreadTasks(); -}; - -class AutoJNIClass { -private: - JNIEnv* const mEnv; - const jclass mClass; - -public: - AutoJNIClass(JNIEnv* jEnv, const char* name) - : mEnv(jEnv) - , mClass(jni::GetClassRef(jEnv, name)) - {} - - ~AutoJNIClass() { - mEnv->DeleteLocalRef(mClass); - } - - jclass getRawRef() const { - return mClass; - } - - jclass getGlobalRef() const { - return static_cast<jclass>(mEnv->NewGlobalRef(mClass)); - } - - jfieldID getField(const char* name, const char* type) const { - return AndroidBridge::GetFieldID(mEnv, mClass, name, type); - } - - jfieldID getStaticField(const char* name, const char* type) const { - return AndroidBridge::GetStaticFieldID(mEnv, mClass, name, type); - } - - jmethodID getMethod(const char* name, const char* type) const { - return AndroidBridge::GetMethodID(mEnv, mClass, name, type); - } - - jmethodID getStaticMethod(const char* name, const char* type) const { - return AndroidBridge::GetStaticMethodID(mEnv, mClass, name, type); - } -}; - -class AutoJObject { -public: - AutoJObject(JNIEnv* aJNIEnv = nullptr) : mObject(nullptr) - { - mJNIEnv = aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv(); - } - - AutoJObject(JNIEnv* aJNIEnv, jobject aObject) - { - mJNIEnv = aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv(); - mObject = aObject; - } - - ~AutoJObject() { - if (mObject) - mJNIEnv->DeleteLocalRef(mObject); - } - - jobject operator=(jobject aObject) - { - if (mObject) { - mJNIEnv->DeleteLocalRef(mObject); - } - return mObject = aObject; - } - - operator jobject() { - return mObject; - } -private: - JNIEnv* mJNIEnv; - jobject mObject; -}; - -class AutoLocalJNIFrame { -public: - AutoLocalJNIFrame(int nEntries = 15) - : mEntries(nEntries) - , mJNIEnv(jni::GetGeckoThreadEnv()) - , mHasFrameBeenPushed(false) - { - MOZ_ASSERT(mJNIEnv); - Push(); - } - - AutoLocalJNIFrame(JNIEnv* aJNIEnv, int nEntries = 15) - : mEntries(nEntries) - , mJNIEnv(aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv()) - , mHasFrameBeenPushed(false) - { - MOZ_ASSERT(mJNIEnv); - Push(); - } - - ~AutoLocalJNIFrame() { - if (mHasFrameBeenPushed) { - Pop(); - } - } - - JNIEnv* GetEnv() { - return mJNIEnv; - } - - bool CheckForException() { - if (mJNIEnv->ExceptionCheck()) { - MOZ_CATCH_JNI_EXCEPTION(mJNIEnv); - return true; - } - return false; - } - - // Note! Calling Purge makes all previous local refs created in - // the AutoLocalJNIFrame's scope INVALID; be sure that you locked down - // any local refs that you need to keep around in global refs! - void Purge() { - Pop(); - Push(); - } - - template <typename ReturnType = jobject> - ReturnType Pop(ReturnType aResult = nullptr) { - MOZ_ASSERT(mHasFrameBeenPushed); - mHasFrameBeenPushed = false; - return static_cast<ReturnType>( - mJNIEnv->PopLocalFrame(static_cast<jobject>(aResult))); - } - -private: - void Push() { - MOZ_ASSERT(!mHasFrameBeenPushed); - // Make sure there is enough space to store a local ref to the - // exception. I am not completely sure this is needed, but does - // not hurt. - if (mJNIEnv->PushLocalFrame(mEntries + 1) != 0) { - CheckForException(); - return; - } - mHasFrameBeenPushed = true; - } - - const int mEntries; - JNIEnv* const mJNIEnv; - bool mHasFrameBeenPushed; -}; - -} - -#define NS_ANDROIDBRIDGE_CID \ -{ 0x0FE2321D, 0xEBD9, 0x467D, \ - { 0xA7, 0x43, 0x03, 0xA6, 0x8D, 0x40, 0x59, 0x9E } } - -class nsAndroidBridge final : public nsIAndroidBridge, - public nsIObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIANDROIDBRIDGE - NS_DECL_NSIOBSERVER - - nsAndroidBridge(); - -private: - ~nsAndroidBridge(); - - void AddObservers(); - void RemoveObservers(); - - void UpdateAudioPlayingWindows(uint64_t aWindowId, bool aPlaying); - - nsTArray<uint64_t> mAudioPlayingWindows; - -protected: -}; - -#endif /* AndroidBridge_h__ */ diff --git a/widget/android/AndroidBridgeUtilities.h b/widget/android/AndroidBridgeUtilities.h deleted file mode 100644 index ca8326281..000000000 --- a/widget/android/AndroidBridgeUtilities.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ALOG -#if defined(DEBUG) || defined(FORCE_ALOG) -#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args) -#else -#define ALOG(args...) ((void)0) -#endif -#endif - -#ifdef DEBUG -#define ALOG_BRIDGE(args...) ALOG(args) -#else -#define ALOG_BRIDGE(args...) ((void)0) -#endif diff --git a/widget/android/AndroidCompositorWidget.cpp b/widget/android/AndroidCompositorWidget.cpp deleted file mode 100644 index 91cc08531..000000000 --- a/widget/android/AndroidCompositorWidget.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=2 et tw=80 : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "AndroidCompositorWidget.h" -#include "nsWindow.h" - -namespace mozilla { -namespace widget { - -void -AndroidCompositorWidget::SetFirstPaintViewport(const LayerIntPoint& aOffset, - const CSSToLayerScale& aZoom, - const CSSRect& aCssPageRect) -{ - auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient(); - if (!layerClient) { - return; - } - - layerClient->SetFirstPaintViewport( - float(aOffset.x), float(aOffset.y), aZoom.scale, aCssPageRect.x, - aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost()); -} - -void -AndroidCompositorWidget::SyncFrameMetrics(const ParentLayerPoint& aScrollOffset, - const CSSToParentLayerScale& aZoom, - const CSSRect& aCssPageRect, - const CSSRect& aDisplayPort, - const CSSToLayerScale& aPaintedResolution, - bool aLayersUpdated, - int32_t aPaintSyncId, - ScreenMargin& aFixedLayerMargins) -{ - auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient(); - if (!layerClient) { - return; - } - - // convert the displayport rect from document-relative CSS pixels to - // document-relative device pixels - LayerIntRect dp = gfx::RoundedToInt(aDisplayPort * aPaintedResolution); - - java::ViewTransform::LocalRef viewTransform = layerClient->SyncFrameMetrics( - aScrollOffset.x, aScrollOffset.y, aZoom.scale, - aCssPageRect.x, aCssPageRect.y, - aCssPageRect.XMost(), aCssPageRect.YMost(), - dp.x, dp.y, dp.width, dp.height, - aPaintedResolution.scale, aLayersUpdated, aPaintSyncId); - - MOZ_ASSERT(viewTransform, "No view transform object!"); - - aFixedLayerMargins.top = viewTransform->FixedLayerMarginTop(); - aFixedLayerMargins.right = viewTransform->FixedLayerMarginRight(); - aFixedLayerMargins.bottom = viewTransform->FixedLayerMarginBottom(); - aFixedLayerMargins.left = viewTransform->FixedLayerMarginLeft(); -} - -} // namespace widget -} // namespace mozilla diff --git a/widget/android/AndroidCompositorWidget.h b/widget/android/AndroidCompositorWidget.h deleted file mode 100644 index 23076e30d..000000000 --- a/widget/android/AndroidCompositorWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_widget_AndroidCompositorWidget_h -#define mozilla_widget_AndroidCompositorWidget_h - -#include "mozilla/widget/InProcessCompositorWidget.h" - -namespace mozilla { -namespace widget { - -/** - * AndroidCompositorWidget inherits from InProcessCompositorWidget because - * Android does not support OOP compositing yet. Once it does, - * AndroidCompositorWidget will be made to inherit from CompositorWidget - * instead. - */ -class AndroidCompositorWidget final : public InProcessCompositorWidget -{ -public: - using InProcessCompositorWidget::InProcessCompositorWidget; - - AndroidCompositorWidget* AsAndroid() override { return this; } - - void SetFirstPaintViewport(const LayerIntPoint& aOffset, - const CSSToLayerScale& aZoom, - const CSSRect& aCssPageRect); - - void SyncFrameMetrics(const ParentLayerPoint& aScrollOffset, - const CSSToParentLayerScale& aZoom, - const CSSRect& aCssPageRect, - const CSSRect& aDisplayPort, - const CSSToLayerScale& aPaintedResolution, - bool aLayersUpdated, - int32_t aPaintSyncId, - ScreenMargin& aFixedLayerMargins); -}; - -} // namespace widget -} // namespace mozilla - -#endif // mozilla_widget_AndroidCompositorWidget_h diff --git a/widget/android/AndroidContentController.cpp b/widget/android/AndroidContentController.cpp deleted file mode 100644 index 1df053afb..000000000 --- a/widget/android/AndroidContentController.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "AndroidContentController.h" - -#include "AndroidBridge.h" -#include "base/message_loop.h" -#include "mozilla/layers/APZCCallbackHelper.h" -#include "mozilla/layers/IAPZCTreeManager.h" -#include "nsIObserverService.h" -#include "nsLayoutUtils.h" -#include "nsWindow.h" - -using mozilla::layers::IAPZCTreeManager; - -namespace mozilla { -namespace widget { - -void -AndroidContentController::Destroy() -{ - mAndroidWindow = nullptr; - ChromeProcessController::Destroy(); -} - -void -AndroidContentController::NotifyDefaultPrevented(IAPZCTreeManager* aManager, - uint64_t aInputBlockId, - bool aDefaultPrevented) -{ - if (!AndroidBridge::IsJavaUiThread()) { - // The notification must reach the APZ on the Java UI thread (aka the - // APZ "controller" thread) but we get it from the Gecko thread, so we - // have to throw it onto the other thread. - AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableMethod<uint64_t, bool>( - aManager, &IAPZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aDefaultPrevented), 0); - return; - } - - aManager->ContentReceivedInputBlock(aInputBlockId, aDefaultPrevented); -} - -void -AndroidContentController::DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint, - const ScrollableLayerGuid& aGuid) const -{ - nsIContent* content = nsLayoutUtils::FindContentFor(aGuid.mScrollId); - nsPresContext* context = content - ? mozilla::layers::APZCCallbackHelper::GetPresContextForContent(content) - : nullptr; - - if (!context) { - return; - } - - CSSPoint point = mozilla::layers::APZCCallbackHelper::ApplyCallbackTransform( - aPoint / context->CSSToDevPixelScale(), aGuid); - - nsPresContext* rcdContext = context->GetToplevelContentDocumentPresContext(); - if (rcdContext && rcdContext->PresShell()->ScaleToResolution()) { - // We need to convert from the root document to the root content document, - // by unapplying the resolution that's on the content document. - const float resolution = rcdContext->PresShell()->GetResolution(); - point.x /= resolution; - point.y /= resolution; - } - - CSSIntPoint rounded = RoundedToInt(point); - nsAppShell::PostEvent([rounded] { - nsCOMPtr<nsIObserverService> obsServ = - mozilla::services::GetObserverService(); - if (!obsServ) { - return; - } - - nsPrintfCString data("{\"x\":%d,\"y\":%d}", rounded.x, rounded.y); - obsServ->NotifyObservers(nullptr, "Gesture:SingleTap", - NS_ConvertASCIItoUTF16(data).get()); - }); -} - -void -AndroidContentController::HandleTap(TapType aType, const LayoutDevicePoint& aPoint, - Modifiers aModifiers, - const ScrollableLayerGuid& aGuid, - uint64_t aInputBlockId) -{ - // This function will get invoked first on the Java UI thread, and then - // again on the main thread (because of the code in ChromeProcessController:: - // HandleTap). We want to post the SingleTap message once; it can be - // done from either thread but we need access to the callback transform - // so we do it from the main thread. - if (NS_IsMainThread() && - (aType == TapType::eSingleTap || aType == TapType::eSecondTap)) { - DispatchSingleTapToObservers(aPoint, aGuid); - } - - ChromeProcessController::HandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId); -} - -void -AndroidContentController::PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) -{ - AndroidBridge::Bridge()->PostTaskToUiThread(Move(aTask), aDelayMs); -} -void -AndroidContentController::UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent) -{ - if (aIsRootContent && mAndroidWindow) { - mAndroidWindow->UpdateOverscrollVelocity(aX, aY); - } -} - -void -AndroidContentController::UpdateOverscrollOffset(const float aX, const float aY, const bool aIsRootContent) -{ - if (aIsRootContent && mAndroidWindow) { - mAndroidWindow->UpdateOverscrollOffset(aX, aY); - } -} - -void -AndroidContentController::SetScrollingRootContent(const bool isRootContent) -{ - if (mAndroidWindow) { - mAndroidWindow->SetScrollingRootContent(isRootContent); - } -} - -void -AndroidContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, - APZStateChange aChange, - int aArg) -{ - // This function may get invoked twice, if the first invocation is not on - // the main thread then the ChromeProcessController version of this function - // will redispatch to the main thread. We want to make sure that our handling - // only happens on the main thread. - ChromeProcessController::NotifyAPZStateChange(aGuid, aChange, aArg); - if (NS_IsMainThread()) { - nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); - if (aChange == layers::GeckoContentController::APZStateChange::eTransformEnd) { - // This is used by tests to determine when the APZ is done doing whatever - // it's doing. XXX generify this as needed when writing additional tests. - observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr); - observerService->NotifyObservers(nullptr, "PanZoom:StateChange", u"NOTHING"); - } else if (aChange == layers::GeckoContentController::APZStateChange::eTransformBegin) { - observerService->NotifyObservers(nullptr, "PanZoom:StateChange", u"PANNING"); - } - } -} - -} // namespace widget -} // namespace mozilla diff --git a/widget/android/AndroidContentController.h b/widget/android/AndroidContentController.h deleted file mode 100644 index 39674c939..000000000 --- a/widget/android/AndroidContentController.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidContentController_h__ -#define AndroidContentController_h__ - -#include "mozilla/layers/ChromeProcessController.h" -#include "mozilla/EventForwards.h" // for Modifiers -#include "mozilla/StaticPtr.h" -#include "mozilla/TimeStamp.h" -#include "nsIDOMWindowUtils.h" -#include "nsTArray.h" -#include "nsWindow.h" - -namespace mozilla { -namespace layers { -class APZEventState; -class IAPZCTreeManager; -} -namespace widget { - -class AndroidContentController final - : public mozilla::layers::ChromeProcessController -{ -public: - AndroidContentController(nsWindow* aWindow, - mozilla::layers::APZEventState* aAPZEventState, - mozilla::layers::IAPZCTreeManager* aAPZCTreeManager) - : mozilla::layers::ChromeProcessController(aWindow, aAPZEventState, aAPZCTreeManager) - , mAndroidWindow(aWindow) - {} - - // ChromeProcessController methods - virtual void Destroy() override; - void HandleTap(TapType aType, const LayoutDevicePoint& aPoint, Modifiers aModifiers, - const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) override; - void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) override; - void UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent) override; - void UpdateOverscrollOffset(const float aX, const float aY, const bool aIsRootContent) override; - void SetScrollingRootContent(const bool isRootContent) override; - void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, - APZStateChange aChange, - int aArg) override; - - static void NotifyDefaultPrevented(mozilla::layers::IAPZCTreeManager* aManager, - uint64_t aInputBlockId, bool aDefaultPrevented); -private: - nsWindow* mAndroidWindow; - - void DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint, - const ScrollableLayerGuid& aGuid) const; -}; - -} // namespace widget -} // namespace mozilla - -#endif diff --git a/widget/android/AndroidDirectTexture.h b/widget/android/AndroidDirectTexture.h deleted file mode 100644 index 8582b8582..000000000 --- a/widget/android/AndroidDirectTexture.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidDirectTexture_h_ -#define AndroidDirectTexture_h_ - -#include "gfxTypes.h" -#include "mozilla/Mutex.h" -#include "AndroidGraphicBuffer.h" -#include "nsRect.h" - -namespace mozilla { - -/** - * This is a thread safe wrapper around AndroidGraphicBuffer that handles - * double buffering. Each call to Bind() flips the buffer when necessary. - * - * You need to be careful when destroying an instance of this class. If either - * buffer is locked by the application of the driver/hardware, bad things will - * happen. Be sure that the OpenGL texture is no longer on the screen. - */ -class AndroidDirectTexture -{ -public: - AndroidDirectTexture(uint32_t width, uint32_t height, uint32_t usage, gfxImageFormat format); - virtual ~AndroidDirectTexture(); - - bool Lock(uint32_t usage, unsigned char **bits); - bool Lock(uint32_t usage, const nsIntRect& rect, unsigned char **bits); - bool Unlock(bool aFlip = true); - - bool Reallocate(uint32_t aWidth, uint32_t aHeight); - bool Reallocate(uint32_t aWidth, uint32_t aHeight, gfxImageFormat aFormat); - - uint32_t Width() { return mWidth; } - uint32_t Height() { return mHeight; } - - bool Bind(); - -private: - mozilla::Mutex mLock; - bool mNeedFlip; - - uint32_t mWidth; - uint32_t mHeight; - gfxImageFormat mFormat; - - AndroidGraphicBuffer* mFrontBuffer; - AndroidGraphicBuffer* mBackBuffer; - - AndroidGraphicBuffer* mPendingReallocBuffer; - void ReallocPendingBuffer(); -}; - -} /* mozilla */ -#endif /* AndroidDirectTexture_h_ */ diff --git a/widget/android/AndroidGraphicBuffer.h b/widget/android/AndroidGraphicBuffer.h deleted file mode 100644 index 269f8680a..000000000 --- a/widget/android/AndroidGraphicBuffer.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidGraphicBuffer_h_ -#define AndroidGraphicBuffer_h_ - -#include "gfxTypes.h" -#include "nsRect.h" - -typedef void* EGLImageKHR; -typedef void* EGLClientBuffer; - -namespace mozilla { - -/** - * This class allows access to Android's direct texturing mechanism. Locking - * the buffer gives you a pointer you can read/write to directly. It is fully - * threadsafe, but you probably really want to use the AndroidDirectTexture - * class which will handle double buffering. - * - * In order to use the buffer in OpenGL, just call Bind() and it will attach - * to whatever texture is bound to GL_TEXTURE_2D. - */ -class AndroidGraphicBuffer -{ -public: - enum { - UsageSoftwareRead = 1, - UsageSoftwareWrite = 1 << 1, - UsageTexture = 1 << 2, - UsageTarget = 1 << 3, - Usage2D = 1 << 4 - }; - - AndroidGraphicBuffer(uint32_t width, uint32_t height, uint32_t usage, gfxImageFormat format); - virtual ~AndroidGraphicBuffer(); - - int Lock(uint32_t usage, unsigned char **bits); - int Lock(uint32_t usage, const nsIntRect& rect, unsigned char **bits); - int Unlock(); - bool Reallocate(uint32_t aWidth, uint32_t aHeight, gfxImageFormat aFormat); - - uint32_t Width() { return mWidth; } - uint32_t Height() { return mHeight; } - - bool Bind(); - - static bool IsBlacklisted(); - -private: - uint32_t mWidth; - uint32_t mHeight; - uint32_t mUsage; - gfxImageFormat mFormat; - - bool EnsureInitialized(); - bool EnsureEGLImage(); - - void DestroyBuffer(); - bool EnsureBufferCreated(); - - uint32_t GetAndroidUsage(uint32_t aUsage); - uint32_t GetAndroidFormat(gfxImageFormat aFormat); - - void *mHandle; - void *mEGLImage; -}; - -} /* mozilla */ -#endif /* AndroidGraphicBuffer_h_ */ diff --git a/widget/android/AndroidJNI.cpp b/widget/android/AndroidJNI.cpp deleted file mode 100644 index 3e27d253b..000000000 --- a/widget/android/AndroidJNI.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Hal.h" -#include "nsIFile.h" -#include "nsString.h" - -#include "AndroidBridge.h" -#include "AndroidContentController.h" -#include "AndroidGraphicBuffer.h" - -#include <jni.h> -#include <pthread.h> -#include <dlfcn.h> -#include <stdio.h> -#include <unistd.h> - -#include "nsAppShell.h" -#include "nsWindow.h" -#include <android/log.h> -#include "nsIObserverService.h" -#include "mozilla/Services.h" -#include "nsThreadUtils.h" - -#include "mozilla/Unused.h" -#include "mozilla/MathAlgorithms.h" -#include "mozilla/UniquePtr.h" - -#include "mozilla/layers/APZCTreeManager.h" -#include "nsPluginInstanceOwner.h" -#include "AndroidSurfaceTexture.h" - -using namespace mozilla; -using namespace mozilla::dom; -using namespace mozilla::layers; -using namespace mozilla::widget; - -/* Forward declare all the JNI methods as extern "C" */ - -extern "C" { -/* - * Incoming JNI methods - */ - -} diff --git a/widget/android/AndroidJNIWrapper.cpp b/widget/android/AndroidJNIWrapper.cpp deleted file mode 100644 index e549c6fc7..000000000 --- a/widget/android/AndroidJNIWrapper.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include <android/log.h> -#include <dlfcn.h> -#include <prthread.h> - -#include "mozilla/DebugOnly.h" -#include "mozilla/Assertions.h" -#include "mozilla/SyncRunnable.h" -#include "nsThreadUtils.h" -#include "AndroidBridge.h" - -extern "C" { - jclass __jsjni_GetGlobalClassRef(const char *className); -} - -class GetGlobalClassRefRunnable : public mozilla::Runnable { - public: - GetGlobalClassRefRunnable(const char *className, jclass *foundClass) : - mClassName(className), mResult(foundClass) {} - NS_IMETHOD Run() override { - *mResult = __jsjni_GetGlobalClassRef(mClassName); - return NS_OK; - } - private: - const char *mClassName; - jclass *mResult; -}; - -extern "C" { - __attribute__ ((visibility("default"))) - jclass - jsjni_FindClass(const char *className) { - // FindClass outside the main thread will run into problems due - // to missing the classpath - MOZ_ASSERT(NS_IsMainThread()); - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - return env->FindClass(className); - } - - jclass - __jsjni_GetGlobalClassRef(const char *className) { - // root class globally - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - jclass globalRef = static_cast<jclass>(env->NewGlobalRef(env->FindClass(className))); - if (!globalRef) - return nullptr; - - // return the newly create global reference - return globalRef; - } - - __attribute__ ((visibility("default"))) - jclass - jsjni_GetGlobalClassRef(const char *className) { - if (NS_IsMainThread()) { - return __jsjni_GetGlobalClassRef(className); - } - - nsCOMPtr<nsIThread> mainThread; - mozilla::DebugOnly<nsresult> rv = NS_GetMainThread(getter_AddRefs(mainThread)); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - - jclass foundClass; - nsCOMPtr<nsIRunnable> runnable_ref(new GetGlobalClassRefRunnable(className, - &foundClass)); - RefPtr<mozilla::SyncRunnable> sr = new mozilla::SyncRunnable(runnable_ref); - sr->DispatchToThread(mainThread); - if (!foundClass) - return nullptr; - - return foundClass; - } - - __attribute__ ((visibility("default"))) - jmethodID - jsjni_GetStaticMethodID(jclass methodClass, - const char *methodName, - const char *signature) { - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - return env->GetStaticMethodID(methodClass, methodName, signature); - } - - __attribute__ ((visibility("default"))) - bool - jsjni_ExceptionCheck() { - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - return env->ExceptionCheck(); - } - - __attribute__ ((visibility("default"))) - void - jsjni_CallStaticVoidMethodA(jclass cls, - jmethodID method, - jvalue *values) { - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - - mozilla::AutoLocalJNIFrame jniFrame(env); - env->CallStaticVoidMethodA(cls, method, values); - } - - __attribute__ ((visibility("default"))) - int - jsjni_CallStaticIntMethodA(jclass cls, - jmethodID method, - jvalue *values) { - JNIEnv *env = mozilla::jni::GetGeckoThreadEnv(); - - mozilla::AutoLocalJNIFrame jniFrame(env); - return env->CallStaticIntMethodA(cls, method, values); - } - - __attribute__ ((visibility("default"))) - jobject jsjni_GetGlobalContextRef() { - return mozilla::AndroidBridge::Bridge()->GetGlobalContextRef(); - } - - __attribute__ ((visibility("default"))) - JavaVM* jsjni_GetVM() { - JavaVM* jvm; - JNIEnv* const env = mozilla::jni::GetGeckoThreadEnv(); - MOZ_ALWAYS_TRUE(!env->GetJavaVM(&jvm)); - return jvm; - } - - __attribute__ ((visibility("default"))) - JNIEnv* jsjni_GetJNIForThread() { - return mozilla::jni::GetEnvForThread(); - } - - // For compatibility with JNI.jsm; some addons bundle their own JNI.jsm, - // so we cannot just change the function name used in JNI.jsm. - __attribute__ ((visibility("default"))) - JNIEnv* GetJNIForThread() { - return mozilla::jni::GetEnvForThread(); - } -} diff --git a/widget/android/AndroidJNIWrapper.h b/widget/android/AndroidJNIWrapper.h deleted file mode 100644 index 90bca2693..000000000 --- a/widget/android/AndroidJNIWrapper.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidJNIWrapper_h__ -#define AndroidJNIWrapper_h__ - -#include "mozilla/Types.h" -#include <jni.h> -#include <android/log.h> - -extern "C" MOZ_EXPORT jclass jsjni_FindClass(const char *className); - -/** - * JNIEnv::FindClass alternative. - * Callable from any thread, including code - * invoked via the JNI that doesn't have MOZILLA_INTERNAL_API defined. - * The caller is responsible for ensuring that the class is not leaked by - * calling DeleteGlobalRef at an appropriate time. - */ -extern "C" MOZ_EXPORT jclass jsjni_GetGlobalClassRef(const char *className); - -extern "C" MOZ_EXPORT jmethodID jsjni_GetStaticMethodID(jclass methodClass, - const char *methodName, - const char *signature); -extern "C" MOZ_EXPORT bool jsjni_ExceptionCheck(); -extern "C" MOZ_EXPORT void jsjni_CallStaticVoidMethodA(jclass cls, jmethodID method, jvalue *values); -extern "C" MOZ_EXPORT int jsjni_CallStaticIntMethodA(jclass cls, jmethodID method, jvalue *values); -extern "C" MOZ_EXPORT jobject jsjni_GetGlobalContextRef(); -extern "C" MOZ_EXPORT JavaVM* jsjni_GetVM(); -extern "C" MOZ_EXPORT JNIEnv* jsjni_GetJNIForThread(); - -#endif /* AndroidJNIWrapper_h__ */ diff --git a/widget/android/AndroidJavaWrappers.cpp b/widget/android/AndroidJavaWrappers.cpp deleted file mode 100644 index eb657a9c4..000000000 --- a/widget/android/AndroidJavaWrappers.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "AndroidJavaWrappers.h" - -using namespace mozilla; - -nsJNIString::nsJNIString(jstring jstr, JNIEnv *jenv) -{ - if (!jstr) { - SetIsVoid(true); - return; - } - JNIEnv *jni = jenv; - if (!jni) { - jni = jni::GetGeckoThreadEnv(); - } - const jchar* jCharPtr = jni->GetStringChars(jstr, nullptr); - - if (!jCharPtr) { - SetIsVoid(true); - return; - } - - jsize len = jni->GetStringLength(jstr); - - if (len <= 0) { - SetIsVoid(true); - } else { - Assign(reinterpret_cast<const char16_t*>(jCharPtr), len); - } - jni->ReleaseStringChars(jstr, jCharPtr); -} - -nsJNICString::nsJNICString(jstring jstr, JNIEnv *jenv) -{ - if (!jstr) { - SetIsVoid(true); - return; - } - JNIEnv *jni = jenv; - if (!jni) { - jni = jni::GetGeckoThreadEnv(); - } - const char* jCharPtr = jni->GetStringUTFChars(jstr, nullptr); - - if (!jCharPtr) { - SetIsVoid(true); - return; - } - - jsize len = jni->GetStringUTFLength(jstr); - - if (len <= 0) { - SetIsVoid(true); - } else { - Assign(jCharPtr, len); - } - jni->ReleaseStringUTFChars(jstr, jCharPtr); -} diff --git a/widget/android/AndroidJavaWrappers.h b/widget/android/AndroidJavaWrappers.h deleted file mode 100644 index fadf97353..000000000 --- a/widget/android/AndroidJavaWrappers.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef AndroidJavaWrappers_h__ -#define AndroidJavaWrappers_h__ - -#include <jni.h> -#include <android/input.h> -#include <android/log.h> -#include <android/api-level.h> - -#include "nsRect.h" -#include "nsString.h" -#include "nsTArray.h" -#include "nsIAndroidBridge.h" -#include "mozilla/gfx/Rect.h" -#include "mozilla/dom/Touch.h" -#include "mozilla/EventForwards.h" -#include "InputData.h" -#include "Units.h" -#include "FrameMetrics.h" - -//#define FORCE_ALOG 1 - -class nsIAndroidDisplayport; -class nsIWidget; - -namespace mozilla { - -enum { - // These keycode masks are not defined in android/keycodes.h: -#if __ANDROID_API__ < 13 - AKEYCODE_ESCAPE = 111, - AKEYCODE_FORWARD_DEL = 112, - AKEYCODE_CTRL_LEFT = 113, - AKEYCODE_CTRL_RIGHT = 114, - AKEYCODE_CAPS_LOCK = 115, - AKEYCODE_SCROLL_LOCK = 116, - AKEYCODE_META_LEFT = 117, - AKEYCODE_META_RIGHT = 118, - AKEYCODE_FUNCTION = 119, - AKEYCODE_SYSRQ = 120, - AKEYCODE_BREAK = 121, - AKEYCODE_MOVE_HOME = 122, - AKEYCODE_MOVE_END = 123, - AKEYCODE_INSERT = 124, - AKEYCODE_FORWARD = 125, - AKEYCODE_MEDIA_PLAY = 126, - AKEYCODE_MEDIA_PAUSE = 127, - AKEYCODE_MEDIA_CLOSE = 128, - AKEYCODE_MEDIA_EJECT = 129, - AKEYCODE_MEDIA_RECORD = 130, - AKEYCODE_F1 = 131, - AKEYCODE_F2 = 132, - AKEYCODE_F3 = 133, - AKEYCODE_F4 = 134, - AKEYCODE_F5 = 135, - AKEYCODE_F6 = 136, - AKEYCODE_F7 = 137, - AKEYCODE_F8 = 138, - AKEYCODE_F9 = 139, - AKEYCODE_F10 = 140, - AKEYCODE_F11 = 141, - AKEYCODE_F12 = 142, - AKEYCODE_NUM_LOCK = 143, - AKEYCODE_NUMPAD_0 = 144, - AKEYCODE_NUMPAD_1 = 145, - AKEYCODE_NUMPAD_2 = 146, - AKEYCODE_NUMPAD_3 = 147, - AKEYCODE_NUMPAD_4 = 148, - AKEYCODE_NUMPAD_5 = 149, - AKEYCODE_NUMPAD_6 = 150, - AKEYCODE_NUMPAD_7 = 151, - AKEYCODE_NUMPAD_8 = 152, - AKEYCODE_NUMPAD_9 = 153, - AKEYCODE_NUMPAD_DIVIDE = 154, - AKEYCODE_NUMPAD_MULTIPLY = 155, - AKEYCODE_NUMPAD_SUBTRACT = 156, - AKEYCODE_NUMPAD_ADD = 157, - AKEYCODE_NUMPAD_DOT = 158, - AKEYCODE_NUMPAD_COMMA = 159, - AKEYCODE_NUMPAD_ENTER = 160, - AKEYCODE_NUMPAD_EQUALS = 161, - AKEYCODE_NUMPAD_LEFT_PAREN = 162, - AKEYCODE_NUMPAD_RIGHT_PAREN = 163, - AKEYCODE_VOLUME_MUTE = 164, - AKEYCODE_INFO = 165, - AKEYCODE_CHANNEL_UP = 166, - AKEYCODE_CHANNEL_DOWN = 167, - AKEYCODE_ZOOM_IN = 168, - AKEYCODE_ZOOM_OUT = 169, - AKEYCODE_TV = 170, - AKEYCODE_WINDOW = 171, - AKEYCODE_GUIDE = 172, - AKEYCODE_DVR = 173, - AKEYCODE_BOOKMARK = 174, - AKEYCODE_CAPTIONS = 175, - AKEYCODE_SETTINGS = 176, - AKEYCODE_TV_POWER = 177, - AKEYCODE_TV_INPUT = 178, - AKEYCODE_STB_POWER = 179, - AKEYCODE_STB_INPUT = 180, - AKEYCODE_AVR_POWER = 181, - AKEYCODE_AVR_INPUT = 182, - AKEYCODE_PROG_RED = 183, - AKEYCODE_PROG_GREEN = 184, - AKEYCODE_PROG_YELLOW = 185, - AKEYCODE_PROG_BLUE = 186, - AKEYCODE_APP_SWITCH = 187, - AKEYCODE_BUTTON_1 = 188, - AKEYCODE_BUTTON_2 = 189, - AKEYCODE_BUTTON_3 = 190, - AKEYCODE_BUTTON_4 = 191, - AKEYCODE_BUTTON_5 = 192, - AKEYCODE_BUTTON_6 = 193, - AKEYCODE_BUTTON_7 = 194, - AKEYCODE_BUTTON_8 = 195, - AKEYCODE_BUTTON_9 = 196, - AKEYCODE_BUTTON_10 = 197, - AKEYCODE_BUTTON_11 = 198, - AKEYCODE_BUTTON_12 = 199, - AKEYCODE_BUTTON_13 = 200, - AKEYCODE_BUTTON_14 = 201, - AKEYCODE_BUTTON_15 = 202, - AKEYCODE_BUTTON_16 = 203, -#endif -#if __ANDROID_API__ < 14 - AKEYCODE_LANGUAGE_SWITCH = 204, - AKEYCODE_MANNER_MODE = 205, - AKEYCODE_3D_MODE = 206, -#endif -#if __ANDROID_API__ < 15 - AKEYCODE_CONTACTS = 207, - AKEYCODE_CALENDAR = 208, - AKEYCODE_MUSIC = 209, - AKEYCODE_CALCULATOR = 210, -#endif -#if __ANDROID_API__ < 16 - AKEYCODE_ZENKAKU_HANKAKU = 211, - AKEYCODE_EISU = 212, - AKEYCODE_MUHENKAN = 213, - AKEYCODE_HENKAN = 214, - AKEYCODE_KATAKANA_HIRAGANA = 215, - AKEYCODE_YEN = 216, - AKEYCODE_RO = 217, - AKEYCODE_KANA = 218, - AKEYCODE_ASSIST = 219, -#endif - - AMETA_FUNCTION_ON = 0x00000008, - AMETA_CTRL_ON = 0x00001000, - AMETA_CTRL_LEFT_ON = 0x00002000, - AMETA_CTRL_RIGHT_ON = 0x00004000, - AMETA_META_ON = 0x00010000, - AMETA_META_LEFT_ON = 0x00020000, - AMETA_META_RIGHT_ON = 0x00040000, - AMETA_CAPS_LOCK_ON = 0x00100000, - AMETA_NUM_LOCK_ON = 0x00200000, - AMETA_SCROLL_LOCK_ON = 0x00400000, - - AMETA_ALT_MASK = AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON | AMETA_ALT_ON, - AMETA_CTRL_MASK = AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON | AMETA_CTRL_ON, - AMETA_META_MASK = AMETA_META_LEFT_ON | AMETA_META_RIGHT_ON | AMETA_META_ON, - AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON, -}; - -class AndroidMotionEvent -{ -public: - enum { - ACTION_DOWN = 0, - ACTION_UP = 1, - ACTION_MOVE = 2, - ACTION_CANCEL = 3, - ACTION_OUTSIDE = 4, - ACTION_POINTER_DOWN = 5, - ACTION_POINTER_UP = 6, - ACTION_HOVER_MOVE = 7, - ACTION_HOVER_ENTER = 9, - ACTION_HOVER_EXIT = 10, - ACTION_MAGNIFY_START = 11, - ACTION_MAGNIFY = 12, - ACTION_MAGNIFY_END = 13, - EDGE_TOP = 0x00000001, - EDGE_BOTTOM = 0x00000002, - EDGE_LEFT = 0x00000004, - EDGE_RIGHT = 0x00000008, - SAMPLE_X = 0, - SAMPLE_Y = 1, - SAMPLE_PRESSURE = 2, - SAMPLE_SIZE = 3, - NUM_SAMPLE_DATA = 4, - TOOL_TYPE_UNKNOWN = 0, - TOOL_TYPE_FINGER = 1, - TOOL_TYPE_STYLUS = 2, - TOOL_TYPE_MOUSE = 3, - TOOL_TYPE_ERASER = 4, - dummy_java_enum_list_end - }; -}; - -class nsJNIString : public nsString -{ -public: - nsJNIString(jstring jstr, JNIEnv *jenv); -}; - -class nsJNICString : public nsCString -{ -public: - nsJNICString(jstring jstr, JNIEnv *jenv); -}; - -} - -#endif diff --git a/widget/android/GeckoBatteryManager.h b/widget/android/GeckoBatteryManager.h deleted file mode 100644 index a09e83efd..000000000 --- a/widget/android/GeckoBatteryManager.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GeckoBatteryManager_h -#define GeckoBatteryManager_h - -#include "GeneratedJNINatives.h" -#include "nsAppShell.h" - -#include "mozilla/Hal.h" - -namespace mozilla { - -class GeckoBatteryManager final - : public java::GeckoBatteryManager::Natives<GeckoBatteryManager> -{ -public: - static void - OnBatteryChange(double aLevel, bool aCharging, double aRemainingTime) - { - hal::NotifyBatteryChange( - hal::BatteryInformation(aLevel, aCharging, aRemainingTime)); - } -}; - -} // namespace mozilla - -#endif // GeckoBatteryManager_h diff --git a/widget/android/GeckoNetworkManager.h b/widget/android/GeckoNetworkManager.h deleted file mode 100644 index 63cbb9c79..000000000 --- a/widget/android/GeckoNetworkManager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GeckoNetworkManager_h -#define GeckoNetworkManager_h - -#include "GeneratedJNINatives.h" -#include "nsAppShell.h" -#include "nsCOMPtr.h" -#include "nsINetworkLinkService.h" - -#include "mozilla/Services.h" - -namespace mozilla { - -class GeckoNetworkManager final - : public java::GeckoNetworkManager::Natives<GeckoNetworkManager> -{ - GeckoNetworkManager() = delete; - -public: - static void - OnConnectionChanged(int32_t aType, jni::String::Param aSubType, - bool aIsWifi, int32_t aGateway) - { - hal::NotifyNetworkChange(hal::NetworkInformation( - aType, aIsWifi, aGateway)); - - nsCOMPtr<nsIObserverService> os = services::GetObserverService(); - if (os) { - os->NotifyObservers(nullptr, - NS_NETWORK_LINK_TYPE_TOPIC, - aSubType->ToString().get()); - } - } - - static void - OnStatusChanged(jni::String::Param aStatus) - { - nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); - if (os) { - os->NotifyObservers(nullptr, - NS_NETWORK_LINK_TOPIC, - aStatus->ToString().get()); - } - } -}; - -} // namespace mozilla - -#endif // GeckoNetworkManager_h diff --git a/widget/android/GeckoScreenOrientation.h b/widget/android/GeckoScreenOrientation.h deleted file mode 100644 index c6e5861be..000000000 --- a/widget/android/GeckoScreenOrientation.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GeckoScreenOrientation_h -#define GeckoScreenOrientation_h - -#include "GeneratedJNINatives.h" -#include "nsAppShell.h" -#include "nsCOMPtr.h" -#include "nsIScreenManager.h" - -#include "mozilla/Hal.h" -#include "mozilla/dom/ScreenOrientation.h" - -namespace mozilla { - -class GeckoScreenOrientation final - : public java::GeckoScreenOrientation::Natives<GeckoScreenOrientation> -{ - GeckoScreenOrientation() = delete; - -public: - static void - OnOrientationChange(int16_t aOrientation, int16_t aAngle) - { - nsCOMPtr<nsIScreenManager> screenMgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - nsCOMPtr<nsIScreen> screen; - - if (!screenMgr || NS_FAILED(screenMgr->GetPrimaryScreen( - getter_AddRefs(screen))) || !screen) { - return; - } - - nsIntRect rect; - int32_t colorDepth, pixelDepth; - - if (NS_FAILED(screen->GetRect(&rect.x, &rect.y, - &rect.width, &rect.height)) || - NS_FAILED(screen->GetColorDepth(&colorDepth)) || - NS_FAILED(screen->GetPixelDepth(&pixelDepth))) { - return; - } - - hal::NotifyScreenConfigurationChange(hal::ScreenConfiguration( - rect, static_cast<dom::ScreenOrientationInternal>(aOrientation), - aAngle, colorDepth, pixelDepth)); - } -}; - -} // namespace mozilla - -#endif // GeckoScreenOrientation_h diff --git a/widget/android/GeneratedJNINatives.h b/widget/android/GeneratedJNINatives.h deleted file mode 100644 index bce88ce65..000000000 --- a/widget/android/GeneratedJNINatives.h +++ /dev/null @@ -1,526 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#ifndef GeneratedJNINatives_h -#define GeneratedJNINatives_h - -#include "GeneratedJNIWrappers.h" -#include "mozilla/jni/Natives.h" - -namespace mozilla { -namespace java { - -template<class Impl> -class AlarmReceiver::Natives : public mozilla::jni::NativeImpl<AlarmReceiver, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod AlarmReceiver::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<AlarmReceiver::NotifyAlarmFired_t>( - mozilla::jni::NativeStub<AlarmReceiver::NotifyAlarmFired_t, Impl> - ::template Wrap<&Impl::NotifyAlarmFired>) -}; - -template<class Impl> -class AndroidGamepadManager::Natives : public mozilla::jni::NativeImpl<AndroidGamepadManager, Impl> -{ -public: - static const JNINativeMethod methods[3]; -}; - -template<class Impl> -const JNINativeMethod AndroidGamepadManager::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnAxisChange_t>( - mozilla::jni::NativeStub<AndroidGamepadManager::OnAxisChange_t, Impl> - ::template Wrap<&Impl::OnAxisChange>), - - mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnButtonChange_t>( - mozilla::jni::NativeStub<AndroidGamepadManager::OnButtonChange_t, Impl> - ::template Wrap<&Impl::OnButtonChange>), - - mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnGamepadChange_t>( - mozilla::jni::NativeStub<AndroidGamepadManager::OnGamepadChange_t, Impl> - ::template Wrap<&Impl::OnGamepadChange>) -}; - -template<class Impl> -class GeckoAppShell::Natives : public mozilla::jni::NativeImpl<GeckoAppShell, Impl> -{ -public: - static const JNINativeMethod methods[8]; -}; - -template<class Impl> -const JNINativeMethod GeckoAppShell::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyObservers_t>( - mozilla::jni::NativeStub<GeckoAppShell::NotifyObservers_t, Impl> - ::template Wrap<&Impl::NotifyObservers>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyAlertListener_t>( - mozilla::jni::NativeStub<GeckoAppShell::NotifyAlertListener_t, Impl> - ::template Wrap<&Impl::NotifyAlertListener>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyUriVisited_t>( - mozilla::jni::NativeStub<GeckoAppShell::NotifyUriVisited_t, Impl> - ::template Wrap<&Impl::NotifyUriVisited>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::OnFullScreenPluginHidden_t>( - mozilla::jni::NativeStub<GeckoAppShell::OnFullScreenPluginHidden_t, Impl> - ::template Wrap<&Impl::OnFullScreenPluginHidden>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::OnLocationChanged_t>( - mozilla::jni::NativeStub<GeckoAppShell::OnLocationChanged_t, Impl> - ::template Wrap<&Impl::OnLocationChanged>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::OnSensorChanged_t>( - mozilla::jni::NativeStub<GeckoAppShell::OnSensorChanged_t, Impl> - ::template Wrap<&Impl::OnSensorChanged>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::ReportJavaCrash_t>( - mozilla::jni::NativeStub<GeckoAppShell::ReportJavaCrash_t, Impl> - ::template Wrap<&Impl::ReportJavaCrash>), - - mozilla::jni::MakeNativeMethod<GeckoAppShell::SyncNotifyObservers_t>( - mozilla::jni::NativeStub<GeckoAppShell::SyncNotifyObservers_t, Impl> - ::template Wrap<&Impl::SyncNotifyObservers>) -}; - -template<class Impl> -class GeckoAppShell::CameraCallback::Natives : public mozilla::jni::NativeImpl<CameraCallback, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod GeckoAppShell::CameraCallback::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoAppShell::CameraCallback::OnFrameData_t>( - mozilla::jni::NativeStub<GeckoAppShell::CameraCallback::OnFrameData_t, Impl> - ::template Wrap<&Impl::OnFrameData>) -}; - -template<class Impl> -class GeckoBatteryManager::Natives : public mozilla::jni::NativeImpl<GeckoBatteryManager, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod GeckoBatteryManager::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoBatteryManager::OnBatteryChange_t>( - mozilla::jni::NativeStub<GeckoBatteryManager::OnBatteryChange_t, Impl> - ::template Wrap<&Impl::OnBatteryChange>) -}; - -template<class Impl> -class GeckoEditable::Natives : public mozilla::jni::NativeImpl<GeckoEditable, Impl> -{ -public: - static const JNINativeMethod methods[7]; -}; - -template<class Impl> -const JNINativeMethod GeckoEditable::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoEditable::DisposeNative_t>( - mozilla::jni::NativeStub<GeckoEditable::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeAddCompositionRange_t>( - mozilla::jni::NativeStub<GeckoEditable::OnImeAddCompositionRange_t, Impl> - ::template Wrap<&Impl::OnImeAddCompositionRange>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeReplaceText_t>( - mozilla::jni::NativeStub<GeckoEditable::OnImeReplaceText_t, Impl> - ::template Wrap<&Impl::OnImeReplaceText>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeRequestCursorUpdates_t>( - mozilla::jni::NativeStub<GeckoEditable::OnImeRequestCursorUpdates_t, Impl> - ::template Wrap<&Impl::OnImeRequestCursorUpdates>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeSynchronize_t>( - mozilla::jni::NativeStub<GeckoEditable::OnImeSynchronize_t, Impl> - ::template Wrap<&Impl::OnImeSynchronize>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeUpdateComposition_t>( - mozilla::jni::NativeStub<GeckoEditable::OnImeUpdateComposition_t, Impl> - ::template Wrap<&Impl::OnImeUpdateComposition>), - - mozilla::jni::MakeNativeMethod<GeckoEditable::OnKeyEvent_t>( - mozilla::jni::NativeStub<GeckoEditable::OnKeyEvent_t, Impl> - ::template Wrap<&Impl::OnKeyEvent>) -}; - -template<class Impl> -class GeckoNetworkManager::Natives : public mozilla::jni::NativeImpl<GeckoNetworkManager, Impl> -{ -public: - static const JNINativeMethod methods[2]; -}; - -template<class Impl> -const JNINativeMethod GeckoNetworkManager::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoNetworkManager::OnConnectionChanged_t>( - mozilla::jni::NativeStub<GeckoNetworkManager::OnConnectionChanged_t, Impl> - ::template Wrap<&Impl::OnConnectionChanged>), - - mozilla::jni::MakeNativeMethod<GeckoNetworkManager::OnStatusChanged_t>( - mozilla::jni::NativeStub<GeckoNetworkManager::OnStatusChanged_t, Impl> - ::template Wrap<&Impl::OnStatusChanged>) -}; - -template<class Impl> -class GeckoScreenOrientation::Natives : public mozilla::jni::NativeImpl<GeckoScreenOrientation, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod GeckoScreenOrientation::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoScreenOrientation::OnOrientationChange_t>( - mozilla::jni::NativeStub<GeckoScreenOrientation::OnOrientationChange_t, Impl> - ::template Wrap<&Impl::OnOrientationChange>) -}; - -template<class Impl> -class GeckoThread::Natives : public mozilla::jni::NativeImpl<GeckoThread, Impl> -{ -public: - static const JNINativeMethod methods[6]; -}; - -template<class Impl> -const JNINativeMethod GeckoThread::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoThread::CreateServices_t>( - mozilla::jni::NativeStub<GeckoThread::CreateServices_t, Impl> - ::template Wrap<&Impl::CreateServices>), - - mozilla::jni::MakeNativeMethod<GeckoThread::OnPause_t>( - mozilla::jni::NativeStub<GeckoThread::OnPause_t, Impl> - ::template Wrap<&Impl::OnPause>), - - mozilla::jni::MakeNativeMethod<GeckoThread::OnResume_t>( - mozilla::jni::NativeStub<GeckoThread::OnResume_t, Impl> - ::template Wrap<&Impl::OnResume>), - - mozilla::jni::MakeNativeMethod<GeckoThread::RunUiThreadCallback_t>( - mozilla::jni::NativeStub<GeckoThread::RunUiThreadCallback_t, Impl> - ::template Wrap<&Impl::RunUiThreadCallback>), - - mozilla::jni::MakeNativeMethod<GeckoThread::SpeculativeConnect_t>( - mozilla::jni::NativeStub<GeckoThread::SpeculativeConnect_t, Impl> - ::template Wrap<&Impl::SpeculativeConnect>), - - mozilla::jni::MakeNativeMethod<GeckoThread::WaitOnGecko_t>( - mozilla::jni::NativeStub<GeckoThread::WaitOnGecko_t, Impl> - ::template Wrap<&Impl::WaitOnGecko>) -}; - -template<class Impl> -class GeckoView::Window::Natives : public mozilla::jni::NativeImpl<Window, Impl> -{ -public: - static const JNINativeMethod methods[5]; -}; - -template<class Impl> -const JNINativeMethod GeckoView::Window::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoView::Window::Close_t>( - mozilla::jni::NativeStub<GeckoView::Window::Close_t, Impl> - ::template Wrap<&Impl::Close>), - - mozilla::jni::MakeNativeMethod<GeckoView::Window::DisposeNative_t>( - mozilla::jni::NativeStub<GeckoView::Window::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>), - - mozilla::jni::MakeNativeMethod<GeckoView::Window::LoadUri_t>( - mozilla::jni::NativeStub<GeckoView::Window::LoadUri_t, Impl> - ::template Wrap<&Impl::LoadUri>), - - mozilla::jni::MakeNativeMethod<GeckoView::Window::Open_t>( - mozilla::jni::NativeStub<GeckoView::Window::Open_t, Impl> - ::template Wrap<&Impl::Open>), - - mozilla::jni::MakeNativeMethod<GeckoView::Window::Reattach_t>( - mozilla::jni::NativeStub<GeckoView::Window::Reattach_t, Impl> - ::template Wrap<&Impl::Reattach>) -}; - -template<class Impl> -class PrefsHelper::Natives : public mozilla::jni::NativeImpl<PrefsHelper, Impl> -{ -public: - static const JNINativeMethod methods[4]; -}; - -template<class Impl> -const JNINativeMethod PrefsHelper::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<PrefsHelper::AddObserver_t>( - mozilla::jni::NativeStub<PrefsHelper::AddObserver_t, Impl> - ::template Wrap<&Impl::AddObserver>), - - mozilla::jni::MakeNativeMethod<PrefsHelper::GetPrefs_t>( - mozilla::jni::NativeStub<PrefsHelper::GetPrefs_t, Impl> - ::template Wrap<&Impl::GetPrefs>), - - mozilla::jni::MakeNativeMethod<PrefsHelper::RemoveObserver_t>( - mozilla::jni::NativeStub<PrefsHelper::RemoveObserver_t, Impl> - ::template Wrap<&Impl::RemoveObserver>), - - mozilla::jni::MakeNativeMethod<PrefsHelper::SetPref_t>( - mozilla::jni::NativeStub<PrefsHelper::SetPref_t, Impl> - ::template Wrap<&Impl::SetPref>) -}; - -template<class Impl> -class SurfaceTextureListener::Natives : public mozilla::jni::NativeImpl<SurfaceTextureListener, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod SurfaceTextureListener::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<SurfaceTextureListener::OnFrameAvailable_t>( - mozilla::jni::NativeStub<SurfaceTextureListener::OnFrameAvailable_t, Impl> - ::template Wrap<&Impl::OnFrameAvailable>) -}; - -template<class Impl> -class LayerView::Compositor::Natives : public mozilla::jni::NativeImpl<Compositor, Impl> -{ -public: - static const JNINativeMethod methods[7]; -}; - -template<class Impl> -const JNINativeMethod LayerView::Compositor::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::AttachToJava_t>( - mozilla::jni::NativeStub<LayerView::Compositor::AttachToJava_t, Impl> - ::template Wrap<&Impl::AttachToJava>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::CreateCompositor_t>( - mozilla::jni::NativeStub<LayerView::Compositor::CreateCompositor_t, Impl> - ::template Wrap<&Impl::CreateCompositor>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::DisposeNative_t>( - mozilla::jni::NativeStub<LayerView::Compositor::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::OnSizeChanged_t>( - mozilla::jni::NativeStub<LayerView::Compositor::OnSizeChanged_t, Impl> - ::template Wrap<&Impl::OnSizeChanged>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncInvalidateAndScheduleComposite_t>( - mozilla::jni::NativeStub<LayerView::Compositor::SyncInvalidateAndScheduleComposite_t, Impl> - ::template Wrap<&Impl::SyncInvalidateAndScheduleComposite>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncPauseCompositor_t>( - mozilla::jni::NativeStub<LayerView::Compositor::SyncPauseCompositor_t, Impl> - ::template Wrap<&Impl::SyncPauseCompositor>), - - mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncResumeResizeCompositor_t>( - mozilla::jni::NativeStub<LayerView::Compositor::SyncResumeResizeCompositor_t, Impl> - ::template Wrap<&Impl::SyncResumeResizeCompositor>) -}; - -template<class Impl> -class NativePanZoomController::Natives : public mozilla::jni::NativeImpl<NativePanZoomController, Impl> -{ -public: - static const JNINativeMethod methods[7]; -}; - -template<class Impl> -const JNINativeMethod NativePanZoomController::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<NativePanZoomController::AdjustScrollForSurfaceShift_t>( - mozilla::jni::NativeStub<NativePanZoomController::AdjustScrollForSurfaceShift_t, Impl> - ::template Wrap<&Impl::AdjustScrollForSurfaceShift>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::DisposeNative_t>( - mozilla::jni::NativeStub<NativePanZoomController::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMotionEvent_t>( - mozilla::jni::NativeStub<NativePanZoomController::HandleMotionEvent_t, Impl> - ::template Wrap<&Impl::HandleMotionEvent>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMotionEventVelocity_t>( - mozilla::jni::NativeStub<NativePanZoomController::HandleMotionEventVelocity_t, Impl> - ::template Wrap<&Impl::HandleMotionEventVelocity>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMouseEvent_t>( - mozilla::jni::NativeStub<NativePanZoomController::HandleMouseEvent_t, Impl> - ::template Wrap<&Impl::HandleMouseEvent>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleScrollEvent_t>( - mozilla::jni::NativeStub<NativePanZoomController::HandleScrollEvent_t, Impl> - ::template Wrap<&Impl::HandleScrollEvent>), - - mozilla::jni::MakeNativeMethod<NativePanZoomController::SetIsLongpressEnabled_t>( - mozilla::jni::NativeStub<NativePanZoomController::SetIsLongpressEnabled_t, Impl> - ::template Wrap<&Impl::SetIsLongpressEnabled>) -}; - -template<class Impl> -class NativeJSContainer::Natives : public mozilla::jni::NativeImpl<NativeJSContainer, Impl> -{ -public: - static const JNINativeMethod methods[2]; -}; - -template<class Impl> -const JNINativeMethod NativeJSContainer::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<NativeJSContainer::Clone2_t>( - mozilla::jni::NativeStub<NativeJSContainer::Clone2_t, Impl> - ::template Wrap<&Impl::Clone>), - - mozilla::jni::MakeNativeMethod<NativeJSContainer::DisposeNative_t>( - mozilla::jni::NativeStub<NativeJSContainer::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>) -}; - -template<class Impl> -class NativeJSObject::Natives : public mozilla::jni::NativeImpl<NativeJSObject, Impl> -{ -public: - static const JNINativeMethod methods[27]; -}; - -template<class Impl> -const JNINativeMethod NativeJSObject::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetBoolean_t>( - mozilla::jni::NativeStub<NativeJSObject::GetBoolean_t, Impl> - ::template Wrap<&Impl::GetBoolean>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetBooleanArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetBooleanArray_t, Impl> - ::template Wrap<&Impl::GetBooleanArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetBundle_t>( - mozilla::jni::NativeStub<NativeJSObject::GetBundle_t, Impl> - ::template Wrap<&Impl::GetBundle>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetBundleArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetBundleArray_t, Impl> - ::template Wrap<&Impl::GetBundleArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetDouble_t>( - mozilla::jni::NativeStub<NativeJSObject::GetDouble_t, Impl> - ::template Wrap<&Impl::GetDouble>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetDoubleArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetDoubleArray_t, Impl> - ::template Wrap<&Impl::GetDoubleArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetInt_t>( - mozilla::jni::NativeStub<NativeJSObject::GetInt_t, Impl> - ::template Wrap<&Impl::GetInt>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetIntArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetIntArray_t, Impl> - ::template Wrap<&Impl::GetIntArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetObject_t>( - mozilla::jni::NativeStub<NativeJSObject::GetObject_t, Impl> - ::template Wrap<&Impl::GetObject>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetObjectArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetObjectArray_t, Impl> - ::template Wrap<&Impl::GetObjectArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetString_t>( - mozilla::jni::NativeStub<NativeJSObject::GetString_t, Impl> - ::template Wrap<&Impl::GetString>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::GetStringArray_t>( - mozilla::jni::NativeStub<NativeJSObject::GetStringArray_t, Impl> - ::template Wrap<&Impl::GetStringArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::Has_t>( - mozilla::jni::NativeStub<NativeJSObject::Has_t, Impl> - ::template Wrap<&Impl::Has>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptBoolean_t>( - mozilla::jni::NativeStub<NativeJSObject::OptBoolean_t, Impl> - ::template Wrap<&Impl::OptBoolean>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptBooleanArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptBooleanArray_t, Impl> - ::template Wrap<&Impl::OptBooleanArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptBundle_t>( - mozilla::jni::NativeStub<NativeJSObject::OptBundle_t, Impl> - ::template Wrap<&Impl::OptBundle>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptBundleArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptBundleArray_t, Impl> - ::template Wrap<&Impl::OptBundleArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptDouble_t>( - mozilla::jni::NativeStub<NativeJSObject::OptDouble_t, Impl> - ::template Wrap<&Impl::OptDouble>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptDoubleArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptDoubleArray_t, Impl> - ::template Wrap<&Impl::OptDoubleArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptInt_t>( - mozilla::jni::NativeStub<NativeJSObject::OptInt_t, Impl> - ::template Wrap<&Impl::OptInt>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptIntArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptIntArray_t, Impl> - ::template Wrap<&Impl::OptIntArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptObject_t>( - mozilla::jni::NativeStub<NativeJSObject::OptObject_t, Impl> - ::template Wrap<&Impl::OptObject>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptObjectArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptObjectArray_t, Impl> - ::template Wrap<&Impl::OptObjectArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptString_t>( - mozilla::jni::NativeStub<NativeJSObject::OptString_t, Impl> - ::template Wrap<&Impl::OptString>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::OptStringArray_t>( - mozilla::jni::NativeStub<NativeJSObject::OptStringArray_t, Impl> - ::template Wrap<&Impl::OptStringArray>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::ToBundle_t>( - mozilla::jni::NativeStub<NativeJSObject::ToBundle_t, Impl> - ::template Wrap<&Impl::ToBundle>), - - mozilla::jni::MakeNativeMethod<NativeJSObject::ToString_t>( - mozilla::jni::NativeStub<NativeJSObject::ToString_t, Impl> - ::template Wrap<&Impl::ToString>) -}; - -} /* java */ -} /* mozilla */ -#endif // GeneratedJNINatives_h diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp deleted file mode 100644 index 37564ba24..000000000 --- a/widget/android/GeneratedJNIWrappers.cpp +++ /dev/null @@ -1,1874 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#include "GeneratedJNIWrappers.h" -#include "mozilla/jni/Accessors.h" - -namespace mozilla { -namespace java { - -const char AlarmReceiver::name[] = - "org/mozilla/gecko/AlarmReceiver"; - -constexpr char AlarmReceiver::NotifyAlarmFired_t::name[]; -constexpr char AlarmReceiver::NotifyAlarmFired_t::signature[]; - -const char AndroidGamepadManager::name[] = - "org/mozilla/gecko/AndroidGamepadManager"; - -constexpr char AndroidGamepadManager::OnAxisChange_t::name[]; -constexpr char AndroidGamepadManager::OnAxisChange_t::signature[]; - -constexpr char AndroidGamepadManager::OnButtonChange_t::name[]; -constexpr char AndroidGamepadManager::OnButtonChange_t::signature[]; - -constexpr char AndroidGamepadManager::OnGamepadAdded_t::name[]; -constexpr char AndroidGamepadManager::OnGamepadAdded_t::signature[]; - -auto AndroidGamepadManager::OnGamepadAdded(int32_t a0, int32_t a1) -> void -{ - return mozilla::jni::Method<OnGamepadAdded_t>::Call(AndroidGamepadManager::Context(), nullptr, a0, a1); -} - -constexpr char AndroidGamepadManager::OnGamepadChange_t::name[]; -constexpr char AndroidGamepadManager::OnGamepadChange_t::signature[]; - -constexpr char AndroidGamepadManager::Start_t::name[]; -constexpr char AndroidGamepadManager::Start_t::signature[]; - -auto AndroidGamepadManager::Start() -> void -{ - return mozilla::jni::Method<Start_t>::Call(AndroidGamepadManager::Context(), nullptr); -} - -constexpr char AndroidGamepadManager::Stop_t::name[]; -constexpr char AndroidGamepadManager::Stop_t::signature[]; - -auto AndroidGamepadManager::Stop() -> void -{ - return mozilla::jni::Method<Stop_t>::Call(AndroidGamepadManager::Context(), nullptr); -} - -const char GeckoAppShell::name[] = - "org/mozilla/gecko/GeckoAppShell"; - -constexpr char GeckoAppShell::AddFullScreenPluginView_t::name[]; -constexpr char GeckoAppShell::AddFullScreenPluginView_t::signature[]; - -auto GeckoAppShell::AddFullScreenPluginView(mozilla::jni::Object::Param a0) -> void -{ - return mozilla::jni::Method<AddFullScreenPluginView_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::CancelVibrate_t::name[]; -constexpr char GeckoAppShell::CancelVibrate_t::signature[]; - -auto GeckoAppShell::CancelVibrate() -> void -{ - return mozilla::jni::Method<CancelVibrate_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::CheckURIVisited_t::name[]; -constexpr char GeckoAppShell::CheckURIVisited_t::signature[]; - -auto GeckoAppShell::CheckURIVisited(mozilla::jni::String::Param a0) -> void -{ - return mozilla::jni::Method<CheckURIVisited_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::CloseCamera_t::name[]; -constexpr char GeckoAppShell::CloseCamera_t::signature[]; - -auto GeckoAppShell::CloseCamera() -> void -{ - return mozilla::jni::Method<CloseCamera_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::CloseNotification_t::name[]; -constexpr char GeckoAppShell::CloseNotification_t::signature[]; - -auto GeckoAppShell::CloseNotification(mozilla::jni::String::Param a0) -> void -{ - return mozilla::jni::Method<CloseNotification_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::ConnectionGetMimeType_t::name[]; -constexpr char GeckoAppShell::ConnectionGetMimeType_t::signature[]; - -auto GeckoAppShell::ConnectionGetMimeType(mozilla::jni::Object::Param a0) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<ConnectionGetMimeType_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::CreateInputStream_t::name[]; -constexpr char GeckoAppShell::CreateInputStream_t::signature[]; - -auto GeckoAppShell::CreateInputStream(mozilla::jni::Object::Param a0) -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<CreateInputStream_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::CreateShortcut_t::name[]; -constexpr char GeckoAppShell::CreateShortcut_t::signature[]; - -auto GeckoAppShell::CreateShortcut(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> void -{ - return mozilla::jni::Method<CreateShortcut_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::DisableAlarm_t::name[]; -constexpr char GeckoAppShell::DisableAlarm_t::signature[]; - -auto GeckoAppShell::DisableAlarm() -> void -{ - return mozilla::jni::Method<DisableAlarm_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::DisableBatteryNotifications_t::name[]; -constexpr char GeckoAppShell::DisableBatteryNotifications_t::signature[]; - -auto GeckoAppShell::DisableBatteryNotifications() -> void -{ - return mozilla::jni::Method<DisableBatteryNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::DisableNetworkNotifications_t::name[]; -constexpr char GeckoAppShell::DisableNetworkNotifications_t::signature[]; - -auto GeckoAppShell::DisableNetworkNotifications() -> void -{ - return mozilla::jni::Method<DisableNetworkNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::DisableScreenOrientationNotifications_t::name[]; -constexpr char GeckoAppShell::DisableScreenOrientationNotifications_t::signature[]; - -auto GeckoAppShell::DisableScreenOrientationNotifications() -> void -{ - return mozilla::jni::Method<DisableScreenOrientationNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::DisableSensor_t::name[]; -constexpr char GeckoAppShell::DisableSensor_t::signature[]; - -auto GeckoAppShell::DisableSensor(int32_t a0) -> void -{ - return mozilla::jni::Method<DisableSensor_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::EnableBatteryNotifications_t::name[]; -constexpr char GeckoAppShell::EnableBatteryNotifications_t::signature[]; - -auto GeckoAppShell::EnableBatteryNotifications() -> void -{ - return mozilla::jni::Method<EnableBatteryNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::EnableLocation_t::name[]; -constexpr char GeckoAppShell::EnableLocation_t::signature[]; - -auto GeckoAppShell::EnableLocation(bool a0) -> void -{ - return mozilla::jni::Method<EnableLocation_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::EnableLocationHighAccuracy_t::name[]; -constexpr char GeckoAppShell::EnableLocationHighAccuracy_t::signature[]; - -auto GeckoAppShell::EnableLocationHighAccuracy(bool a0) -> void -{ - return mozilla::jni::Method<EnableLocationHighAccuracy_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::EnableNetworkNotifications_t::name[]; -constexpr char GeckoAppShell::EnableNetworkNotifications_t::signature[]; - -auto GeckoAppShell::EnableNetworkNotifications() -> void -{ - return mozilla::jni::Method<EnableNetworkNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::EnableScreenOrientationNotifications_t::name[]; -constexpr char GeckoAppShell::EnableScreenOrientationNotifications_t::signature[]; - -auto GeckoAppShell::EnableScreenOrientationNotifications() -> void -{ - return mozilla::jni::Method<EnableScreenOrientationNotifications_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::EnableSensor_t::name[]; -constexpr char GeckoAppShell::EnableSensor_t::signature[]; - -auto GeckoAppShell::EnableSensor(int32_t a0) -> void -{ - return mozilla::jni::Method<EnableSensor_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::GetApplicationContext_t::name[]; -constexpr char GeckoAppShell::GetApplicationContext_t::signature[]; - -auto GeckoAppShell::GetApplicationContext() -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<GetApplicationContext_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetConnection_t::name[]; -constexpr char GeckoAppShell::GetConnection_t::signature[]; - -auto GeckoAppShell::GetConnection(mozilla::jni::String::Param a0) -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<GetConnection_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::GetContext_t::name[]; -constexpr char GeckoAppShell::GetContext_t::signature[]; - -auto GeckoAppShell::GetContext() -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<GetContext_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetCurrentBatteryInformation_t::name[]; -constexpr char GeckoAppShell::GetCurrentBatteryInformation_t::signature[]; - -auto GeckoAppShell::GetCurrentBatteryInformation() -> mozilla::jni::DoubleArray::LocalRef -{ - return mozilla::jni::Method<GetCurrentBatteryInformation_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetCurrentNetworkInformation_t::name[]; -constexpr char GeckoAppShell::GetCurrentNetworkInformation_t::signature[]; - -auto GeckoAppShell::GetCurrentNetworkInformation() -> mozilla::jni::DoubleArray::LocalRef -{ - return mozilla::jni::Method<GetCurrentNetworkInformation_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetDensity_t::name[]; -constexpr char GeckoAppShell::GetDensity_t::signature[]; - -auto GeckoAppShell::GetDensity() -> float -{ - return mozilla::jni::Method<GetDensity_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetDpi_t::name[]; -constexpr char GeckoAppShell::GetDpi_t::signature[]; - -auto GeckoAppShell::GetDpi() -> int32_t -{ - return mozilla::jni::Method<GetDpi_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetExceptionStackTrace_t::name[]; -constexpr char GeckoAppShell::GetExceptionStackTrace_t::signature[]; - -auto GeckoAppShell::GetExceptionStackTrace(mozilla::jni::Throwable::Param a0) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetExceptionStackTrace_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::GetExtensionFromMimeType_t::name[]; -constexpr char GeckoAppShell::GetExtensionFromMimeType_t::signature[]; - -auto GeckoAppShell::GetExtensionFromMimeType(mozilla::jni::String::Param a0) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetExtensionFromMimeType_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::GetHWDecoderCapability_t::name[]; -constexpr char GeckoAppShell::GetHWDecoderCapability_t::signature[]; - -auto GeckoAppShell::GetHWDecoderCapability() -> bool -{ - return mozilla::jni::Method<GetHWDecoderCapability_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetHWEncoderCapability_t::name[]; -constexpr char GeckoAppShell::GetHWEncoderCapability_t::signature[]; - -auto GeckoAppShell::GetHWEncoderCapability() -> bool -{ - return mozilla::jni::Method<GetHWEncoderCapability_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetHandlersForMimeType_t::name[]; -constexpr char GeckoAppShell::GetHandlersForMimeType_t::signature[]; - -auto GeckoAppShell::GetHandlersForMimeType(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> mozilla::jni::ObjectArray::LocalRef -{ - return mozilla::jni::Method<GetHandlersForMimeType_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::GetHandlersForURL_t::name[]; -constexpr char GeckoAppShell::GetHandlersForURL_t::signature[]; - -auto GeckoAppShell::GetHandlersForURL(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> mozilla::jni::ObjectArray::LocalRef -{ - return mozilla::jni::Method<GetHandlersForURL_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::GetIconForExtension_t::name[]; -constexpr char GeckoAppShell::GetIconForExtension_t::signature[]; - -auto GeckoAppShell::GetIconForExtension(mozilla::jni::String::Param a0, int32_t a1) -> mozilla::jni::ByteArray::LocalRef -{ - return mozilla::jni::Method<GetIconForExtension_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::GetMaxTouchPoints_t::name[]; -constexpr char GeckoAppShell::GetMaxTouchPoints_t::signature[]; - -auto GeckoAppShell::GetMaxTouchPoints() -> int32_t -{ - return mozilla::jni::Method<GetMaxTouchPoints_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetMimeTypeFromExtensions_t::name[]; -constexpr char GeckoAppShell::GetMimeTypeFromExtensions_t::signature[]; - -auto GeckoAppShell::GetMimeTypeFromExtensions(mozilla::jni::String::Param a0) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetMimeTypeFromExtensions_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::GetNetworkLinkType_t::name[]; -constexpr char GeckoAppShell::GetNetworkLinkType_t::signature[]; - -auto GeckoAppShell::GetNetworkLinkType() -> int32_t -{ - return mozilla::jni::Method<GetNetworkLinkType_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetProxyForURI_t::name[]; -constexpr char GeckoAppShell::GetProxyForURI_t::signature[]; - -auto GeckoAppShell::GetProxyForURI(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, int32_t a3) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetProxyForURI_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3); -} - -constexpr char GeckoAppShell::GetScreenAngle_t::name[]; -constexpr char GeckoAppShell::GetScreenAngle_t::signature[]; - -auto GeckoAppShell::GetScreenAngle() -> int32_t -{ - return mozilla::jni::Method<GetScreenAngle_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetScreenDepth_t::name[]; -constexpr char GeckoAppShell::GetScreenDepth_t::signature[]; - -auto GeckoAppShell::GetScreenDepth() -> int32_t -{ - return mozilla::jni::Method<GetScreenDepth_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetScreenOrientation_t::name[]; -constexpr char GeckoAppShell::GetScreenOrientation_t::signature[]; - -auto GeckoAppShell::GetScreenOrientation() -> int16_t -{ - return mozilla::jni::Method<GetScreenOrientation_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetScreenSize_t::name[]; -constexpr char GeckoAppShell::GetScreenSize_t::signature[]; - -auto GeckoAppShell::GetScreenSize() -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<GetScreenSize_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetShowPasswordSetting_t::name[]; -constexpr char GeckoAppShell::GetShowPasswordSetting_t::signature[]; - -auto GeckoAppShell::GetShowPasswordSetting() -> bool -{ - return mozilla::jni::Method<GetShowPasswordSetting_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::GetSystemColors_t::name[]; -constexpr char GeckoAppShell::GetSystemColors_t::signature[]; - -auto GeckoAppShell::GetSystemColors() -> mozilla::jni::IntArray::LocalRef -{ - return mozilla::jni::Method<GetSystemColors_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::HandleGeckoMessage_t::name[]; -constexpr char GeckoAppShell::HandleGeckoMessage_t::signature[]; - -auto GeckoAppShell::HandleGeckoMessage(mozilla::jni::Object::Param a0) -> void -{ - return mozilla::jni::Method<HandleGeckoMessage_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::HandleUncaughtException_t::name[]; -constexpr char GeckoAppShell::HandleUncaughtException_t::signature[]; - -auto GeckoAppShell::HandleUncaughtException(mozilla::jni::Throwable::Param a0) -> void -{ - return mozilla::jni::Method<HandleUncaughtException_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::HideProgressDialog_t::name[]; -constexpr char GeckoAppShell::HideProgressDialog_t::signature[]; - -auto GeckoAppShell::HideProgressDialog() -> void -{ - return mozilla::jni::Method<HideProgressDialog_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::InitCamera_t::name[]; -constexpr char GeckoAppShell::InitCamera_t::signature[]; - -auto GeckoAppShell::InitCamera(mozilla::jni::String::Param a0, int32_t a1, int32_t a2, int32_t a3) -> mozilla::jni::IntArray::LocalRef -{ - return mozilla::jni::Method<InitCamera_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3); -} - -constexpr char GeckoAppShell::IsNetworkLinkKnown_t::name[]; -constexpr char GeckoAppShell::IsNetworkLinkKnown_t::signature[]; - -auto GeckoAppShell::IsNetworkLinkKnown() -> bool -{ - return mozilla::jni::Method<IsNetworkLinkKnown_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::IsNetworkLinkUp_t::name[]; -constexpr char GeckoAppShell::IsNetworkLinkUp_t::signature[]; - -auto GeckoAppShell::IsNetworkLinkUp() -> bool -{ - return mozilla::jni::Method<IsNetworkLinkUp_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::IsTablet_t::name[]; -constexpr char GeckoAppShell::IsTablet_t::signature[]; - -auto GeckoAppShell::IsTablet() -> bool -{ - return mozilla::jni::Method<IsTablet_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::KillAnyZombies_t::name[]; -constexpr char GeckoAppShell::KillAnyZombies_t::signature[]; - -auto GeckoAppShell::KillAnyZombies() -> void -{ - return mozilla::jni::Method<KillAnyZombies_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::LoadPluginClass_t::name[]; -constexpr char GeckoAppShell::LoadPluginClass_t::signature[]; - -auto GeckoAppShell::LoadPluginClass(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> mozilla::jni::Class::LocalRef -{ - return mozilla::jni::Method<LoadPluginClass_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::LockScreenOrientation_t::name[]; -constexpr char GeckoAppShell::LockScreenOrientation_t::signature[]; - -auto GeckoAppShell::LockScreenOrientation(int32_t a0) -> void -{ - return mozilla::jni::Method<LockScreenOrientation_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::MarkURIVisited_t::name[]; -constexpr char GeckoAppShell::MarkURIVisited_t::signature[]; - -auto GeckoAppShell::MarkURIVisited(mozilla::jni::String::Param a0) -> void -{ - return mozilla::jni::Method<MarkURIVisited_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::MoveTaskToBack_t::name[]; -constexpr char GeckoAppShell::MoveTaskToBack_t::signature[]; - -auto GeckoAppShell::MoveTaskToBack() -> void -{ - return mozilla::jni::Method<MoveTaskToBack_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::NotifyObservers_t::name[]; -constexpr char GeckoAppShell::NotifyObservers_t::signature[]; - -constexpr char GeckoAppShell::NotifyAlertListener_t::name[]; -constexpr char GeckoAppShell::NotifyAlertListener_t::signature[]; - -constexpr char GeckoAppShell::NotifyUriVisited_t::name[]; -constexpr char GeckoAppShell::NotifyUriVisited_t::signature[]; - -constexpr char GeckoAppShell::NotifyWakeLockChanged_t::name[]; -constexpr char GeckoAppShell::NotifyWakeLockChanged_t::signature[]; - -auto GeckoAppShell::NotifyWakeLockChanged(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> void -{ - return mozilla::jni::Method<NotifyWakeLockChanged_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::name[]; -constexpr char GeckoAppShell::OnFullScreenPluginHidden_t::signature[]; - -constexpr char GeckoAppShell::OnLocationChanged_t::name[]; -constexpr char GeckoAppShell::OnLocationChanged_t::signature[]; - -constexpr char GeckoAppShell::OnSensorChanged_t::name[]; -constexpr char GeckoAppShell::OnSensorChanged_t::signature[]; - -constexpr char GeckoAppShell::OpenUriExternal_t::name[]; -constexpr char GeckoAppShell::OpenUriExternal_t::signature[]; - -auto GeckoAppShell::OpenUriExternal(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, mozilla::jni::String::Param a3, mozilla::jni::String::Param a4, mozilla::jni::String::Param a5) -> bool -{ - return mozilla::jni::Method<OpenUriExternal_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3, a4, a5); -} - -constexpr char GeckoAppShell::OpenWindowForNotification_t::name[]; -constexpr char GeckoAppShell::OpenWindowForNotification_t::signature[]; - -auto GeckoAppShell::OpenWindowForNotification() -> void -{ - return mozilla::jni::Method<OpenWindowForNotification_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::PerformHapticFeedback_t::name[]; -constexpr char GeckoAppShell::PerformHapticFeedback_t::signature[]; - -auto GeckoAppShell::PerformHapticFeedback(bool a0) -> void -{ - return mozilla::jni::Method<PerformHapticFeedback_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::RemoveFullScreenPluginView_t::name[]; -constexpr char GeckoAppShell::RemoveFullScreenPluginView_t::signature[]; - -auto GeckoAppShell::RemoveFullScreenPluginView(mozilla::jni::Object::Param a0) -> void -{ - return mozilla::jni::Method<RemoveFullScreenPluginView_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::ReportJavaCrash_t::name[]; -constexpr char GeckoAppShell::ReportJavaCrash_t::signature[]; - -constexpr char GeckoAppShell::ScheduleRestart_t::name[]; -constexpr char GeckoAppShell::ScheduleRestart_t::signature[]; - -auto GeckoAppShell::ScheduleRestart() -> void -{ - return mozilla::jni::Method<ScheduleRestart_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::SetAlarm_t::name[]; -constexpr char GeckoAppShell::SetAlarm_t::signature[]; - -auto GeckoAppShell::SetAlarm(int32_t a0, int32_t a1) -> bool -{ - return mozilla::jni::Method<SetAlarm_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::SetFullScreen_t::name[]; -constexpr char GeckoAppShell::SetFullScreen_t::signature[]; - -auto GeckoAppShell::SetFullScreen(bool a0) -> void -{ - return mozilla::jni::Method<SetFullScreen_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::SetKeepScreenOn_t::name[]; -constexpr char GeckoAppShell::SetKeepScreenOn_t::signature[]; - -auto GeckoAppShell::SetKeepScreenOn(bool a0) -> void -{ - return mozilla::jni::Method<SetKeepScreenOn_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::SetScreenDepthOverride_t::name[]; -constexpr char GeckoAppShell::SetScreenDepthOverride_t::signature[]; - -auto GeckoAppShell::SetScreenDepthOverride(int32_t a0) -> void -{ - return mozilla::jni::Method<SetScreenDepthOverride_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::SetURITitle_t::name[]; -constexpr char GeckoAppShell::SetURITitle_t::signature[]; - -auto GeckoAppShell::SetURITitle(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> void -{ - return mozilla::jni::Method<SetURITitle_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -constexpr char GeckoAppShell::ShowNotification_t::name[]; -constexpr char GeckoAppShell::ShowNotification_t::signature[]; - -auto GeckoAppShell::ShowNotification(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, mozilla::jni::String::Param a3, mozilla::jni::String::Param a4, mozilla::jni::String::Param a5, mozilla::jni::String::Param a6) -> void -{ - return mozilla::jni::Method<ShowNotification_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3, a4, a5, a6); -} - -constexpr char GeckoAppShell::SyncNotifyObservers_t::name[]; -constexpr char GeckoAppShell::SyncNotifyObservers_t::signature[]; - -constexpr char GeckoAppShell::UnlockProfile_t::name[]; -constexpr char GeckoAppShell::UnlockProfile_t::signature[]; - -auto GeckoAppShell::UnlockProfile() -> bool -{ - return mozilla::jni::Method<UnlockProfile_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::UnlockScreenOrientation_t::name[]; -constexpr char GeckoAppShell::UnlockScreenOrientation_t::signature[]; - -auto GeckoAppShell::UnlockScreenOrientation() -> void -{ - return mozilla::jni::Method<UnlockScreenOrientation_t>::Call(GeckoAppShell::Context(), nullptr); -} - -constexpr char GeckoAppShell::Vibrate_t::name[]; -constexpr char GeckoAppShell::Vibrate_t::signature[]; - -auto GeckoAppShell::Vibrate(int64_t a0) -> void -{ - return mozilla::jni::Method<Vibrate_t>::Call(GeckoAppShell::Context(), nullptr, a0); -} - -constexpr char GeckoAppShell::Vibrate2_t::name[]; -constexpr char GeckoAppShell::Vibrate2_t::signature[]; - -auto GeckoAppShell::Vibrate(mozilla::jni::LongArray::Param a0, int32_t a1) -> void -{ - return mozilla::jni::Method<Vibrate2_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1); -} - -const char GeckoAppShell::CameraCallback::name[] = - "org/mozilla/gecko/GeckoAppShell$CameraCallback"; - -constexpr char GeckoAppShell::CameraCallback::OnFrameData_t::name[]; -constexpr char GeckoAppShell::CameraCallback::OnFrameData_t::signature[]; - -const char GeckoBatteryManager::name[] = - "org/mozilla/gecko/GeckoBatteryManager"; - -constexpr char GeckoBatteryManager::OnBatteryChange_t::name[]; -constexpr char GeckoBatteryManager::OnBatteryChange_t::signature[]; - -const char GeckoEditable::name[] = - "org/mozilla/gecko/GeckoEditable"; - -constexpr char GeckoEditable::New_t::name[]; -constexpr char GeckoEditable::New_t::signature[]; - -auto GeckoEditable::New(mozilla::jni::Object::Param a0) -> GeckoEditable::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(GeckoEditable::Context(), nullptr, a0); -} - -constexpr char GeckoEditable::DisposeNative_t::name[]; -constexpr char GeckoEditable::DisposeNative_t::signature[]; - -constexpr char GeckoEditable::NotifyIME_t::name[]; -constexpr char GeckoEditable::NotifyIME_t::signature[]; - -auto GeckoEditable::NotifyIME(int32_t a0) const -> void -{ - return mozilla::jni::Method<NotifyIME_t>::Call(GeckoEditable::mCtx, nullptr, a0); -} - -constexpr char GeckoEditable::NotifyIMEContext_t::name[]; -constexpr char GeckoEditable::NotifyIMEContext_t::signature[]; - -auto GeckoEditable::NotifyIMEContext(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, mozilla::jni::String::Param a3) const -> void -{ - return mozilla::jni::Method<NotifyIMEContext_t>::Call(GeckoEditable::mCtx, nullptr, a0, a1, a2, a3); -} - -constexpr char GeckoEditable::OnDefaultKeyEvent_t::name[]; -constexpr char GeckoEditable::OnDefaultKeyEvent_t::signature[]; - -auto GeckoEditable::OnDefaultKeyEvent(mozilla::jni::Object::Param a0) const -> void -{ - return mozilla::jni::Method<OnDefaultKeyEvent_t>::Call(GeckoEditable::mCtx, nullptr, a0); -} - -constexpr char GeckoEditable::OnImeAddCompositionRange_t::name[]; -constexpr char GeckoEditable::OnImeAddCompositionRange_t::signature[]; - -constexpr char GeckoEditable::OnImeReplaceText_t::name[]; -constexpr char GeckoEditable::OnImeReplaceText_t::signature[]; - -constexpr char GeckoEditable::OnImeRequestCursorUpdates_t::name[]; -constexpr char GeckoEditable::OnImeRequestCursorUpdates_t::signature[]; - -constexpr char GeckoEditable::OnImeSynchronize_t::name[]; -constexpr char GeckoEditable::OnImeSynchronize_t::signature[]; - -constexpr char GeckoEditable::OnImeUpdateComposition_t::name[]; -constexpr char GeckoEditable::OnImeUpdateComposition_t::signature[]; - -constexpr char GeckoEditable::OnKeyEvent_t::name[]; -constexpr char GeckoEditable::OnKeyEvent_t::signature[]; - -constexpr char GeckoEditable::OnSelectionChange_t::name[]; -constexpr char GeckoEditable::OnSelectionChange_t::signature[]; - -auto GeckoEditable::OnSelectionChange(int32_t a0, int32_t a1) const -> void -{ - return mozilla::jni::Method<OnSelectionChange_t>::Call(GeckoEditable::mCtx, nullptr, a0, a1); -} - -constexpr char GeckoEditable::OnTextChange_t::name[]; -constexpr char GeckoEditable::OnTextChange_t::signature[]; - -auto GeckoEditable::OnTextChange(mozilla::jni::String::Param a0, int32_t a1, int32_t a2, int32_t a3) const -> void -{ - return mozilla::jni::Method<OnTextChange_t>::Call(GeckoEditable::mCtx, nullptr, a0, a1, a2, a3); -} - -constexpr char GeckoEditable::OnViewChange_t::name[]; -constexpr char GeckoEditable::OnViewChange_t::signature[]; - -auto GeckoEditable::OnViewChange(mozilla::jni::Object::Param a0) const -> void -{ - return mozilla::jni::Method<OnViewChange_t>::Call(GeckoEditable::mCtx, nullptr, a0); -} - -constexpr char GeckoEditable::UpdateCompositionRects_t::name[]; -constexpr char GeckoEditable::UpdateCompositionRects_t::signature[]; - -auto GeckoEditable::UpdateCompositionRects(mozilla::jni::ObjectArray::Param a0) const -> void -{ - return mozilla::jni::Method<UpdateCompositionRects_t>::Call(GeckoEditable::mCtx, nullptr, a0); -} - -const char GeckoEditableListener::name[] = - "org/mozilla/gecko/GeckoEditableListener"; - -const char GeckoNetworkManager::name[] = - "org/mozilla/gecko/GeckoNetworkManager"; - -constexpr char GeckoNetworkManager::OnConnectionChanged_t::name[]; -constexpr char GeckoNetworkManager::OnConnectionChanged_t::signature[]; - -constexpr char GeckoNetworkManager::OnStatusChanged_t::name[]; -constexpr char GeckoNetworkManager::OnStatusChanged_t::signature[]; - -const char GeckoScreenOrientation::name[] = - "org/mozilla/gecko/GeckoScreenOrientation"; - -constexpr char GeckoScreenOrientation::OnOrientationChange_t::name[]; -constexpr char GeckoScreenOrientation::OnOrientationChange_t::signature[]; - -const char GeckoThread::name[] = - "org/mozilla/gecko/GeckoThread"; - -constexpr char GeckoThread::CheckAndSetState_t::name[]; -constexpr char GeckoThread::CheckAndSetState_t::signature[]; - -auto GeckoThread::CheckAndSetState(mozilla::jni::Object::Param a0, mozilla::jni::Object::Param a1) -> bool -{ - return mozilla::jni::Method<CheckAndSetState_t>::Call(GeckoThread::Context(), nullptr, a0, a1); -} - -constexpr char GeckoThread::CreateServices_t::name[]; -constexpr char GeckoThread::CreateServices_t::signature[]; - -constexpr char GeckoThread::OnPause_t::name[]; -constexpr char GeckoThread::OnPause_t::signature[]; - -constexpr char GeckoThread::OnResume_t::name[]; -constexpr char GeckoThread::OnResume_t::signature[]; - -constexpr char GeckoThread::PumpMessageLoop_t::name[]; -constexpr char GeckoThread::PumpMessageLoop_t::signature[]; - -auto GeckoThread::PumpMessageLoop(mozilla::jni::Object::Param a0) -> bool -{ - return mozilla::jni::Method<PumpMessageLoop_t>::Call(GeckoThread::Context(), nullptr, a0); -} - -constexpr char GeckoThread::RequestUiThreadCallback_t::name[]; -constexpr char GeckoThread::RequestUiThreadCallback_t::signature[]; - -auto GeckoThread::RequestUiThreadCallback(int64_t a0) -> void -{ - return mozilla::jni::Method<RequestUiThreadCallback_t>::Call(GeckoThread::Context(), nullptr, a0); -} - -constexpr char GeckoThread::RunUiThreadCallback_t::name[]; -constexpr char GeckoThread::RunUiThreadCallback_t::signature[]; - -constexpr char GeckoThread::SetState_t::name[]; -constexpr char GeckoThread::SetState_t::signature[]; - -auto GeckoThread::SetState(mozilla::jni::Object::Param a0) -> void -{ - return mozilla::jni::Method<SetState_t>::Call(GeckoThread::Context(), nullptr, a0); -} - -constexpr char GeckoThread::SpeculativeConnect_t::name[]; -constexpr char GeckoThread::SpeculativeConnect_t::signature[]; - -constexpr char GeckoThread::WaitOnGecko_t::name[]; -constexpr char GeckoThread::WaitOnGecko_t::signature[]; - -constexpr char GeckoThread::ClsLoader_t::name[]; -constexpr char GeckoThread::ClsLoader_t::signature[]; - -auto GeckoThread::ClsLoader() -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Field<ClsLoader_t>::Get(GeckoThread::Context(), nullptr); -} - -constexpr char GeckoThread::MsgQueue_t::name[]; -constexpr char GeckoThread::MsgQueue_t::signature[]; - -auto GeckoThread::MsgQueue() -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Field<MsgQueue_t>::Get(GeckoThread::Context(), nullptr); -} - -auto GeckoThread::MsgQueue(mozilla::jni::Object::Param a0) -> void -{ - return mozilla::jni::Field<MsgQueue_t>::Set(GeckoThread::Context(), nullptr, a0); -} - -const char GeckoThread::State::name[] = - "org/mozilla/gecko/GeckoThread$State"; - -constexpr char GeckoThread::State::EXITED_t::name[]; -constexpr char GeckoThread::State::EXITED_t::signature[]; - -auto GeckoThread::State::EXITED() -> State::LocalRef -{ - return mozilla::jni::Field<EXITED_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::EXITING_t::name[]; -constexpr char GeckoThread::State::EXITING_t::signature[]; - -auto GeckoThread::State::EXITING() -> State::LocalRef -{ - return mozilla::jni::Field<EXITING_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::INITIAL_t::name[]; -constexpr char GeckoThread::State::INITIAL_t::signature[]; - -auto GeckoThread::State::INITIAL() -> State::LocalRef -{ - return mozilla::jni::Field<INITIAL_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::JNI_READY_t::name[]; -constexpr char GeckoThread::State::JNI_READY_t::signature[]; - -auto GeckoThread::State::JNI_READY() -> State::LocalRef -{ - return mozilla::jni::Field<JNI_READY_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::LAUNCHED_t::name[]; -constexpr char GeckoThread::State::LAUNCHED_t::signature[]; - -auto GeckoThread::State::LAUNCHED() -> State::LocalRef -{ - return mozilla::jni::Field<LAUNCHED_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::LIBS_READY_t::name[]; -constexpr char GeckoThread::State::LIBS_READY_t::signature[]; - -auto GeckoThread::State::LIBS_READY() -> State::LocalRef -{ - return mozilla::jni::Field<LIBS_READY_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::MOZGLUE_READY_t::name[]; -constexpr char GeckoThread::State::MOZGLUE_READY_t::signature[]; - -auto GeckoThread::State::MOZGLUE_READY() -> State::LocalRef -{ - return mozilla::jni::Field<MOZGLUE_READY_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::PROFILE_READY_t::name[]; -constexpr char GeckoThread::State::PROFILE_READY_t::signature[]; - -auto GeckoThread::State::PROFILE_READY() -> State::LocalRef -{ - return mozilla::jni::Field<PROFILE_READY_t>::Get(State::Context(), nullptr); -} - -constexpr char GeckoThread::State::RUNNING_t::name[]; -constexpr char GeckoThread::State::RUNNING_t::signature[]; - -auto GeckoThread::State::RUNNING() -> State::LocalRef -{ - return mozilla::jni::Field<RUNNING_t>::Get(State::Context(), nullptr); -} - -const char GeckoView::name[] = - "org/mozilla/gecko/GeckoView"; - -const char GeckoView::Window::name[] = - "org/mozilla/gecko/GeckoView$Window"; - -constexpr char GeckoView::Window::Close_t::name[]; -constexpr char GeckoView::Window::Close_t::signature[]; - -constexpr char GeckoView::Window::DisposeNative_t::name[]; -constexpr char GeckoView::Window::DisposeNative_t::signature[]; - -constexpr char GeckoView::Window::LoadUri_t::name[]; -constexpr char GeckoView::Window::LoadUri_t::signature[]; - -constexpr char GeckoView::Window::Open_t::name[]; -constexpr char GeckoView::Window::Open_t::signature[]; - -constexpr char GeckoView::Window::Reattach_t::name[]; -constexpr char GeckoView::Window::Reattach_t::signature[]; - -const char PrefsHelper::name[] = - "org/mozilla/gecko/PrefsHelper"; - -constexpr char PrefsHelper::CallPrefHandler_t::name[]; -constexpr char PrefsHelper::CallPrefHandler_t::signature[]; - -auto PrefsHelper::CallPrefHandler(mozilla::jni::Object::Param a0, int32_t a1, mozilla::jni::String::Param a2, bool a3, int32_t a4, mozilla::jni::String::Param a5) -> void -{ - return mozilla::jni::Method<CallPrefHandler_t>::Call(PrefsHelper::Context(), nullptr, a0, a1, a2, a3, a4, a5); -} - -constexpr char PrefsHelper::AddObserver_t::name[]; -constexpr char PrefsHelper::AddObserver_t::signature[]; - -constexpr char PrefsHelper::GetPrefs_t::name[]; -constexpr char PrefsHelper::GetPrefs_t::signature[]; - -constexpr char PrefsHelper::RemoveObserver_t::name[]; -constexpr char PrefsHelper::RemoveObserver_t::signature[]; - -constexpr char PrefsHelper::SetPref_t::name[]; -constexpr char PrefsHelper::SetPref_t::signature[]; - -constexpr char PrefsHelper::OnPrefChange_t::name[]; -constexpr char PrefsHelper::OnPrefChange_t::signature[]; - -auto PrefsHelper::OnPrefChange(mozilla::jni::String::Param a0, int32_t a1, bool a2, int32_t a3, mozilla::jni::String::Param a4) -> void -{ - return mozilla::jni::Method<OnPrefChange_t>::Call(PrefsHelper::Context(), nullptr, a0, a1, a2, a3, a4); -} - -const char SurfaceTextureListener::name[] = - "org/mozilla/gecko/SurfaceTextureListener"; - -constexpr char SurfaceTextureListener::New_t::name[]; -constexpr char SurfaceTextureListener::New_t::signature[]; - -auto SurfaceTextureListener::New() -> SurfaceTextureListener::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(SurfaceTextureListener::Context(), nullptr); -} - -constexpr char SurfaceTextureListener::OnFrameAvailable_t::name[]; -constexpr char SurfaceTextureListener::OnFrameAvailable_t::signature[]; - -const char GeckoLayerClient::name[] = - "org/mozilla/gecko/gfx/GeckoLayerClient"; - -constexpr char GeckoLayerClient::ContentDocumentChanged_t::name[]; -constexpr char GeckoLayerClient::ContentDocumentChanged_t::signature[]; - -auto GeckoLayerClient::ContentDocumentChanged() const -> void -{ - return mozilla::jni::Method<ContentDocumentChanged_t>::Call(GeckoLayerClient::mCtx, nullptr); -} - -constexpr char GeckoLayerClient::CreateFrame_t::name[]; -constexpr char GeckoLayerClient::CreateFrame_t::signature[]; - -auto GeckoLayerClient::CreateFrame() const -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<CreateFrame_t>::Call(GeckoLayerClient::mCtx, nullptr); -} - -constexpr char GeckoLayerClient::IsContentDocumentDisplayed_t::name[]; -constexpr char GeckoLayerClient::IsContentDocumentDisplayed_t::signature[]; - -auto GeckoLayerClient::IsContentDocumentDisplayed() const -> bool -{ - return mozilla::jni::Method<IsContentDocumentDisplayed_t>::Call(GeckoLayerClient::mCtx, nullptr); -} - -constexpr char GeckoLayerClient::OnGeckoReady_t::name[]; -constexpr char GeckoLayerClient::OnGeckoReady_t::signature[]; - -auto GeckoLayerClient::OnGeckoReady() const -> void -{ - return mozilla::jni::Method<OnGeckoReady_t>::Call(GeckoLayerClient::mCtx, nullptr); -} - -constexpr char GeckoLayerClient::SetFirstPaintViewport_t::name[]; -constexpr char GeckoLayerClient::SetFirstPaintViewport_t::signature[]; - -auto GeckoLayerClient::SetFirstPaintViewport(float a0, float a1, float a2, float a3, float a4, float a5, float a6) const -> void -{ - return mozilla::jni::Method<SetFirstPaintViewport_t>::Call(GeckoLayerClient::mCtx, nullptr, a0, a1, a2, a3, a4, a5, a6); -} - -constexpr char GeckoLayerClient::SyncFrameMetrics_t::name[]; -constexpr char GeckoLayerClient::SyncFrameMetrics_t::signature[]; - -auto GeckoLayerClient::SyncFrameMetrics(float a0, float a1, float a2, float a3, float a4, float a5, float a6, int32_t a7, int32_t a8, int32_t a9, int32_t a10, float a11, bool a12, int32_t a13) const -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<SyncFrameMetrics_t>::Call(GeckoLayerClient::mCtx, nullptr, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); -} - -constexpr char GeckoLayerClient::SynthesizeNativeMouseEvent_t::name[]; -constexpr char GeckoLayerClient::SynthesizeNativeMouseEvent_t::signature[]; - -auto GeckoLayerClient::SynthesizeNativeMouseEvent(int32_t a0, int32_t a1, int32_t a2) const -> void -{ - return mozilla::jni::Method<SynthesizeNativeMouseEvent_t>::Call(GeckoLayerClient::mCtx, nullptr, a0, a1, a2); -} - -constexpr char GeckoLayerClient::SynthesizeNativeTouchPoint_t::name[]; -constexpr char GeckoLayerClient::SynthesizeNativeTouchPoint_t::signature[]; - -auto GeckoLayerClient::SynthesizeNativeTouchPoint(int32_t a0, int32_t a1, int32_t a2, int32_t a3, double a4, int32_t a5) const -> void -{ - return mozilla::jni::Method<SynthesizeNativeTouchPoint_t>::Call(GeckoLayerClient::mCtx, nullptr, a0, a1, a2, a3, a4, a5); -} - -constexpr char GeckoLayerClient::ClearColor_t::name[]; -constexpr char GeckoLayerClient::ClearColor_t::signature[]; - -auto GeckoLayerClient::ClearColor() const -> int32_t -{ - return mozilla::jni::Field<ClearColor_t>::Get(GeckoLayerClient::mCtx, nullptr); -} - -auto GeckoLayerClient::ClearColor(int32_t a0) const -> void -{ - return mozilla::jni::Field<ClearColor_t>::Set(GeckoLayerClient::mCtx, nullptr, a0); -} - -const char ImmutableViewportMetrics::name[] = - "org/mozilla/gecko/gfx/ImmutableViewportMetrics"; - -constexpr char ImmutableViewportMetrics::New_t::name[]; -constexpr char ImmutableViewportMetrics::New_t::signature[]; - -auto ImmutableViewportMetrics::New(float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, int32_t a10, int32_t a11, float a12) -> ImmutableViewportMetrics::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(ImmutableViewportMetrics::Context(), nullptr, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); -} - -const char LayerRenderer::name[] = - "org/mozilla/gecko/gfx/LayerRenderer"; - -const char LayerRenderer::Frame::name[] = - "org/mozilla/gecko/gfx/LayerRenderer$Frame"; - -constexpr char LayerRenderer::Frame::BeginDrawing_t::name[]; -constexpr char LayerRenderer::Frame::BeginDrawing_t::signature[]; - -auto LayerRenderer::Frame::BeginDrawing() const -> void -{ - return mozilla::jni::Method<BeginDrawing_t>::Call(Frame::mCtx, nullptr); -} - -constexpr char LayerRenderer::Frame::EndDrawing_t::name[]; -constexpr char LayerRenderer::Frame::EndDrawing_t::signature[]; - -auto LayerRenderer::Frame::EndDrawing() const -> void -{ - return mozilla::jni::Method<EndDrawing_t>::Call(Frame::mCtx, nullptr); -} - -const char LayerView::name[] = - "org/mozilla/gecko/gfx/LayerView"; - -constexpr char LayerView::GetCompositor_t::name[]; -constexpr char LayerView::GetCompositor_t::signature[]; - -auto LayerView::GetCompositor() const -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Method<GetCompositor_t>::Call(LayerView::mCtx, nullptr); -} - -constexpr char LayerView::UpdateZoomedView_t::name[]; -constexpr char LayerView::UpdateZoomedView_t::signature[]; - -auto LayerView::UpdateZoomedView(mozilla::jni::ByteBuffer::Param a0) -> void -{ - return mozilla::jni::Method<UpdateZoomedView_t>::Call(LayerView::Context(), nullptr, a0); -} - -constexpr char LayerView::CompositorCreated_t::name[]; -constexpr char LayerView::CompositorCreated_t::signature[]; - -auto LayerView::CompositorCreated() const -> bool -{ - return mozilla::jni::Field<CompositorCreated_t>::Get(LayerView::mCtx, nullptr); -} - -auto LayerView::CompositorCreated(bool a0) const -> void -{ - return mozilla::jni::Field<CompositorCreated_t>::Set(LayerView::mCtx, nullptr, a0); -} - -const char LayerView::Compositor::name[] = - "org/mozilla/gecko/gfx/LayerView$Compositor"; - -constexpr char LayerView::Compositor::AttachToJava_t::name[]; -constexpr char LayerView::Compositor::AttachToJava_t::signature[]; - -constexpr char LayerView::Compositor::CreateCompositor_t::name[]; -constexpr char LayerView::Compositor::CreateCompositor_t::signature[]; - -constexpr char LayerView::Compositor::Destroy_t::name[]; -constexpr char LayerView::Compositor::Destroy_t::signature[]; - -auto LayerView::Compositor::Destroy() const -> void -{ - return mozilla::jni::Method<Destroy_t>::Call(Compositor::mCtx, nullptr); -} - -constexpr char LayerView::Compositor::DisposeNative_t::name[]; -constexpr char LayerView::Compositor::DisposeNative_t::signature[]; - -constexpr char LayerView::Compositor::OnSizeChanged_t::name[]; -constexpr char LayerView::Compositor::OnSizeChanged_t::signature[]; - -constexpr char LayerView::Compositor::Reattach_t::name[]; -constexpr char LayerView::Compositor::Reattach_t::signature[]; - -auto LayerView::Compositor::Reattach() const -> void -{ - return mozilla::jni::Method<Reattach_t>::Call(Compositor::mCtx, nullptr); -} - -constexpr char LayerView::Compositor::SyncInvalidateAndScheduleComposite_t::name[]; -constexpr char LayerView::Compositor::SyncInvalidateAndScheduleComposite_t::signature[]; - -constexpr char LayerView::Compositor::SyncPauseCompositor_t::name[]; -constexpr char LayerView::Compositor::SyncPauseCompositor_t::signature[]; - -constexpr char LayerView::Compositor::SyncResumeResizeCompositor_t::name[]; -constexpr char LayerView::Compositor::SyncResumeResizeCompositor_t::signature[]; - -const char NativePanZoomController::name[] = - "org/mozilla/gecko/gfx/NativePanZoomController"; - -constexpr char NativePanZoomController::AdjustScrollForSurfaceShift_t::name[]; -constexpr char NativePanZoomController::AdjustScrollForSurfaceShift_t::signature[]; - -constexpr char NativePanZoomController::Destroy_t::name[]; -constexpr char NativePanZoomController::Destroy_t::signature[]; - -auto NativePanZoomController::Destroy() const -> void -{ - return mozilla::jni::Method<Destroy_t>::Call(NativePanZoomController::mCtx, nullptr); -} - -constexpr char NativePanZoomController::DisposeNative_t::name[]; -constexpr char NativePanZoomController::DisposeNative_t::signature[]; - -constexpr char NativePanZoomController::HandleMotionEvent_t::name[]; -constexpr char NativePanZoomController::HandleMotionEvent_t::signature[]; - -constexpr char NativePanZoomController::HandleMotionEventVelocity_t::name[]; -constexpr char NativePanZoomController::HandleMotionEventVelocity_t::signature[]; - -constexpr char NativePanZoomController::HandleMouseEvent_t::name[]; -constexpr char NativePanZoomController::HandleMouseEvent_t::signature[]; - -constexpr char NativePanZoomController::HandleScrollEvent_t::name[]; -constexpr char NativePanZoomController::HandleScrollEvent_t::signature[]; - -constexpr char NativePanZoomController::SetIsLongpressEnabled_t::name[]; -constexpr char NativePanZoomController::SetIsLongpressEnabled_t::signature[]; - -constexpr char NativePanZoomController::OnSelectionDragState_t::name[]; -constexpr char NativePanZoomController::OnSelectionDragState_t::signature[]; - -auto NativePanZoomController::OnSelectionDragState(bool a0) const -> void -{ - return mozilla::jni::Method<OnSelectionDragState_t>::Call(NativePanZoomController::mCtx, nullptr, a0); -} - -constexpr char NativePanZoomController::SetScrollingRootContent_t::name[]; -constexpr char NativePanZoomController::SetScrollingRootContent_t::signature[]; - -auto NativePanZoomController::SetScrollingRootContent(bool a0) const -> void -{ - return mozilla::jni::Method<SetScrollingRootContent_t>::Call(NativePanZoomController::mCtx, nullptr, a0); -} - -constexpr char NativePanZoomController::UpdateOverscrollOffset_t::name[]; -constexpr char NativePanZoomController::UpdateOverscrollOffset_t::signature[]; - -auto NativePanZoomController::UpdateOverscrollOffset(float a0, float a1) const -> void -{ - return mozilla::jni::Method<UpdateOverscrollOffset_t>::Call(NativePanZoomController::mCtx, nullptr, a0, a1); -} - -constexpr char NativePanZoomController::UpdateOverscrollVelocity_t::name[]; -constexpr char NativePanZoomController::UpdateOverscrollVelocity_t::signature[]; - -auto NativePanZoomController::UpdateOverscrollVelocity(float a0, float a1) const -> void -{ - return mozilla::jni::Method<UpdateOverscrollVelocity_t>::Call(NativePanZoomController::mCtx, nullptr, a0, a1); -} - -const char ProgressiveUpdateData::name[] = - "org/mozilla/gecko/gfx/ProgressiveUpdateData"; - -constexpr char ProgressiveUpdateData::New_t::name[]; -constexpr char ProgressiveUpdateData::New_t::signature[]; - -auto ProgressiveUpdateData::New() -> ProgressiveUpdateData::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(ProgressiveUpdateData::Context(), nullptr); -} - -constexpr char ProgressiveUpdateData::SetViewport_t::name[]; -constexpr char ProgressiveUpdateData::SetViewport_t::signature[]; - -auto ProgressiveUpdateData::SetViewport(mozilla::jni::Object::Param a0) const -> void -{ - return mozilla::jni::Method<SetViewport_t>::Call(ProgressiveUpdateData::mCtx, nullptr, a0); -} - -constexpr char ProgressiveUpdateData::Abort_t::name[]; -constexpr char ProgressiveUpdateData::Abort_t::signature[]; - -auto ProgressiveUpdateData::Abort() const -> bool -{ - return mozilla::jni::Field<Abort_t>::Get(ProgressiveUpdateData::mCtx, nullptr); -} - -auto ProgressiveUpdateData::Abort(bool a0) const -> void -{ - return mozilla::jni::Field<Abort_t>::Set(ProgressiveUpdateData::mCtx, nullptr, a0); -} - -constexpr char ProgressiveUpdateData::Scale_t::name[]; -constexpr char ProgressiveUpdateData::Scale_t::signature[]; - -auto ProgressiveUpdateData::Scale() const -> float -{ - return mozilla::jni::Field<Scale_t>::Get(ProgressiveUpdateData::mCtx, nullptr); -} - -auto ProgressiveUpdateData::Scale(float a0) const -> void -{ - return mozilla::jni::Field<Scale_t>::Set(ProgressiveUpdateData::mCtx, nullptr, a0); -} - -constexpr char ProgressiveUpdateData::X_t::name[]; -constexpr char ProgressiveUpdateData::X_t::signature[]; - -auto ProgressiveUpdateData::X() const -> float -{ - return mozilla::jni::Field<X_t>::Get(ProgressiveUpdateData::mCtx, nullptr); -} - -auto ProgressiveUpdateData::X(float a0) const -> void -{ - return mozilla::jni::Field<X_t>::Set(ProgressiveUpdateData::mCtx, nullptr, a0); -} - -constexpr char ProgressiveUpdateData::Y_t::name[]; -constexpr char ProgressiveUpdateData::Y_t::signature[]; - -auto ProgressiveUpdateData::Y() const -> float -{ - return mozilla::jni::Field<Y_t>::Get(ProgressiveUpdateData::mCtx, nullptr); -} - -auto ProgressiveUpdateData::Y(float a0) const -> void -{ - return mozilla::jni::Field<Y_t>::Set(ProgressiveUpdateData::mCtx, nullptr, a0); -} - -const char StackScroller::name[] = - "org/mozilla/gecko/gfx/StackScroller"; - -constexpr char StackScroller::New_t::name[]; -constexpr char StackScroller::New_t::signature[]; - -auto StackScroller::New(mozilla::jni::Object::Param a0, StackScroller::LocalRef* a1) -> nsresult -{ - MOZ_ASSERT(a1); - nsresult rv = NS_OK; - *a1 = mozilla::jni::Constructor<New_t>::Call(StackScroller::Context(), &rv, a0); - return rv; -} - -constexpr char StackScroller::AbortAnimation_t::name[]; -constexpr char StackScroller::AbortAnimation_t::signature[]; - -auto StackScroller::AbortAnimation() const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<AbortAnimation_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::ComputeScrollOffset_t::name[]; -constexpr char StackScroller::ComputeScrollOffset_t::signature[]; - -auto StackScroller::ComputeScrollOffset(int64_t a0, bool* a1) const -> nsresult -{ - MOZ_ASSERT(a1); - nsresult rv = NS_OK; - *a1 = mozilla::jni::Method<ComputeScrollOffset_t>::Call(StackScroller::mCtx, &rv, a0); - return rv; -} - -constexpr char StackScroller::Fling_t::name[]; -constexpr char StackScroller::Fling_t::signature[]; - -auto StackScroller::Fling(int32_t a0, int32_t a1, int32_t a2, int32_t a3, int32_t a4, int32_t a5, int32_t a6, int32_t a7, int32_t a8, int32_t a9, int64_t a10) const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<Fling_t>::Call(StackScroller::mCtx, &rv, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); - return rv; -} - -constexpr char StackScroller::ForceFinished_t::name[]; -constexpr char StackScroller::ForceFinished_t::signature[]; - -auto StackScroller::ForceFinished(bool a0) const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<ForceFinished_t>::Call(StackScroller::mCtx, &rv, a0); - return rv; -} - -constexpr char StackScroller::GetCurrSpeedX_t::name[]; -constexpr char StackScroller::GetCurrSpeedX_t::signature[]; - -auto StackScroller::GetCurrSpeedX(float* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetCurrSpeedX_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::GetCurrSpeedY_t::name[]; -constexpr char StackScroller::GetCurrSpeedY_t::signature[]; - -auto StackScroller::GetCurrSpeedY(float* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetCurrSpeedY_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::GetCurrX_t::name[]; -constexpr char StackScroller::GetCurrX_t::signature[]; - -auto StackScroller::GetCurrX(int32_t* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetCurrX_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::GetCurrY_t::name[]; -constexpr char StackScroller::GetCurrY_t::signature[]; - -auto StackScroller::GetCurrY(int32_t* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetCurrY_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::GetFinalX_t::name[]; -constexpr char StackScroller::GetFinalX_t::signature[]; - -auto StackScroller::GetFinalX(int32_t* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetFinalX_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::GetFinalY_t::name[]; -constexpr char StackScroller::GetFinalY_t::signature[]; - -auto StackScroller::GetFinalY(int32_t* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<GetFinalY_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::InitContants_t::name[]; -constexpr char StackScroller::InitContants_t::signature[]; - -auto StackScroller::InitContants() -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<InitContants_t>::Call(StackScroller::Context(), &rv); - return rv; -} - -constexpr char StackScroller::IsFinished_t::name[]; -constexpr char StackScroller::IsFinished_t::signature[]; - -auto StackScroller::IsFinished(bool* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Method<IsFinished_t>::Call(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::SetFinalX_t::name[]; -constexpr char StackScroller::SetFinalX_t::signature[]; - -auto StackScroller::SetFinalX(int32_t a0) const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<SetFinalX_t>::Call(StackScroller::mCtx, &rv, a0); - return rv; -} - -constexpr char StackScroller::SpringBack_t::name[]; -constexpr char StackScroller::SpringBack_t::signature[]; - -auto StackScroller::SpringBack(int32_t a0, int32_t a1, int32_t a2, int32_t a3, int32_t a4, int32_t a5, int64_t a6, bool* a7) const -> nsresult -{ - MOZ_ASSERT(a7); - nsresult rv = NS_OK; - *a7 = mozilla::jni::Method<SpringBack_t>::Call(StackScroller::mCtx, &rv, a0, a1, a2, a3, a4, a5, a6); - return rv; -} - -constexpr char StackScroller::StartScroll_t::name[]; -constexpr char StackScroller::StartScroll_t::signature[]; - -auto StackScroller::StartScroll(int32_t a0, int32_t a1, int32_t a2, int32_t a3, int64_t a4, int32_t a5) const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Method<StartScroll_t>::Call(StackScroller::mCtx, &rv, a0, a1, a2, a3, a4, a5); - return rv; -} - -constexpr char StackScroller::ViscousFluid_t::name[]; -constexpr char StackScroller::ViscousFluid_t::signature[]; - -auto StackScroller::ViscousFluid(float a0, float* a1) -> nsresult -{ - MOZ_ASSERT(a1); - nsresult rv = NS_OK; - *a1 = mozilla::jni::Method<ViscousFluid_t>::Call(StackScroller::Context(), &rv, a0); - return rv; -} - -constexpr char StackScroller::MFlywheel_t::name[]; -constexpr char StackScroller::MFlywheel_t::signature[]; - -auto StackScroller::MFlywheel(bool* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<MFlywheel_t>::Get(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::MMode_t::name[]; -constexpr char StackScroller::MMode_t::signature[]; - -auto StackScroller::MMode(int32_t* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<MMode_t>::Get(StackScroller::mCtx, &rv); - return rv; -} - -auto StackScroller::MMode(int32_t a0) const -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Field<MMode_t>::Set(StackScroller::mCtx, &rv, a0); - return rv; -} - -constexpr char StackScroller::MScrollerX_t::name[]; -constexpr char StackScroller::MScrollerX_t::signature[]; - -auto StackScroller::MScrollerX(mozilla::jni::Object::LocalRef* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<MScrollerX_t>::Get(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::MScrollerY_t::name[]; -constexpr char StackScroller::MScrollerY_t::signature[]; - -auto StackScroller::MScrollerY(mozilla::jni::Object::LocalRef* a0) const -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<MScrollerY_t>::Get(StackScroller::mCtx, &rv); - return rv; -} - -constexpr char StackScroller::SViscousFluidNormalize_t::name[]; -constexpr char StackScroller::SViscousFluidNormalize_t::signature[]; - -auto StackScroller::SViscousFluidNormalize(float* a0) -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<SViscousFluidNormalize_t>::Get(StackScroller::Context(), &rv); - return rv; -} - -auto StackScroller::SViscousFluidNormalize(float a0) -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Field<SViscousFluidNormalize_t>::Set(StackScroller::Context(), &rv, a0); - return rv; -} - -constexpr char StackScroller::SViscousFluidScale_t::name[]; -constexpr char StackScroller::SViscousFluidScale_t::signature[]; - -auto StackScroller::SViscousFluidScale(float* a0) -> nsresult -{ - MOZ_ASSERT(a0); - nsresult rv = NS_OK; - *a0 = mozilla::jni::Field<SViscousFluidScale_t>::Get(StackScroller::Context(), &rv); - return rv; -} - -auto StackScroller::SViscousFluidScale(float a0) -> nsresult -{ - nsresult rv = NS_OK; - mozilla::jni::Field<SViscousFluidScale_t>::Set(StackScroller::Context(), &rv, a0); - return rv; -} - -const char ViewTransform::name[] = - "org/mozilla/gecko/gfx/ViewTransform"; - -constexpr char ViewTransform::New_t::name[]; -constexpr char ViewTransform::New_t::signature[]; - -auto ViewTransform::New(float a0, float a1, float a2) -> ViewTransform::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(ViewTransform::Context(), nullptr, a0, a1, a2); -} - -constexpr char ViewTransform::FixedLayerMarginBottom_t::name[]; -constexpr char ViewTransform::FixedLayerMarginBottom_t::signature[]; - -auto ViewTransform::FixedLayerMarginBottom() const -> float -{ - return mozilla::jni::Field<FixedLayerMarginBottom_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::FixedLayerMarginBottom(float a0) const -> void -{ - return mozilla::jni::Field<FixedLayerMarginBottom_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::FixedLayerMarginLeft_t::name[]; -constexpr char ViewTransform::FixedLayerMarginLeft_t::signature[]; - -auto ViewTransform::FixedLayerMarginLeft() const -> float -{ - return mozilla::jni::Field<FixedLayerMarginLeft_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::FixedLayerMarginLeft(float a0) const -> void -{ - return mozilla::jni::Field<FixedLayerMarginLeft_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::FixedLayerMarginRight_t::name[]; -constexpr char ViewTransform::FixedLayerMarginRight_t::signature[]; - -auto ViewTransform::FixedLayerMarginRight() const -> float -{ - return mozilla::jni::Field<FixedLayerMarginRight_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::FixedLayerMarginRight(float a0) const -> void -{ - return mozilla::jni::Field<FixedLayerMarginRight_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::FixedLayerMarginTop_t::name[]; -constexpr char ViewTransform::FixedLayerMarginTop_t::signature[]; - -auto ViewTransform::FixedLayerMarginTop() const -> float -{ - return mozilla::jni::Field<FixedLayerMarginTop_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::FixedLayerMarginTop(float a0) const -> void -{ - return mozilla::jni::Field<FixedLayerMarginTop_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::Height_t::name[]; -constexpr char ViewTransform::Height_t::signature[]; - -auto ViewTransform::Height() const -> float -{ - return mozilla::jni::Field<Height_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::Height(float a0) const -> void -{ - return mozilla::jni::Field<Height_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::Scale_t::name[]; -constexpr char ViewTransform::Scale_t::signature[]; - -auto ViewTransform::Scale() const -> float -{ - return mozilla::jni::Field<Scale_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::Scale(float a0) const -> void -{ - return mozilla::jni::Field<Scale_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::Width_t::name[]; -constexpr char ViewTransform::Width_t::signature[]; - -auto ViewTransform::Width() const -> float -{ - return mozilla::jni::Field<Width_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::Width(float a0) const -> void -{ - return mozilla::jni::Field<Width_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::X_t::name[]; -constexpr char ViewTransform::X_t::signature[]; - -auto ViewTransform::X() const -> float -{ - return mozilla::jni::Field<X_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::X(float a0) const -> void -{ - return mozilla::jni::Field<X_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -constexpr char ViewTransform::Y_t::name[]; -constexpr char ViewTransform::Y_t::signature[]; - -auto ViewTransform::Y() const -> float -{ - return mozilla::jni::Field<Y_t>::Get(ViewTransform::mCtx, nullptr); -} - -auto ViewTransform::Y(float a0) const -> void -{ - return mozilla::jni::Field<Y_t>::Set(ViewTransform::mCtx, nullptr, a0); -} - -const char Clipboard::name[] = - "org/mozilla/gecko/util/Clipboard"; - -constexpr char Clipboard::ClearText_t::name[]; -constexpr char Clipboard::ClearText_t::signature[]; - -auto Clipboard::ClearText() -> void -{ - return mozilla::jni::Method<ClearText_t>::Call(Clipboard::Context(), nullptr); -} - -constexpr char Clipboard::GetText_t::name[]; -constexpr char Clipboard::GetText_t::signature[]; - -auto Clipboard::GetText() -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetText_t>::Call(Clipboard::Context(), nullptr); -} - -constexpr char Clipboard::HasText_t::name[]; -constexpr char Clipboard::HasText_t::signature[]; - -auto Clipboard::HasText() -> bool -{ - return mozilla::jni::Method<HasText_t>::Call(Clipboard::Context(), nullptr); -} - -constexpr char Clipboard::SetText_t::name[]; -constexpr char Clipboard::SetText_t::signature[]; - -auto Clipboard::SetText(mozilla::jni::String::Param a0) -> void -{ - return mozilla::jni::Method<SetText_t>::Call(Clipboard::Context(), nullptr, a0); -} - -const char HardwareCodecCapabilityUtils::name[] = - "org/mozilla/gecko/util/HardwareCodecCapabilityUtils"; - -constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::name[]; -constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::signature[]; - -auto HardwareCodecCapabilityUtils::HasHWVP9() -> bool -{ - return mozilla::jni::Method<HasHWVP9_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr); -} - -constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::name[]; -constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::signature[]; - -auto HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(mozilla::jni::String::Param a0) -> bool -{ - return mozilla::jni::Method<FindDecoderCodecInfoForMimeType_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr, a0); -} - -const char NativeJSContainer::name[] = - "org/mozilla/gecko/util/NativeJSContainer"; - -constexpr char NativeJSContainer::New_t::name[]; -constexpr char NativeJSContainer::New_t::signature[]; - -auto NativeJSContainer::New() -> NativeJSContainer::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(NativeJSContainer::Context(), nullptr); -} - -constexpr char NativeJSContainer::Clone2_t::name[]; -constexpr char NativeJSContainer::Clone2_t::signature[]; - -constexpr char NativeJSContainer::DisposeNative_t::name[]; -constexpr char NativeJSContainer::DisposeNative_t::signature[]; - -const char NativeJSObject::name[] = - "org/mozilla/gecko/util/NativeJSObject"; - -constexpr char NativeJSObject::New_t::name[]; -constexpr char NativeJSObject::New_t::signature[]; - -auto NativeJSObject::New() -> NativeJSObject::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(NativeJSObject::Context(), nullptr); -} - -constexpr char NativeJSObject::DisposeNative_t::name[]; -constexpr char NativeJSObject::DisposeNative_t::signature[]; - -auto NativeJSObject::DisposeNative() const -> void -{ - return mozilla::jni::Method<DisposeNative_t>::Call(NativeJSObject::mCtx, nullptr); -} - -constexpr char NativeJSObject::GetBoolean_t::name[]; -constexpr char NativeJSObject::GetBoolean_t::signature[]; - -constexpr char NativeJSObject::GetBooleanArray_t::name[]; -constexpr char NativeJSObject::GetBooleanArray_t::signature[]; - -constexpr char NativeJSObject::GetBundle_t::name[]; -constexpr char NativeJSObject::GetBundle_t::signature[]; - -constexpr char NativeJSObject::GetBundleArray_t::name[]; -constexpr char NativeJSObject::GetBundleArray_t::signature[]; - -constexpr char NativeJSObject::GetDouble_t::name[]; -constexpr char NativeJSObject::GetDouble_t::signature[]; - -constexpr char NativeJSObject::GetDoubleArray_t::name[]; -constexpr char NativeJSObject::GetDoubleArray_t::signature[]; - -constexpr char NativeJSObject::GetInt_t::name[]; -constexpr char NativeJSObject::GetInt_t::signature[]; - -constexpr char NativeJSObject::GetIntArray_t::name[]; -constexpr char NativeJSObject::GetIntArray_t::signature[]; - -constexpr char NativeJSObject::GetObject_t::name[]; -constexpr char NativeJSObject::GetObject_t::signature[]; - -constexpr char NativeJSObject::GetObjectArray_t::name[]; -constexpr char NativeJSObject::GetObjectArray_t::signature[]; - -constexpr char NativeJSObject::GetString_t::name[]; -constexpr char NativeJSObject::GetString_t::signature[]; - -constexpr char NativeJSObject::GetStringArray_t::name[]; -constexpr char NativeJSObject::GetStringArray_t::signature[]; - -constexpr char NativeJSObject::Has_t::name[]; -constexpr char NativeJSObject::Has_t::signature[]; - -constexpr char NativeJSObject::OptBoolean_t::name[]; -constexpr char NativeJSObject::OptBoolean_t::signature[]; - -constexpr char NativeJSObject::OptBooleanArray_t::name[]; -constexpr char NativeJSObject::OptBooleanArray_t::signature[]; - -constexpr char NativeJSObject::OptBundle_t::name[]; -constexpr char NativeJSObject::OptBundle_t::signature[]; - -constexpr char NativeJSObject::OptBundleArray_t::name[]; -constexpr char NativeJSObject::OptBundleArray_t::signature[]; - -constexpr char NativeJSObject::OptDouble_t::name[]; -constexpr char NativeJSObject::OptDouble_t::signature[]; - -constexpr char NativeJSObject::OptDoubleArray_t::name[]; -constexpr char NativeJSObject::OptDoubleArray_t::signature[]; - -constexpr char NativeJSObject::OptInt_t::name[]; -constexpr char NativeJSObject::OptInt_t::signature[]; - -constexpr char NativeJSObject::OptIntArray_t::name[]; -constexpr char NativeJSObject::OptIntArray_t::signature[]; - -constexpr char NativeJSObject::OptObject_t::name[]; -constexpr char NativeJSObject::OptObject_t::signature[]; - -constexpr char NativeJSObject::OptObjectArray_t::name[]; -constexpr char NativeJSObject::OptObjectArray_t::signature[]; - -constexpr char NativeJSObject::OptString_t::name[]; -constexpr char NativeJSObject::OptString_t::signature[]; - -constexpr char NativeJSObject::OptStringArray_t::name[]; -constexpr char NativeJSObject::OptStringArray_t::signature[]; - -constexpr char NativeJSObject::ToBundle_t::name[]; -constexpr char NativeJSObject::ToBundle_t::signature[]; - -constexpr char NativeJSObject::ToString_t::name[]; -constexpr char NativeJSObject::ToString_t::signature[]; - -} /* java */ -} /* mozilla */ diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h deleted file mode 100644 index 7d4777648..000000000 --- a/widget/android/GeneratedJNIWrappers.h +++ /dev/null @@ -1,5456 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#ifndef GeneratedJNIWrappers_h -#define GeneratedJNIWrappers_h - -#include "mozilla/jni/Refs.h" - -namespace mozilla { -namespace java { - -class AlarmReceiver : public mozilla::jni::ObjectBase<AlarmReceiver> -{ -public: - static const char name[]; - - explicit AlarmReceiver(const Context& ctx) : ObjectBase<AlarmReceiver>(ctx) {} - - struct NotifyAlarmFired_t { - typedef AlarmReceiver Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "notifyAlarmFired"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - - template<class Impl> class Natives; -}; - -class AndroidGamepadManager : public mozilla::jni::ObjectBase<AndroidGamepadManager> -{ -public: - static const char name[]; - - explicit AndroidGamepadManager(const Context& ctx) : ObjectBase<AndroidGamepadManager>(ctx) {} - - struct OnAxisChange_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::BooleanArray::Param, - mozilla::jni::FloatArray::Param> Args; - static constexpr char name[] = "onAxisChange"; - static constexpr char signature[] = - "(I[Z[F)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnButtonChange_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - bool, - float> Args; - static constexpr char name[] = "onButtonChange"; - static constexpr char signature[] = - "(IIZF)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnGamepadAdded_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "onGamepadAdded"; - static constexpr char signature[] = - "(II)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto OnGamepadAdded(int32_t, int32_t) -> void; - - struct OnGamepadChange_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - bool> Args; - static constexpr char name[] = "onGamepadChange"; - static constexpr char signature[] = - "(IZ)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct Start_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "start"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Start() -> void; - - struct Stop_t { - typedef AndroidGamepadManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "stop"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Stop() -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoAppShell : public mozilla::jni::ObjectBase<GeckoAppShell> -{ -public: - static const char name[]; - - explicit GeckoAppShell(const Context& ctx) : ObjectBase<GeckoAppShell>(ctx) {} - - class CameraCallback; - - struct AddFullScreenPluginView_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "addFullScreenPluginView"; - static constexpr char signature[] = - "(Landroid/view/View;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto AddFullScreenPluginView(mozilla::jni::Object::Param) -> void; - - struct CancelVibrate_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "cancelVibrate"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CancelVibrate() -> void; - - struct CheckURIVisited_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "checkUriVisited"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CheckURIVisited(mozilla::jni::String::Param) -> void; - - struct CloseCamera_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "closeCamera"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CloseCamera() -> void; - - struct CloseNotification_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "closeNotification"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CloseNotification(mozilla::jni::String::Param) -> void; - - struct ConnectionGetMimeType_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "connectionGetMimeType"; - static constexpr char signature[] = - "(Ljava/net/URLConnection;)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ConnectionGetMimeType(mozilla::jni::Object::Param) -> mozilla::jni::String::LocalRef; - - struct CreateInputStream_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "createInputStream"; - static constexpr char signature[] = - "(Ljava/net/URLConnection;)Ljava/io/InputStream;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CreateInputStream(mozilla::jni::Object::Param) -> mozilla::jni::Object::LocalRef; - - struct CreateShortcut_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "createShortcut"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CreateShortcut(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - - struct DisableAlarm_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disableAlarm"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto DisableAlarm() -> void; - - struct DisableBatteryNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disableBatteryNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto DisableBatteryNotifications() -> void; - - struct DisableNetworkNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disableNetworkNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto DisableNetworkNotifications() -> void; - - struct DisableScreenOrientationNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disableScreenOrientationNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto DisableScreenOrientationNotifications() -> void; - - struct DisableSensor_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "disableSensor"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto DisableSensor(int32_t) -> void; - - struct EnableBatteryNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "enableBatteryNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableBatteryNotifications() -> void; - - struct EnableLocation_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "enableLocation"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableLocation(bool) -> void; - - struct EnableLocationHighAccuracy_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "enableLocationHighAccuracy"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableLocationHighAccuracy(bool) -> void; - - struct EnableNetworkNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "enableNetworkNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableNetworkNotifications() -> void; - - struct EnableScreenOrientationNotifications_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "enableScreenOrientationNotifications"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableScreenOrientationNotifications() -> void; - - struct EnableSensor_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "enableSensor"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EnableSensor(int32_t) -> void; - - struct GetApplicationContext_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getApplicationContext"; - static constexpr char signature[] = - "()Landroid/content/Context;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetApplicationContext() -> mozilla::jni::Object::LocalRef; - - struct GetConnection_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getConnection"; - static constexpr char signature[] = - "(Ljava/lang/String;)Ljava/net/URLConnection;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetConnection(mozilla::jni::String::Param) -> mozilla::jni::Object::LocalRef; - - struct GetContext_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getContext"; - static constexpr char signature[] = - "()Landroid/content/Context;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetContext() -> mozilla::jni::Object::LocalRef; - - struct GetCurrentBatteryInformation_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::DoubleArray::LocalRef ReturnType; - typedef mozilla::jni::DoubleArray::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrentBatteryInformation"; - static constexpr char signature[] = - "()[D"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetCurrentBatteryInformation() -> mozilla::jni::DoubleArray::LocalRef; - - struct GetCurrentNetworkInformation_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::DoubleArray::LocalRef ReturnType; - typedef mozilla::jni::DoubleArray::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrentNetworkInformation"; - static constexpr char signature[] = - "()[D"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetCurrentNetworkInformation() -> mozilla::jni::DoubleArray::LocalRef; - - struct GetDensity_t { - typedef GeckoAppShell Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getDensity"; - static constexpr char signature[] = - "()F"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetDensity() -> float; - - struct GetDpi_t { - typedef GeckoAppShell Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getDpi"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetDpi() -> int32_t; - - struct GetExceptionStackTrace_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Throwable::Param> Args; - static constexpr char name[] = "getExceptionStackTrace"; - static constexpr char signature[] = - "(Ljava/lang/Throwable;)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::IGNORE; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetExceptionStackTrace(mozilla::jni::Throwable::Param) -> mozilla::jni::String::LocalRef; - - struct GetExtensionFromMimeType_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getExtensionFromMimeType"; - static constexpr char signature[] = - "(Ljava/lang/String;)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetExtensionFromMimeType(mozilla::jni::String::Param) -> mozilla::jni::String::LocalRef; - - struct GetHWDecoderCapability_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getHWDecoderCapability"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetHWDecoderCapability() -> bool; - - struct GetHWEncoderCapability_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getHWEncoderCapability"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetHWEncoderCapability() -> bool; - - struct GetHandlersForMimeType_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getHandlersForMimeType"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetHandlersForMimeType(mozilla::jni::String::Param, mozilla::jni::String::Param) -> mozilla::jni::ObjectArray::LocalRef; - - struct GetHandlersForURL_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getHandlersForURL"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetHandlersForURL(mozilla::jni::String::Param, mozilla::jni::String::Param) -> mozilla::jni::ObjectArray::LocalRef; - - struct GetIconForExtension_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::ByteArray::LocalRef ReturnType; - typedef mozilla::jni::ByteArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "getIconForExtension"; - static constexpr char signature[] = - "(Ljava/lang/String;I)[B"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetIconForExtension(mozilla::jni::String::Param, int32_t) -> mozilla::jni::ByteArray::LocalRef; - - struct GetMaxTouchPoints_t { - typedef GeckoAppShell Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getMaxTouchPoints"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetMaxTouchPoints() -> int32_t; - - struct GetMimeTypeFromExtensions_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getMimeTypeFromExtensions"; - static constexpr char signature[] = - "(Ljava/lang/String;)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetMimeTypeFromExtensions(mozilla::jni::String::Param) -> mozilla::jni::String::LocalRef; - - struct GetNetworkLinkType_t { - typedef GeckoAppShell Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getNetworkLinkType"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetNetworkLinkType() -> int32_t; - - struct GetProxyForURI_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "getProxyForURI"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetProxyForURI(mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, int32_t) -> mozilla::jni::String::LocalRef; - - struct GetScreenAngle_t { - typedef GeckoAppShell Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getScreenAngle"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetScreenAngle() -> int32_t; - - struct GetScreenDepth_t { - typedef GeckoAppShell Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getScreenDepth"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetScreenDepth() -> int32_t; - - struct GetScreenOrientation_t { - typedef GeckoAppShell Owner; - typedef int16_t ReturnType; - typedef int16_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getScreenOrientation"; - static constexpr char signature[] = - "()S"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetScreenOrientation() -> int16_t; - - struct GetScreenSize_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getScreenSize"; - static constexpr char signature[] = - "()Landroid/graphics/Rect;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetScreenSize() -> mozilla::jni::Object::LocalRef; - - struct GetShowPasswordSetting_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getShowPasswordSetting"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetShowPasswordSetting() -> bool; - - struct GetSystemColors_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::IntArray::LocalRef ReturnType; - typedef mozilla::jni::IntArray::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getSystemColors"; - static constexpr char signature[] = - "()[I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetSystemColors() -> mozilla::jni::IntArray::LocalRef; - - struct HandleGeckoMessage_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "handleGeckoMessage"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/util/NativeJSContainer;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto HandleGeckoMessage(mozilla::jni::Object::Param) -> void; - - struct HandleUncaughtException_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Throwable::Param> Args; - static constexpr char name[] = "handleUncaughtException"; - static constexpr char signature[] = - "(Ljava/lang/Throwable;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::IGNORE; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto HandleUncaughtException(mozilla::jni::Throwable::Param) -> void; - - struct HideProgressDialog_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "hideProgressDialog"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto HideProgressDialog() -> void; - - struct InitCamera_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::IntArray::LocalRef ReturnType; - typedef mozilla::jni::IntArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "initCamera"; - static constexpr char signature[] = - "(Ljava/lang/String;III)[I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto InitCamera(mozilla::jni::String::Param, int32_t, int32_t, int32_t) -> mozilla::jni::IntArray::LocalRef; - - struct IsNetworkLinkKnown_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isNetworkLinkKnown"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsNetworkLinkKnown() -> bool; - - struct IsNetworkLinkUp_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isNetworkLinkUp"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsNetworkLinkUp() -> bool; - - struct IsTablet_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isTablet"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsTablet() -> bool; - - struct KillAnyZombies_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "killAnyZombies"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto KillAnyZombies() -> void; - - struct LoadPluginClass_t { - typedef GeckoAppShell Owner; - typedef mozilla::jni::Class::LocalRef ReturnType; - typedef mozilla::jni::Class::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "loadPluginClass"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto LoadPluginClass(mozilla::jni::String::Param, mozilla::jni::String::Param) -> mozilla::jni::Class::LocalRef; - - struct LockScreenOrientation_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "lockScreenOrientation"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto LockScreenOrientation(int32_t) -> void; - - struct MarkURIVisited_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "markUriVisited"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto MarkURIVisited(mozilla::jni::String::Param) -> void; - - struct MoveTaskToBack_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "moveTaskToBack"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto MoveTaskToBack() -> void; - - struct NotifyObservers_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "nativeNotifyObservers"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct NotifyAlertListener_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "notifyAlertListener"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct NotifyUriVisited_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "notifyUriVisited"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct NotifyWakeLockChanged_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "notifyWakeLockChanged"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto NotifyWakeLockChanged(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - - struct OnFullScreenPluginHidden_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onFullScreenPluginHidden"; - static constexpr char signature[] = - "(Landroid/view/View;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnLocationChanged_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - double, - double, - double, - float, - float, - float, - int64_t> Args; - static constexpr char name[] = "onLocationChanged"; - static constexpr char signature[] = - "(DDDFFFJ)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSensorChanged_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - float, - float, - float, - float, - int32_t, - int64_t> Args; - static constexpr char name[] = "onSensorChanged"; - static constexpr char signature[] = - "(IFFFFIJ)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OpenUriExternal_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "openUriExternal"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto OpenUriExternal(mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) -> bool; - - struct OpenWindowForNotification_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "openWindowForNotification"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto OpenWindowForNotification() -> void; - - struct PerformHapticFeedback_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "performHapticFeedback"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto PerformHapticFeedback(bool) -> void; - - struct RemoveFullScreenPluginView_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "removeFullScreenPluginView"; - static constexpr char signature[] = - "(Landroid/view/View;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto RemoveFullScreenPluginView(mozilla::jni::Object::Param) -> void; - - struct ReportJavaCrash_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Throwable::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "reportJavaCrash"; - static constexpr char signature[] = - "(Ljava/lang/Throwable;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct ScheduleRestart_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "scheduleRestart"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ScheduleRestart() -> void; - - struct SetAlarm_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "setAlarm"; - static constexpr char signature[] = - "(II)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetAlarm(int32_t, int32_t) -> bool; - - struct SetFullScreen_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "setFullScreen"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetFullScreen(bool) -> void; - - struct SetKeepScreenOn_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "setKeepScreenOn"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetKeepScreenOn(bool) -> void; - - struct SetScreenDepthOverride_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "setScreenDepthOverride"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetScreenDepthOverride(int32_t) -> void; - - struct SetURITitle_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "setUriTitle"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetURITitle(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - - struct ShowNotification_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "showNotification"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ShowNotification(mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - - struct SyncNotifyObservers_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "syncNotifyObservers"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct UnlockProfile_t { - typedef GeckoAppShell Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "unlockProfile"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto UnlockProfile() -> bool; - - struct UnlockScreenOrientation_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "unlockScreenOrientation"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto UnlockScreenOrientation() -> void; - - struct Vibrate_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int64_t> Args; - static constexpr char name[] = "vibrate"; - static constexpr char signature[] = - "(J)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Vibrate(int64_t) -> void; - - struct Vibrate2_t { - typedef GeckoAppShell Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::LongArray::Param, - int32_t> Args; - static constexpr char name[] = "vibrate"; - static constexpr char signature[] = - "([JI)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Vibrate(mozilla::jni::LongArray::Param, int32_t) -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoAppShell::CameraCallback : public mozilla::jni::ObjectBase<CameraCallback> -{ -public: - static const char name[]; - - explicit CameraCallback(const Context& ctx) : ObjectBase<CameraCallback>(ctx) {} - - struct OnFrameData_t { - typedef CameraCallback Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onFrameData"; - static constexpr char signature[] = - "(I[B)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - - template<class Impl> class Natives; -}; - -class GeckoBatteryManager : public mozilla::jni::ObjectBase<GeckoBatteryManager> -{ -public: - static const char name[]; - - explicit GeckoBatteryManager(const Context& ctx) : ObjectBase<GeckoBatteryManager>(ctx) {} - - struct OnBatteryChange_t { - typedef GeckoBatteryManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - double, - bool, - double> Args; - static constexpr char name[] = "onBatteryChange"; - static constexpr char signature[] = - "(DZD)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - - template<class Impl> class Natives; -}; - -class GeckoEditable : public mozilla::jni::ObjectBase<GeckoEditable> -{ -public: - static const char name[]; - - explicit GeckoEditable(const Context& ctx) : ObjectBase<GeckoEditable>(ctx) {} - - struct New_t { - typedef GeckoEditable Owner; - typedef GeckoEditable::LocalRef ReturnType; - typedef GeckoEditable::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(mozilla::jni::Object::Param) -> GeckoEditable::LocalRef; - - struct DisposeNative_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct NotifyIME_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "notifyIME"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto NotifyIME(int32_t) const -> void; - - struct NotifyIMEContext_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param, - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "notifyIMEContext"; - static constexpr char signature[] = - "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto NotifyIMEContext(int32_t, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) const -> void; - - struct OnDefaultKeyEvent_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onDefaultKeyEvent"; - static constexpr char signature[] = - "(Landroid/view/KeyEvent;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnDefaultKeyEvent(mozilla::jni::Object::Param) const -> void; - - struct OnImeAddCompositionRange_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - bool, - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "onImeAddCompositionRange"; - static constexpr char signature[] = - "(IIIIIZIII)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnImeReplaceText_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onImeReplaceText"; - static constexpr char signature[] = - "(IILjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnImeRequestCursorUpdates_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "onImeRequestCursorUpdates"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnImeSynchronize_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "onImeSynchronize"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnImeUpdateComposition_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "onImeUpdateComposition"; - static constexpr char signature[] = - "(II)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnKeyEvent_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - int64_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - bool, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onKeyEvent"; - static constexpr char signature[] = - "(IIIIJIIIIIZLandroid/view/KeyEvent;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct OnSelectionChange_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "onSelectionChange"; - static constexpr char signature[] = - "(II)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::IGNORE; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnSelectionChange(int32_t, int32_t) const -> void; - - struct OnTextChange_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "onTextChange"; - static constexpr char signature[] = - "(Ljava/lang/CharSequence;III)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::IGNORE; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnTextChange(mozilla::jni::String::Param, int32_t, int32_t, int32_t) const -> void; - - struct OnViewChange_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onViewChange"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnViewChange(mozilla::jni::Object::Param) const -> void; - - struct UpdateCompositionRects_t { - typedef GeckoEditable Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "updateCompositionRects"; - static constexpr char signature[] = - "([Landroid/graphics/RectF;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto UpdateCompositionRects(mozilla::jni::ObjectArray::Param) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoEditableListener : public mozilla::jni::ObjectBase<GeckoEditableListener> -{ -public: - static const char name[]; - - explicit GeckoEditableListener(const Context& ctx) : ObjectBase<GeckoEditableListener>(ctx) {} - - static const int32_t NOTIFY_IME_OF_BLUR = 2; - - static const int32_t NOTIFY_IME_OF_FOCUS = 1; - - static const int32_t NOTIFY_IME_OPEN_VKB = -2; - - static const int32_t NOTIFY_IME_REPLY_EVENT = -1; - - static const int32_t NOTIFY_IME_TO_CANCEL_COMPOSITION = 9; - - static const int32_t NOTIFY_IME_TO_COMMIT_COMPOSITION = 8; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class GeckoNetworkManager : public mozilla::jni::ObjectBase<GeckoNetworkManager> -{ -public: - static const char name[]; - - explicit GeckoNetworkManager(const Context& ctx) : ObjectBase<GeckoNetworkManager>(ctx) {} - - struct OnConnectionChanged_t { - typedef GeckoNetworkManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param, - bool, - int32_t> Args; - static constexpr char name[] = "onConnectionChanged"; - static constexpr char signature[] = - "(ILjava/lang/String;ZI)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnStatusChanged_t { - typedef GeckoNetworkManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onStatusChanged"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoScreenOrientation : public mozilla::jni::ObjectBase<GeckoScreenOrientation> -{ -public: - static const char name[]; - - explicit GeckoScreenOrientation(const Context& ctx) : ObjectBase<GeckoScreenOrientation>(ctx) {} - - struct OnOrientationChange_t { - typedef GeckoScreenOrientation Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int16_t, - int16_t> Args; - static constexpr char name[] = "onOrientationChange"; - static constexpr char signature[] = - "(SS)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoThread : public mozilla::jni::ObjectBase<GeckoThread> -{ -public: - static const char name[]; - - explicit GeckoThread(const Context& ctx) : ObjectBase<GeckoThread>(ctx) {} - - class State; - - struct CheckAndSetState_t { - typedef GeckoThread Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "checkAndSetState"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoThread$State;Lorg/mozilla/gecko/GeckoThread$State;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CheckAndSetState(mozilla::jni::Object::Param, mozilla::jni::Object::Param) -> bool; - - struct CreateServices_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "nativeCreateServices"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnPause_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "nativeOnPause"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnResume_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "nativeOnResume"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct PumpMessageLoop_t { - typedef GeckoThread Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "pumpMessageLoop"; - static constexpr char signature[] = - "(Landroid/os/Message;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto PumpMessageLoop(mozilla::jni::Object::Param) -> bool; - - struct RequestUiThreadCallback_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int64_t> Args; - static constexpr char name[] = "requestUiThreadCallback"; - static constexpr char signature[] = - "(J)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto RequestUiThreadCallback(int64_t) -> void; - - struct RunUiThreadCallback_t { - typedef GeckoThread Owner; - typedef int64_t ReturnType; - typedef int64_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "runUiThreadCallback"; - static constexpr char signature[] = - "()J"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct SetState_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "setState"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoThread$State;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetState(mozilla::jni::Object::Param) -> void; - - struct SpeculativeConnect_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "speculativeConnectNative"; - static constexpr char signature[] = - "(Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct WaitOnGecko_t { - typedef GeckoThread Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "waitOnGecko"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct ClsLoader_t { - typedef GeckoThread Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "clsLoader"; - static constexpr char signature[] = - "Ljava/lang/ClassLoader;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ClsLoader() -> mozilla::jni::Object::LocalRef; - - struct MsgQueue_t { - typedef GeckoThread Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "msgQueue"; - static constexpr char signature[] = - "Landroid/os/MessageQueue;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto MsgQueue() -> mozilla::jni::Object::LocalRef; - - static auto MsgQueue(mozilla::jni::Object::Param) -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoThread::State : public mozilla::jni::ObjectBase<State> -{ -public: - static const char name[]; - - explicit State(const Context& ctx) : ObjectBase<State>(ctx) {} - - struct EXITED_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "EXITED"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EXITED() -> State::LocalRef; - - struct EXITING_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "EXITING"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto EXITING() -> State::LocalRef; - - struct INITIAL_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "INITIAL"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto INITIAL() -> State::LocalRef; - - struct JNI_READY_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "JNI_READY"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto JNI_READY() -> State::LocalRef; - - struct LAUNCHED_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "LAUNCHED"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto LAUNCHED() -> State::LocalRef; - - struct LIBS_READY_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "LIBS_READY"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto LIBS_READY() -> State::LocalRef; - - struct MOZGLUE_READY_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "MOZGLUE_READY"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto MOZGLUE_READY() -> State::LocalRef; - - struct PROFILE_READY_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "PROFILE_READY"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto PROFILE_READY() -> State::LocalRef; - - struct RUNNING_t { - typedef State Owner; - typedef State::LocalRef ReturnType; - typedef State::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "RUNNING"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/GeckoThread$State;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto RUNNING() -> State::LocalRef; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class GeckoView : public mozilla::jni::ObjectBase<GeckoView> -{ -public: - static const char name[]; - - explicit GeckoView(const Context& ctx) : ObjectBase<GeckoView>(ctx) {} - - class Window; - - static const int32_t LOAD_DEFAULT = 0; - - static const int32_t LOAD_NEW_TAB = 1; - - static const int32_t LOAD_SWITCH_TAB = 2; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class GeckoView::Window : public mozilla::jni::ObjectBase<Window> -{ -public: - static const char name[]; - - explicit Window(const Context& ctx) : ObjectBase<Window>(ctx) {} - - struct Close_t { - typedef Window Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "close"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct DisposeNative_t { - typedef Window Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct LoadUri_t { - typedef Window Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "loadUri"; - static constexpr char signature[] = - "(Ljava/lang/String;I)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct Open_t { - typedef Window Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - Window::Param, - GeckoView::Param, - mozilla::jni::Object::Param, - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "open"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView$Window;Lorg/mozilla/gecko/GeckoView;Ljava/lang/Object;Ljava/lang/String;I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct Reattach_t { - typedef Window Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - GeckoView::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "reattach"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView;Ljava/lang/Object;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class PrefsHelper : public mozilla::jni::ObjectBase<PrefsHelper> -{ -public: - static const char name[]; - - explicit PrefsHelper(const Context& ctx) : ObjectBase<PrefsHelper>(ctx) {} - - struct CallPrefHandler_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - int32_t, - mozilla::jni::String::Param, - bool, - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "callPrefHandler"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/PrefsHelper$PrefHandler;ILjava/lang/String;ZILjava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CallPrefHandler(mozilla::jni::Object::Param, int32_t, mozilla::jni::String::Param, bool, int32_t, mozilla::jni::String::Param) -> void; - - struct AddObserver_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ObjectArray::Param, - mozilla::jni::Object::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "nativeAddObserver"; - static constexpr char signature[] = - "([Ljava/lang/String;Lorg/mozilla/gecko/PrefsHelper$PrefHandler;[Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct GetPrefs_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ObjectArray::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "nativeGetPrefs"; - static constexpr char signature[] = - "([Ljava/lang/String;Lorg/mozilla/gecko/PrefsHelper$PrefHandler;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct RemoveObserver_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "nativeRemoveObserver"; - static constexpr char signature[] = - "([Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct SetPref_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - bool, - int32_t, - bool, - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "nativeSetPref"; - static constexpr char signature[] = - "(Ljava/lang/String;ZIZILjava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnPrefChange_t { - typedef PrefsHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t, - bool, - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onPrefChange"; - static constexpr char signature[] = - "(Ljava/lang/String;IZILjava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto OnPrefChange(mozilla::jni::String::Param, int32_t, bool, int32_t, mozilla::jni::String::Param) -> void; - - static const int32_t PREF_BOOL = 1; - - static const int32_t PREF_FINISH = 0; - - static const int32_t PREF_INT = 2; - - static const int32_t PREF_INVALID = -1; - - static const int32_t PREF_STRING = 3; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class SurfaceTextureListener : public mozilla::jni::ObjectBase<SurfaceTextureListener> -{ -public: - static const char name[]; - - explicit SurfaceTextureListener(const Context& ctx) : ObjectBase<SurfaceTextureListener>(ctx) {} - - struct New_t { - typedef SurfaceTextureListener Owner; - typedef SurfaceTextureListener::LocalRef ReturnType; - typedef SurfaceTextureListener::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> SurfaceTextureListener::LocalRef; - - struct OnFrameAvailable_t { - typedef SurfaceTextureListener Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "nativeOnFrameAvailable"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class GeckoLayerClient : public mozilla::jni::ObjectBase<GeckoLayerClient> -{ -public: - static const char name[]; - - explicit GeckoLayerClient(const Context& ctx) : ObjectBase<GeckoLayerClient>(ctx) {} - - struct ContentDocumentChanged_t { - typedef GeckoLayerClient Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "contentDocumentChanged"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto ContentDocumentChanged() const -> void; - - struct CreateFrame_t { - typedef GeckoLayerClient Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "createFrame"; - static constexpr char signature[] = - "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CreateFrame() const -> mozilla::jni::Object::LocalRef; - - struct IsContentDocumentDisplayed_t { - typedef GeckoLayerClient Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isContentDocumentDisplayed"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto IsContentDocumentDisplayed() const -> bool; - - struct OnGeckoReady_t { - typedef GeckoLayerClient Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "onGeckoReady"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnGeckoReady() const -> void; - - struct SetFirstPaintViewport_t { - typedef GeckoLayerClient Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - float, - float, - float, - float, - float, - float, - float> Args; - static constexpr char name[] = "setFirstPaintViewport"; - static constexpr char signature[] = - "(FFFFFFF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SetFirstPaintViewport(float, float, float, float, float, float, float) const -> void; - - struct SyncFrameMetrics_t { - typedef GeckoLayerClient Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - float, - float, - float, - float, - float, - float, - float, - int32_t, - int32_t, - int32_t, - int32_t, - float, - bool, - int32_t> Args; - static constexpr char name[] = "syncFrameMetrics"; - static constexpr char signature[] = - "(FFFFFFFIIIIFZI)Lorg/mozilla/gecko/gfx/ViewTransform;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SyncFrameMetrics(float, float, float, float, float, float, float, int32_t, int32_t, int32_t, int32_t, float, bool, int32_t) const -> mozilla::jni::Object::LocalRef; - - struct SynthesizeNativeMouseEvent_t { - typedef GeckoLayerClient Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "synthesizeNativeMouseEvent"; - static constexpr char signature[] = - "(III)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SynthesizeNativeMouseEvent(int32_t, int32_t, int32_t) const -> void; - - struct SynthesizeNativeTouchPoint_t { - typedef GeckoLayerClient Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - double, - int32_t> Args; - static constexpr char name[] = "synthesizeNativeTouchPoint"; - static constexpr char signature[] = - "(IIIIDI)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SynthesizeNativeTouchPoint(int32_t, int32_t, int32_t, int32_t, double, int32_t) const -> void; - - struct ClearColor_t { - typedef GeckoLayerClient Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mClearColor"; - static constexpr char signature[] = - "I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto ClearColor() const -> int32_t; - - auto ClearColor(int32_t) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class ImmutableViewportMetrics : public mozilla::jni::ObjectBase<ImmutableViewportMetrics> -{ -public: - static const char name[]; - - explicit ImmutableViewportMetrics(const Context& ctx) : ObjectBase<ImmutableViewportMetrics>(ctx) {} - - struct New_t { - typedef ImmutableViewportMetrics Owner; - typedef ImmutableViewportMetrics::LocalRef ReturnType; - typedef ImmutableViewportMetrics::Param SetterType; - typedef mozilla::jni::Args< - float, - float, - float, - float, - float, - float, - float, - float, - float, - float, - int32_t, - int32_t, - float> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "(FFFFFFFFFFIIF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(float, float, float, float, float, float, float, float, float, float, int32_t, int32_t, float) -> ImmutableViewportMetrics::LocalRef; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - -}; - -class LayerRenderer : public mozilla::jni::ObjectBase<LayerRenderer> -{ -public: - static const char name[]; - - explicit LayerRenderer(const Context& ctx) : ObjectBase<LayerRenderer>(ctx) {} - - class Frame; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class LayerRenderer::Frame : public mozilla::jni::ObjectBase<Frame> -{ -public: - static const char name[]; - - explicit Frame(const Context& ctx) : ObjectBase<Frame>(ctx) {} - - struct BeginDrawing_t { - typedef Frame Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "beginDrawing"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto BeginDrawing() const -> void; - - struct EndDrawing_t { - typedef Frame Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "endDrawing"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto EndDrawing() const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class LayerView : public mozilla::jni::ObjectBase<LayerView> -{ -public: - static const char name[]; - - explicit LayerView(const Context& ctx) : ObjectBase<LayerView>(ctx) {} - - class Compositor; - - struct GetCompositor_t { - typedef LayerView Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCompositor"; - static constexpr char signature[] = - "()Ljava/lang/Object;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetCompositor() const -> mozilla::jni::Object::LocalRef; - - struct UpdateZoomedView_t { - typedef LayerView Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param> Args; - static constexpr char name[] = "updateZoomedView"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto UpdateZoomedView(mozilla::jni::ByteBuffer::Param) -> void; - - struct CompositorCreated_t { - typedef LayerView Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mCompositorCreated"; - static constexpr char signature[] = - "Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CompositorCreated() const -> bool; - - auto CompositorCreated(bool) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class LayerView::Compositor : public mozilla::jni::ObjectBase<Compositor> -{ -public: - static const char name[]; - - explicit Compositor(const Context& ctx) : ObjectBase<Compositor>(ctx) {} - - struct AttachToJava_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "attachToJava"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/gfx/GeckoLayerClient;Lorg/mozilla/gecko/gfx/NativePanZoomController;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct CreateCompositor_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "createCompositor"; - static constexpr char signature[] = - "(IILjava/lang/Object;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - struct Destroy_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "destroy"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Destroy() const -> void; - - struct DisposeNative_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSizeChanged_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "onSizeChanged"; - static constexpr char signature[] = - "(IIII)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct Reattach_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "reattach"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Reattach() const -> void; - - struct SyncInvalidateAndScheduleComposite_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "syncInvalidateAndScheduleComposite"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct SyncPauseCompositor_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "syncPauseCompositor"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct SyncResumeResizeCompositor_t { - typedef Compositor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "syncResumeResizeCompositor"; - static constexpr char signature[] = - "(IILjava/lang/Object;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class NativePanZoomController : public mozilla::jni::ObjectBase<NativePanZoomController> -{ -public: - static const char name[]; - - explicit NativePanZoomController(const Context& ctx) : ObjectBase<NativePanZoomController>(ctx) {} - - struct AdjustScrollForSurfaceShift_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - float, - float> Args; - static constexpr char name[] = "adjustScrollForSurfaceShift"; - static constexpr char signature[] = - "(FF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct Destroy_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "destroy"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Destroy() const -> void; - - struct DisposeNative_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct HandleMotionEvent_t { - typedef NativePanZoomController Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int64_t, - int32_t, - mozilla::jni::IntArray::Param, - mozilla::jni::FloatArray::Param, - mozilla::jni::FloatArray::Param, - mozilla::jni::FloatArray::Param, - mozilla::jni::FloatArray::Param, - mozilla::jni::FloatArray::Param, - mozilla::jni::FloatArray::Param> Args; - static constexpr char name[] = "handleMotionEvent"; - static constexpr char signature[] = - "(IIJI[I[F[F[F[F[F[F)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct HandleMotionEventVelocity_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int64_t, - float> Args; - static constexpr char name[] = "handleMotionEventVelocity"; - static constexpr char signature[] = - "(JF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct HandleMouseEvent_t { - typedef NativePanZoomController Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t, - int64_t, - int32_t, - float, - float, - int32_t> Args; - static constexpr char name[] = "handleMouseEvent"; - static constexpr char signature[] = - "(IJIFFI)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct HandleScrollEvent_t { - typedef NativePanZoomController Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int64_t, - int32_t, - float, - float, - float, - float> Args; - static constexpr char name[] = "handleScrollEvent"; - static constexpr char signature[] = - "(JIFFFF)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct SetIsLongpressEnabled_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "nativeSetIsLongpressEnabled"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnSelectionDragState_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "onSelectionDragState"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto OnSelectionDragState(bool) const -> void; - - struct SetScrollingRootContent_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "setScrollingRootContent"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SetScrollingRootContent(bool) const -> void; - - struct UpdateOverscrollOffset_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - float, - float> Args; - static constexpr char name[] = "updateOverscrollOffset"; - static constexpr char signature[] = - "(FF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto UpdateOverscrollOffset(float, float) const -> void; - - struct UpdateOverscrollVelocity_t { - typedef NativePanZoomController Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - float, - float> Args; - static constexpr char name[] = "updateOverscrollVelocity"; - static constexpr char signature[] = - "(FF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto UpdateOverscrollVelocity(float, float) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class ProgressiveUpdateData : public mozilla::jni::ObjectBase<ProgressiveUpdateData> -{ -public: - static const char name[]; - - explicit ProgressiveUpdateData(const Context& ctx) : ObjectBase<ProgressiveUpdateData>(ctx) {} - - struct New_t { - typedef ProgressiveUpdateData Owner; - typedef ProgressiveUpdateData::LocalRef ReturnType; - typedef ProgressiveUpdateData::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> ProgressiveUpdateData::LocalRef; - - struct SetViewport_t { - typedef ProgressiveUpdateData Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "setViewport"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SetViewport(mozilla::jni::Object::Param) const -> void; - - struct Abort_t { - typedef ProgressiveUpdateData Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "abort"; - static constexpr char signature[] = - "Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Abort() const -> bool; - - auto Abort(bool) const -> void; - - struct Scale_t { - typedef ProgressiveUpdateData Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "scale"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Scale() const -> float; - - auto Scale(float) const -> void; - - struct X_t { - typedef ProgressiveUpdateData Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "x"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto X() const -> float; - - auto X(float) const -> void; - - struct Y_t { - typedef ProgressiveUpdateData Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "y"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Y() const -> float; - - auto Y(float) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class StackScroller : public mozilla::jni::ObjectBase<StackScroller> -{ -public: - static const char name[]; - - explicit StackScroller(const Context& ctx) : ObjectBase<StackScroller>(ctx) {} - - struct New_t { - typedef StackScroller Owner; - typedef StackScroller::LocalRef ReturnType; - typedef StackScroller::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "(Landroid/content/Context;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(mozilla::jni::Object::Param, StackScroller::LocalRef*) -> nsresult; - - struct AbortAnimation_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "abortAnimation"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto AbortAnimation() const -> nsresult; - - struct ComputeScrollOffset_t { - typedef StackScroller Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int64_t> Args; - static constexpr char name[] = "computeScrollOffset"; - static constexpr char signature[] = - "(J)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto ComputeScrollOffset(int64_t, bool*) const -> nsresult; - - struct Fling_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int64_t> Args; - static constexpr char name[] = "fling"; - static constexpr char signature[] = - "(IIIIIIIIIIJ)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Fling(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int64_t) const -> nsresult; - - struct ForceFinished_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "forceFinished"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto ForceFinished(bool) const -> nsresult; - - struct GetCurrSpeedX_t { - typedef StackScroller Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrSpeedX"; - static constexpr char signature[] = - "()F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetCurrSpeedX(float*) const -> nsresult; - - struct GetCurrSpeedY_t { - typedef StackScroller Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrSpeedY"; - static constexpr char signature[] = - "()F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetCurrSpeedY(float*) const -> nsresult; - - struct GetCurrX_t { - typedef StackScroller Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrX"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetCurrX(int32_t*) const -> nsresult; - - struct GetCurrY_t { - typedef StackScroller Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getCurrY"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetCurrY(int32_t*) const -> nsresult; - - struct GetFinalX_t { - typedef StackScroller Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getFinalX"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetFinalX(int32_t*) const -> nsresult; - - struct GetFinalY_t { - typedef StackScroller Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getFinalY"; - static constexpr char signature[] = - "()I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto GetFinalY(int32_t*) const -> nsresult; - - struct InitContants_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "initContants"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto InitContants() -> nsresult; - - struct IsFinished_t { - typedef StackScroller Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isFinished"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto IsFinished(bool*) const -> nsresult; - - struct SetFinalX_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "setFinalX"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SetFinalX(int32_t) const -> nsresult; - - struct SpringBack_t { - typedef StackScroller Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - int64_t> Args; - static constexpr char name[] = "springBack"; - static constexpr char signature[] = - "(IIIIIIJ)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto SpringBack(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int64_t, bool*) const -> nsresult; - - struct StartScroll_t { - typedef StackScroller Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - int32_t, - int64_t, - int32_t> Args; - static constexpr char name[] = "startScroll"; - static constexpr char signature[] = - "(IIIIJI)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto StartScroll(int32_t, int32_t, int32_t, int32_t, int64_t, int32_t) const -> nsresult; - - struct ViscousFluid_t { - typedef StackScroller Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args< - float> Args; - static constexpr char name[] = "viscousFluid"; - static constexpr char signature[] = - "(F)F"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ViscousFluid(float, float*) -> nsresult; - - static const int32_t FLING_MODE = 1; - - static const int32_t SCROLL_MODE = 0; - - struct MFlywheel_t { - typedef StackScroller Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mFlywheel"; - static constexpr char signature[] = - "Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto MFlywheel(bool*) const -> nsresult; - - struct MMode_t { - typedef StackScroller Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mMode"; - static constexpr char signature[] = - "I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto MMode(int32_t*) const -> nsresult; - - auto MMode(int32_t) const -> nsresult; - - struct MScrollerX_t { - typedef StackScroller Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mScrollerX"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/gfx/StackScroller$SplineStackScroller;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto MScrollerX(mozilla::jni::Object::LocalRef*) const -> nsresult; - - struct MScrollerY_t { - typedef StackScroller Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "mScrollerY"; - static constexpr char signature[] = - "Lorg/mozilla/gecko/gfx/StackScroller$SplineStackScroller;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto MScrollerY(mozilla::jni::Object::LocalRef*) const -> nsresult; - - struct SViscousFluidNormalize_t { - typedef StackScroller Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "sViscousFluidNormalize"; - static constexpr char signature[] = - "F"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SViscousFluidNormalize(float*) -> nsresult; - - static auto SViscousFluidNormalize(float) -> nsresult; - - struct SViscousFluidScale_t { - typedef StackScroller Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "sViscousFluidScale"; - static constexpr char signature[] = - "F"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::NSRESULT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SViscousFluidScale(float*) -> nsresult; - - static auto SViscousFluidScale(float) -> nsresult; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class ViewTransform : public mozilla::jni::ObjectBase<ViewTransform> -{ -public: - static const char name[]; - - explicit ViewTransform(const Context& ctx) : ObjectBase<ViewTransform>(ctx) {} - - struct New_t { - typedef ViewTransform Owner; - typedef ViewTransform::LocalRef ReturnType; - typedef ViewTransform::Param SetterType; - typedef mozilla::jni::Args< - float, - float, - float> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "(FFF)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(float, float, float) -> ViewTransform::LocalRef; - - struct FixedLayerMarginBottom_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "fixedLayerMarginBottom"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto FixedLayerMarginBottom() const -> float; - - auto FixedLayerMarginBottom(float) const -> void; - - struct FixedLayerMarginLeft_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "fixedLayerMarginLeft"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto FixedLayerMarginLeft() const -> float; - - auto FixedLayerMarginLeft(float) const -> void; - - struct FixedLayerMarginRight_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "fixedLayerMarginRight"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto FixedLayerMarginRight() const -> float; - - auto FixedLayerMarginRight(float) const -> void; - - struct FixedLayerMarginTop_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "fixedLayerMarginTop"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto FixedLayerMarginTop() const -> float; - - auto FixedLayerMarginTop(float) const -> void; - - struct Height_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "height"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Height() const -> float; - - auto Height(float) const -> void; - - struct Scale_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "scale"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Scale() const -> float; - - auto Scale(float) const -> void; - - struct Width_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "width"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Width() const -> float; - - auto Width(float) const -> void; - - struct X_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "x"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto X() const -> float; - - auto X(float) const -> void; - - struct Y_t { - typedef ViewTransform Owner; - typedef float ReturnType; - typedef float SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "y"; - static constexpr char signature[] = - "F"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Y() const -> float; - - auto Y(float) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class Clipboard : public mozilla::jni::ObjectBase<Clipboard> -{ -public: - static const char name[]; - - explicit Clipboard(const Context& ctx) : ObjectBase<Clipboard>(ctx) {} - - struct ClearText_t { - typedef Clipboard Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "clearText"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ClearText() -> void; - - struct GetText_t { - typedef Clipboard Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getText"; - static constexpr char signature[] = - "()Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetText() -> mozilla::jni::String::LocalRef; - - struct HasText_t { - typedef Clipboard Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "hasText"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto HasText() -> bool; - - struct SetText_t { - typedef Clipboard Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "setText"; - static constexpr char signature[] = - "(Ljava/lang/CharSequence;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto SetText(mozilla::jni::String::Param) -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - -}; - -class HardwareCodecCapabilityUtils : public mozilla::jni::ObjectBase<HardwareCodecCapabilityUtils> -{ -public: - static const char name[]; - - explicit HardwareCodecCapabilityUtils(const Context& ctx) : ObjectBase<HardwareCodecCapabilityUtils>(ctx) {} - - struct HasHWVP9_t { - typedef HardwareCodecCapabilityUtils Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "HasHWVP9"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto HasHWVP9() -> bool; - - struct FindDecoderCodecInfoForMimeType_t { - typedef HardwareCodecCapabilityUtils Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "findDecoderCodecInfoForMimeType"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto FindDecoderCodecInfoForMimeType(mozilla::jni::String::Param) -> bool; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class NativeJSContainer : public mozilla::jni::ObjectBase<NativeJSContainer> -{ -public: - static const char name[]; - - explicit NativeJSContainer(const Context& ctx) : ObjectBase<NativeJSContainer>(ctx) {} - - struct New_t { - typedef NativeJSContainer Owner; - typedef NativeJSContainer::LocalRef ReturnType; - typedef NativeJSContainer::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeJSContainer::LocalRef; - - struct Clone2_t { - typedef NativeJSContainer Owner; - typedef NativeJSContainer::LocalRef ReturnType; - typedef NativeJSContainer::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "clone"; - static constexpr char signature[] = - "()Lorg/mozilla/gecko/util/NativeJSContainer;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct DisposeNative_t { - typedef NativeJSContainer Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - - template<class Impl> class Natives; -}; - -class NativeJSObject : public mozilla::jni::ObjectBase<NativeJSObject> -{ -public: - static const char name[]; - - explicit NativeJSObject(const Context& ctx) : ObjectBase<NativeJSObject>(ctx) {} - - struct New_t { - typedef NativeJSObject Owner; - typedef NativeJSObject::LocalRef ReturnType; - typedef NativeJSObject::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeJSObject::LocalRef; - - struct DisposeNative_t { - typedef NativeJSObject Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto DisposeNative() const -> void; - - struct GetBoolean_t { - typedef NativeJSObject Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getBoolean"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetBooleanArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::BooleanArray::LocalRef ReturnType; - typedef mozilla::jni::BooleanArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getBooleanArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetBundle_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getBundle"; - static constexpr char signature[] = - "(Ljava/lang/String;)Landroid/os/Bundle;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetBundleArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getBundleArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[Landroid/os/Bundle;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetDouble_t { - typedef NativeJSObject Owner; - typedef double ReturnType; - typedef double SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getDouble"; - static constexpr char signature[] = - "(Ljava/lang/String;)D"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetDoubleArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::DoubleArray::LocalRef ReturnType; - typedef mozilla::jni::DoubleArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getDoubleArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[D"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetInt_t { - typedef NativeJSObject Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getInt"; - static constexpr char signature[] = - "(Ljava/lang/String;)I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetIntArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::IntArray::LocalRef ReturnType; - typedef mozilla::jni::IntArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getIntArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetObject_t { - typedef NativeJSObject Owner; - typedef NativeJSObject::LocalRef ReturnType; - typedef NativeJSObject::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getObject"; - static constexpr char signature[] = - "(Ljava/lang/String;)Lorg/mozilla/gecko/util/NativeJSObject;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetObjectArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getObjectArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[Lorg/mozilla/gecko/util/NativeJSObject;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetString_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getString"; - static constexpr char signature[] = - "(Ljava/lang/String;)Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetStringArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "getStringArray"; - static constexpr char signature[] = - "(Ljava/lang/String;)[Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct Has_t { - typedef NativeJSObject Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "has"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptBoolean_t { - typedef NativeJSObject Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - bool> Args; - static constexpr char name[] = "optBoolean"; - static constexpr char signature[] = - "(Ljava/lang/String;Z)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptBooleanArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::BooleanArray::LocalRef ReturnType; - typedef mozilla::jni::BooleanArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::BooleanArray::Param> Args; - static constexpr char name[] = "optBooleanArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[Z)[Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptBundle_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "optBundle"; - static constexpr char signature[] = - "(Ljava/lang/String;Landroid/os/Bundle;)Landroid/os/Bundle;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptBundleArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "optBundleArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[Landroid/os/Bundle;)[Landroid/os/Bundle;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptDouble_t { - typedef NativeJSObject Owner; - typedef double ReturnType; - typedef double SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - double> Args; - static constexpr char name[] = "optDouble"; - static constexpr char signature[] = - "(Ljava/lang/String;D)D"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptDoubleArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::DoubleArray::LocalRef ReturnType; - typedef mozilla::jni::DoubleArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::DoubleArray::Param> Args; - static constexpr char name[] = "optDoubleArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[D)[D"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptInt_t { - typedef NativeJSObject Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "optInt"; - static constexpr char signature[] = - "(Ljava/lang/String;I)I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptIntArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::IntArray::LocalRef ReturnType; - typedef mozilla::jni::IntArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::IntArray::Param> Args; - static constexpr char name[] = "optIntArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[I)[I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptObject_t { - typedef NativeJSObject Owner; - typedef NativeJSObject::LocalRef ReturnType; - typedef NativeJSObject::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - NativeJSObject::Param> Args; - static constexpr char name[] = "optObject"; - static constexpr char signature[] = - "(Ljava/lang/String;Lorg/mozilla/gecko/util/NativeJSObject;)Lorg/mozilla/gecko/util/NativeJSObject;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptObjectArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "optObjectArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[Lorg/mozilla/gecko/util/NativeJSObject;)[Lorg/mozilla/gecko/util/NativeJSObject;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptString_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "optString"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OptStringArray_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::ObjectArray::LocalRef ReturnType; - typedef mozilla::jni::ObjectArray::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "optStringArray"; - static constexpr char signature[] = - "(Ljava/lang/String;[Ljava/lang/String;)[Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct ToBundle_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "toBundle"; - static constexpr char signature[] = - "()Landroid/os/Bundle;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct ToString_t { - typedef NativeJSObject Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "toString"; - static constexpr char signature[] = - "()Ljava/lang/String;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - - template<class Impl> class Natives; -}; - -} /* java */ -} /* mozilla */ -#endif // GeneratedJNIWrappers_h diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp deleted file mode 100644 index d92cdb526..000000000 --- a/widget/android/GfxInfo.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "GfxInfo.h" -#include "GLContext.h" -#include "GLContextProvider.h" -#include "nsUnicharUtils.h" -#include "prenv.h" -#include "prprf.h" -#include "nsHashKeys.h" -#include "nsVersionComparator.h" -#include "AndroidBridge.h" -#include "nsIWindowWatcher.h" -#include "nsServiceManagerUtils.h" - -namespace mozilla { -namespace widget { - -class GfxInfo::GLStrings -{ - nsCString mVendor; - nsCString mRenderer; - nsCString mVersion; - bool mReady; - -public: - GLStrings() - : mReady(false) - {} - - const nsCString& Vendor() { - EnsureInitialized(); - return mVendor; - } - - // This spoofed value wins, even if the environment variable - // MOZ_GFX_SPOOF_GL_VENDOR was set. - void SpoofVendor(const nsCString& s) { - mVendor = s; - } - - const nsCString& Renderer() { - EnsureInitialized(); - return mRenderer; - } - - // This spoofed value wins, even if the environment variable - // MOZ_GFX_SPOOF_GL_RENDERER was set. - void SpoofRenderer(const nsCString& s) { - mRenderer = s; - } - - const nsCString& Version() { - EnsureInitialized(); - return mVersion; - } - - // This spoofed value wins, even if the environment variable - // MOZ_GFX_SPOOF_GL_VERSION was set. - void SpoofVersion(const nsCString& s) { - mVersion = s; - } - - void EnsureInitialized() { - if (mReady) { - return; - } - - RefPtr<gl::GLContext> gl; - nsCString discardFailureId; - gl = gl::GLContextProvider::CreateHeadless(gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE, - &discardFailureId); - - if (!gl) { - // Setting mReady to true here means that we won't retry. Everything will - // remain blacklisted forever. Ideally, we would like to update that once - // any GLContext is successfully created, like the compositor's GLContext. - mReady = true; - return; - } - - gl->MakeCurrent(); - - if (mVendor.IsEmpty()) { - const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR"); - if (spoofedVendor) { - mVendor.Assign(spoofedVendor); - } else { - mVendor.Assign((const char*)gl->fGetString(LOCAL_GL_VENDOR)); - } - } - - if (mRenderer.IsEmpty()) { - const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER"); - if (spoofedRenderer) { - mRenderer.Assign(spoofedRenderer); - } else { - mRenderer.Assign((const char*)gl->fGetString(LOCAL_GL_RENDERER)); - } - } - - if (mVersion.IsEmpty()) { - const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION"); - if (spoofedVersion) { - mVersion.Assign(spoofedVersion); - } else { - mVersion.Assign((const char*)gl->fGetString(LOCAL_GL_VERSION)); - } - } - - mReady = true; - } -}; - -#ifdef DEBUG -NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) -#endif - -GfxInfo::GfxInfo() - : mInitialized(false) - , mGLStrings(new GLStrings) - , mOSVersionInteger(0) - , mSDKVersion(0) -{ -} - -GfxInfo::~GfxInfo() -{ -} - -/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization - * has occurred because they depend on it for information. (See bug 591561) */ -nsresult -GfxInfo::GetD2DEnabled(bool *aEnabled) -{ - return NS_ERROR_FAILURE; -} - -nsresult -GfxInfo::GetDWriteEnabled(bool *aEnabled) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams) -{ - return NS_ERROR_FAILURE; -} - -void -GfxInfo::EnsureInitialized() -{ - if (mInitialized) - return; - - if (!mozilla::AndroidBridge::Bridge()) { - gfxWarning() << "AndroidBridge missing during initialization"; - return; - } - - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", mModel)) { - mAdapterDescription.AppendPrintf("Model: %s", NS_LossyConvertUTF16toASCII(mModel).get()); - } - - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", mProduct)) { - mAdapterDescription.AppendPrintf(", Product: %s", NS_LossyConvertUTF16toASCII(mProduct).get()); - } - - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", mManufacturer)) { - mAdapterDescription.AppendPrintf(", Manufacturer: %s", NS_LossyConvertUTF16toASCII(mManufacturer).get()); - } - - if (mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &mSDKVersion)) { - // the HARDWARE field isn't available on Android SDK < 8, but we require 9+ anyway. - MOZ_ASSERT(mSDKVersion >= 8); - if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", mHardware)) { - mAdapterDescription.AppendPrintf(", Hardware: %s", NS_LossyConvertUTF16toASCII(mHardware).get()); - } - } else { - mSDKVersion = 0; - } - - nsString release; - mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", release); - mOSVersion = NS_LossyConvertUTF16toASCII(release); - - mOSVersionInteger = 0; - char a[5], b[5], c[5], d[5]; - SplitDriverVersion(mOSVersion.get(), a, b, c, d); - uint8_t na = atoi(a); - uint8_t nb = atoi(b); - uint8_t nc = atoi(c); - uint8_t nd = atoi(d); - - mOSVersionInteger = (uint32_t(na) << 24) | - (uint32_t(nb) << 16) | - (uint32_t(nc) << 8) | - uint32_t(nd); - - mAdapterDescription.AppendPrintf(", OpenGL: %s -- %s -- %s", - mGLStrings->Vendor().get(), - mGLStrings->Renderer().get(), - mGLStrings->Version().get()); - - AddCrashReportAnnotations(); - - mInitialized = true; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription) -{ - EnsureInitialized(); - aAdapterDescription = NS_ConvertASCIItoUTF16(mAdapterDescription); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM) -{ - EnsureInitialized(); - aAdapterRAM.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver) -{ - EnsureInitialized(); - aAdapterDriver.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) -{ - EnsureInitialized(); - aAdapterDriverVersion = NS_ConvertASCIItoUTF16(mGLStrings->Version()); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate) -{ - EnsureInitialized(); - aAdapterDriverDate.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) -{ - EnsureInitialized(); - aAdapterVendorID = NS_ConvertASCIItoUTF16(mGLStrings->Vendor()); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) -{ - EnsureInitialized(); - aAdapterDeviceID = NS_ConvertASCIItoUTF16(mGLStrings->Renderer()); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterSubsysID(nsAString & aAdapterSubsysID) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterSubsysID2(nsAString & aAdapterSubsysID) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) -{ - EnsureInitialized(); - return NS_ERROR_FAILURE; -} - -void -GfxInfo::AddCrashReportAnnotations() -{ - /*** STUB ***/ -} - -const nsTArray<GfxDriverInfo>& -GfxInfo::GetGfxDriverInfo() -{ - if (mDriverInfo->IsEmpty()) { - APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android, - (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices, - nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK, - DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions, - "FEATURE_OK_FORCE_OPENGL" ); - } - - return *mDriverInfo; -} - -nsresult -GfxInfo::GetFeatureStatusImpl(int32_t aFeature, - int32_t *aStatus, - nsAString &aSuggestedDriverVersion, - const nsTArray<GfxDriverInfo>& aDriverInfo, - nsACString &aFailureId, - OperatingSystem* aOS /* = nullptr */) -{ - NS_ENSURE_ARG_POINTER(aStatus); - aSuggestedDriverVersion.SetIsVoid(true); - *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN; - OperatingSystem os = mOS; - if (aOS) - *aOS = os; - - if (mShutdownOccurred) { - return NS_OK; - } - - // OpenGL layers are never blacklisted on Android. - // This early return is so we avoid potentially slow - // GLStrings initialization on startup when we initialize GL layers. - if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) { - *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; - return NS_OK; - } - - EnsureInitialized(); - - if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - return NS_OK; - } - - // Don't evaluate special cases when evaluating the downloaded blocklist. - if (aDriverInfo.IsEmpty()) { - if (aFeature == nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION) { - if (mSDKVersion < 11) { - // It's slower than software due to not having a compositing fast path - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION; - aFailureId = "FEATURE_FAILURE_CANVAS_2D_SDK"; - } else if (mGLStrings->Renderer().Find("Vivante GC1000") != -1) { - // Blocklist Vivante GC1000. See bug 1248183. - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILED_CANVAS_2D_HW"; - } else { - *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; - } - return NS_OK; - } - - if (aFeature == FEATURE_WEBGL_OPENGL) { - if (mGLStrings->Renderer().Find("Adreno 200") != -1 || - mGLStrings->Renderer().Find("Adreno 205") != -1) - { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_ADRENO_20x"; - return NS_OK; - } - - if (mHardware.EqualsLiteral("ville")) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_VILLE"; - return NS_OK; - } - } - - if (aFeature == FEATURE_STAGEFRIGHT) { - NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer); - NS_LossyConvertUTF16toASCII cModel(mModel); - NS_LossyConvertUTF16toASCII cHardware(mHardware); - - if (cHardware.EqualsLiteral("antares") || - cHardware.EqualsLiteral("harmony") || - cHardware.EqualsLiteral("picasso") || - cHardware.EqualsLiteral("picasso_e") || - cHardware.EqualsLiteral("ventana") || - cHardware.EqualsLiteral("rk30board")) - { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_STAGE_HW"; - return NS_OK; - } - - if (CompareVersions(mOSVersion.get(), "4.1.0") < 0) - { - // Whitelist: - // All Samsung ICS devices, except for: - // Samsung SGH-I717 (Bug 845729) - // Samsung SGH-I727 (Bug 845729) - // Samsung SGH-I757 (Bug 845729) - // All Galaxy nexus ICS devices - // Sony Xperia Ion (LT28) ICS devices - bool isWhitelisted = - cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) || - cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) || - cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon - - if (cModel.Find("SGH-I717", true) != -1 || - cModel.Find("SGH-I727", true) != -1 || - cModel.Find("SGH-I757", true) != -1) - { - isWhitelisted = false; - } - - if (!isWhitelisted) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_4_1_HW"; - return NS_OK; - } - } - else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0) - { - // Whitelist: - // All JB phones except for those in blocklist below - // Blocklist: - // Samsung devices from bug 812881 and 853522. - // Motorola XT890 from bug 882342. - bool isBlocklisted = - cModel.Find("GT-P3100", true) != -1 || - cModel.Find("GT-P3110", true) != -1 || - cModel.Find("GT-P3113", true) != -1 || - cModel.Find("GT-P5100", true) != -1 || - cModel.Find("GT-P5110", true) != -1 || - cModel.Find("GT-P5113", true) != -1 || - cModel.Find("XT890", true) != -1; - - if (isBlocklisted) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_4_2_HW"; - return NS_OK; - } - } - else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0) - { - // Blocklist all Sony devices - if (cManufacturer.Find("Sony", true) != -1) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_4_3_SONY"; - return NS_OK; - } - } - } - - if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_ENCODE) { - if (mozilla::AndroidBridge::Bridge()) { - *aStatus = mozilla::AndroidBridge::Bridge()->GetHWEncoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_WEBRTC_ENCODE"; - return NS_OK; - } - } - if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_DECODE) { - if (mozilla::AndroidBridge::Bridge()) { - *aStatus = mozilla::AndroidBridge::Bridge()->GetHWDecoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_WEBRTC_DECODE"; - return NS_OK; - } - } - - if (aFeature == FEATURE_VP8_HW_DECODE || aFeature == FEATURE_VP9_HW_DECODE) { - NS_LossyConvertUTF16toASCII model(mModel); - bool isBlocked = - // GIFV crash, see bug 1232911. - model.Equals("GT-N8013", nsCaseInsensitiveCStringComparator()); - - if (isBlocked) { - *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE; - aFailureId = "FEATURE_FAILURE_VPx"; - } else { - *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; - } - return NS_OK; - } - } - - return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, &os); -} - -#ifdef DEBUG - -// Implement nsIGfxInfoDebug - -NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID) -{ - mGLStrings->SpoofVendor(NS_LossyConvertUTF16toASCII(aVendorID)); - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID) -{ - mGLStrings->SpoofRenderer(NS_LossyConvertUTF16toASCII(aDeviceID)); - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion) -{ - mGLStrings->SpoofVersion(NS_LossyConvertUTF16toASCII(aDriverVersion)); - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion) -{ - EnsureInitialized(); - mOSVersion = aVersion; - return NS_OK; -} - -#endif - -nsString GfxInfo::Model() -{ - EnsureInitialized(); - return mModel; -} - -nsString GfxInfo::Hardware() -{ - EnsureInitialized(); - return mHardware; -} - -nsString GfxInfo::Product() -{ - EnsureInitialized(); - return mProduct; -} - -nsString GfxInfo::Manufacturer() -{ - EnsureInitialized(); - return mManufacturer; -} - -uint32_t GfxInfo::OperatingSystemVersion() -{ - EnsureInitialized(); - return mOSVersionInteger; -} - -} -} diff --git a/widget/android/GfxInfo.h b/widget/android/GfxInfo.h deleted file mode 100644 index a3b06099b..000000000 --- a/widget/android/GfxInfo.h +++ /dev/null @@ -1,102 +0,0 @@ -/* vim: se cin sw=2 ts=2 et : */ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __mozilla_widget_GfxInfo_h__ -#define __mozilla_widget_GfxInfo_h__ - -#include "GfxInfoBase.h" -#include "GfxDriverInfo.h" - -#include "nsString.h" -#include "mozilla/UniquePtr.h" - -namespace mozilla { - -namespace widget { - -class GfxInfo : public GfxInfoBase -{ -private: - ~GfxInfo(); - -public: - GfxInfo(); - - // We only declare the subset of nsIGfxInfo that we actually implement. The - // rest is brought forward from GfxInfoBase. - NS_IMETHOD GetD2DEnabled(bool *aD2DEnabled) override; - NS_IMETHOD GetDWriteEnabled(bool *aDWriteEnabled) override; - NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion) override; - NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams) override; - NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription) override; - NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver) override; - NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID) override; - NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID) override; - NS_IMETHOD GetAdapterSubsysID(nsAString & aAdapterSubsysID) override; - NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM) override; - NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) override; - NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate) override; - NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription) override; - NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver) override; - NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID) override; - NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID) override; - NS_IMETHOD GetAdapterSubsysID2(nsAString & aAdapterSubsysID) override; - NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM) override; - NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion) override; - NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate) override; - NS_IMETHOD GetIsGPU2Active(bool *aIsGPU2Active) override; - using GfxInfoBase::GetFeatureStatus; - using GfxInfoBase::GetFeatureSuggestedDriverVersion; - using GfxInfoBase::GetWebGLParameter; - - void EnsureInitialized(); - - virtual nsString Model() override; - virtual nsString Hardware() override; - virtual nsString Product() override; - virtual nsString Manufacturer() override; - -#ifdef DEBUG - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIGFXINFODEBUG -#endif - - virtual uint32_t OperatingSystemVersion() override; - -protected: - - virtual nsresult GetFeatureStatusImpl(int32_t aFeature, - int32_t *aStatus, - nsAString & aSuggestedDriverVersion, - const nsTArray<GfxDriverInfo>& aDriverInfo, - nsACString &aFailureId, - OperatingSystem* aOS = nullptr) override; - virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() override; - -private: - - void AddCrashReportAnnotations(); - - bool mInitialized; - - class GLStrings; - UniquePtr<GLStrings> mGLStrings; - - nsCString mAdapterDescription; - - OperatingSystem mOS; - - nsString mModel, mHardware, mManufacturer, mProduct; - nsCString mOSVersion; - uint32_t mOSVersionInteger; - int32_t mSDKVersion; -}; - -} // namespace widget -} // namespace mozilla - -#endif /* __mozilla_widget_GfxInfo_h__ */ diff --git a/widget/android/NativeJSContainer.cpp b/widget/android/NativeJSContainer.cpp deleted file mode 100644 index b8c434656..000000000 --- a/widget/android/NativeJSContainer.cpp +++ /dev/null @@ -1,881 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "NativeJSContainer.h" - -#include <jni.h> - -#include "Bundle.h" -#include "GeneratedJNINatives.h" -#include "MainThreadUtils.h" -#include "jsapi.h" -#include "nsJSUtils.h" - -#include <mozilla/Vector.h> -#include <mozilla/jni/Accessors.h> -#include <mozilla/jni/Refs.h> -#include <mozilla/jni/Utils.h> - -/** - * NativeJSContainer.cpp implements the native methods in both - * NativeJSContainer and NativeJSObject, using JSAPI to retrieve values from a - * JSObject and using JNI to return those values to Java code. - */ - -namespace mozilla { -namespace widget { - -namespace { - -bool CheckThread() -{ - if (!NS_IsMainThread()) { - jni::ThrowException("java/lang/IllegalThreadStateException", - "Not on Gecko thread"); - return false; - } - return true; -} - -template<class C, typename T> bool -CheckJNIArgument(const jni::Ref<C, T>& arg) -{ - if (!arg) { - jni::ThrowException("java/lang/IllegalArgumentException", - "Null argument"); - } - return !!arg; -} - -nsresult -CheckSDKCall(nsresult rv) -{ - if (NS_FAILED(rv)) { - jni::ThrowException("java/lang/UnsupportedOperationException", - "SDK JNI call failed"); - } - return rv; -} - -// Convert a JNI string to a char16_t string that JSAPI expects. -class JSJNIString final -{ - JNIEnv* const mEnv; - jni::String::Param mJNIString; - const char16_t* const mJSString; - -public: - JSJNIString(JNIEnv* env, jni::String::Param str) - : mEnv(env) - , mJNIString(str) - , mJSString(!str ? nullptr : reinterpret_cast<const char16_t*>( - mEnv->GetStringChars(str.Get(), nullptr))) - {} - - ~JSJNIString() { - if (mJNIString) { - mEnv->ReleaseStringChars(mJNIString.Get(), - reinterpret_cast<const jchar*>(mJSString)); - } - } - - operator const char16_t*() const { - return mJSString; - } - - size_t Length() const { - return static_cast<size_t>(mEnv->GetStringLength(mJNIString.Get())); - } -}; - -} // namepsace - -class NativeJSContainerImpl final - : public NativeJSObject::Natives<NativeJSContainerImpl> - , public NativeJSContainer::Natives<NativeJSContainerImpl> -{ - typedef NativeJSContainerImpl Self; - typedef NativeJSContainer::Natives<NativeJSContainerImpl> ContainerBase; - typedef NativeJSObject::Natives<NativeJSContainerImpl> ObjectBase; - - typedef JS::PersistentRooted<JSObject*> PersistentObject; - - JNIEnv* const mEnv; - // Context that the object is valid in - JSContext* const mJSContext; - // Root JS object - PersistentObject mJSObject; - // Children objects - Vector<NativeJSObject::GlobalRef, 0> mChildren; - - bool CheckObject() const - { - if (!mJSObject) { - jni::ThrowException("java/lang/NullPointerException", - "Null JSObject"); - } - return !!mJSObject; - } - - bool CheckJSCall(bool result) const - { - if (!result) { - JS_ClearPendingException(mJSContext); - jni::ThrowException("java/lang/UnsupportedOperationException", - "JSAPI call failed"); - } - return result; - } - - // Check that a JS Value contains a particular property type as indicaed by - // the property's InValue method (e.g. StringProperty::InValue). - bool CheckProperty(bool (Self::*InValue)(JS::HandleValue) const, - JS::HandleValue val) const - { - if (!(this->*InValue)(val)) { - // XXX this can happen when converting a double array inside a - // Bundle, because double arrays can be misidentified as an int - // array. The workaround is to add a dummy first element to the - // array that is a floating point value, i.e. [0.5, ...]. - jni::ThrowException( - "org/mozilla/gecko/util/NativeJSObject$InvalidPropertyException", - "Property type mismatch"); - return false; - } - return true; - } - - // Primitive properties - - template<bool (JS::Value::*IsType)() const> bool - PrimitiveInValue(JS::HandleValue val) const - { - return (static_cast<const JS::Value&>(val).*IsType)(); - } - - template<typename U, U (JS::Value::*ToType)() const> U - PrimitiveFromValue(JS::HandleValue val) const - { - return (static_cast<const JS::Value&>(val).*ToType)(); - } - - template<class Prop> typename Prop::NativeArray - PrimitiveNewArray(JS::HandleObject array, size_t length) const - { - typedef typename Prop::JNIType JNIType; - - // Fill up a temporary buffer for our array, then use - // JNIEnv::Set*ArrayRegion to fill out array in one go. - - UniquePtr<JNIType[]> buffer = MakeUnique<JNIType[]>(length); - for (size_t i = 0; i < length; i++) { - JS::RootedValue elem(mJSContext); - if (!CheckJSCall(JS_GetElement(mJSContext, array, i, &elem)) || - !CheckProperty(Prop::InValue, elem)) { - return nullptr; - } - buffer[i] = JNIType((this->*Prop::FromValue)(elem)); - } - auto jarray = Prop::NativeArray::Adopt( - mEnv, (mEnv->*Prop::NewJNIArray)(length)); - if (!jarray) { - return nullptr; - } - (mEnv->*Prop::SetJNIArrayRegion)( - jarray.Get(), 0, length, buffer.get()); - if (mEnv->ExceptionCheck()) { - return nullptr; - } - return jarray; - } - - template<typename U, typename UA, typename V, typename VA, - bool (JS::Value::*IsType)() const, - U (JS::Value::*ToType)() const, - VA (JNIEnv::*NewArray_)(jsize), - void (JNIEnv::*SetArrayRegion_)(VA, jsize, jsize, const V*)> - struct PrimitiveProperty - { - // C++ type for a primitive property (e.g. bool) - typedef U NativeType; - // C++ type for the fallback value used in opt* methods - typedef U NativeFallback; - // Type for an array of the primitive type (e.g. BooleanArray::LocalRef) - typedef typename UA::LocalRef NativeArray; - // Type for the fallback value used in opt*Array methods - typedef const typename UA::Ref ArrayFallback; - // JNI type (e.g. jboolean) - typedef V JNIType; - - // JNIEnv function to create a new JNI array of the primiive type - typedef decltype(NewArray_) NewJNIArray_t; - static constexpr NewJNIArray_t NewJNIArray = NewArray_; - - // JNIEnv function to fill a JNI array of the primiive type - typedef decltype(SetArrayRegion_) SetJNIArrayRegion_t; - static constexpr SetJNIArrayRegion_t SetJNIArrayRegion = SetArrayRegion_; - - // Function to determine if a JS Value contains the primitive type - typedef decltype(&Self::PrimitiveInValue<IsType>) InValue_t; - static constexpr InValue_t InValue = &Self::PrimitiveInValue<IsType>; - - // Function to convert a JS Value to the primitive type - typedef decltype(&Self::PrimitiveFromValue<U, ToType>) FromValue_t; - static constexpr FromValue_t FromValue - = &Self::PrimitiveFromValue<U, ToType>; - - // Function to convert a JS array to a JNI array - typedef decltype(&Self::PrimitiveNewArray<PrimitiveProperty>) NewArray_t; - static constexpr NewArray_t NewArray - = &Self::PrimitiveNewArray<PrimitiveProperty>; - }; - - // String properties - - bool StringInValue(JS::HandleValue val) const - { - return val.isString(); - } - - jni::String::LocalRef - StringFromValue(const JS::HandleString str) const - { - nsAutoJSString autoStr; - if (!CheckJSCall(autoStr.init(mJSContext, str))) { - return nullptr; - } - // StringParam can automatically convert a nsString to jstring. - return jni::StringParam(autoStr, mEnv); - } - - jni::String::LocalRef - StringFromValue(JS::HandleValue val) - { - const JS::RootedString str(mJSContext, val.toString()); - return StringFromValue(str); - } - - // Bundle properties - - sdk::Bundle::LocalRef - BundleFromValue(const JS::HandleObject obj) - { - JS::Rooted<JS::IdVector> ids(mJSContext, JS::IdVector(mJSContext)); - if (!CheckJSCall(JS_Enumerate(mJSContext, obj, &ids))) { - return nullptr; - } - - const size_t length = ids.length(); - sdk::Bundle::LocalRef newBundle(mEnv); - NS_ENSURE_SUCCESS(CheckSDKCall( - sdk::Bundle::New(length, &newBundle)), nullptr); - - // Iterate through each property of the JS object. For each property, - // determine its type from a list of supported types, and convert that - // proeprty to the supported type. - - for (size_t i = 0; i < ids.length(); i++) { - const JS::RootedId id(mJSContext, ids[i]); - JS::RootedValue idVal(mJSContext); - if (!CheckJSCall(JS_IdToValue(mJSContext, id, &idVal))) { - return nullptr; - } - - const JS::RootedString idStr(mJSContext, - JS::ToString(mJSContext, idVal)); - if (!CheckJSCall(!!idStr)) { - return nullptr; - } - - jni::String::LocalRef name = StringFromValue(idStr); - JS::RootedValue val(mJSContext); - if (!name || - !CheckJSCall(JS_GetPropertyById(mJSContext, obj, id, &val))) { - return nullptr; - } - -#define PUT_IN_BUNDLE_IF_TYPE_IS(TYPE) \ - if ((this->*TYPE##Property::InValue)(val)) { \ - auto jval = (this->*TYPE##Property::FromValue)(val); \ - if (mEnv->ExceptionCheck()) { \ - return nullptr; \ - } \ - NS_ENSURE_SUCCESS(CheckSDKCall( \ - newBundle->Put##TYPE(name, jval)), nullptr); \ - continue; \ - } \ - ((void) 0) // Accommodate trailing semicolon. - - // Scalar values are faster to check, so check them first. - PUT_IN_BUNDLE_IF_TYPE_IS(Boolean); - // Int can be casted to double, so check int first. - PUT_IN_BUNDLE_IF_TYPE_IS(Int); - PUT_IN_BUNDLE_IF_TYPE_IS(Double); - PUT_IN_BUNDLE_IF_TYPE_IS(String); - // There's no "putObject", so don't check ObjectProperty - - // Check for array types if scalar checks all failed. - // XXX empty arrays are treated as boolean arrays. Workaround is - // to always have a dummy element to create a non-empty array. - PUT_IN_BUNDLE_IF_TYPE_IS(BooleanArray); - // XXX because we only check the first element of an array, - // a double array can potentially be seen as an int array. - // When that happens, the Bundle conversion will fail. - PUT_IN_BUNDLE_IF_TYPE_IS(IntArray); - PUT_IN_BUNDLE_IF_TYPE_IS(DoubleArray); - PUT_IN_BUNDLE_IF_TYPE_IS(StringArray); - // There's no "putObjectArray", so don't check ObjectArrayProperty - // There's no "putBundleArray", so don't check BundleArrayProperty - - // Use Bundle as the default catch-all for objects - PUT_IN_BUNDLE_IF_TYPE_IS(Bundle); - -#undef PUT_IN_BUNDLE_IF_TYPE_IS - - // We tried all supported types; just bail. - jni::ThrowException("java/lang/UnsupportedOperationException", - "Unsupported property type"); - return nullptr; - } - return jni::Object::LocalRef::Adopt(newBundle.Env(), - newBundle.Forget()); - } - - sdk::Bundle::LocalRef - BundleFromValue(JS::HandleValue val) - { - if (val.isNull()) { - return nullptr; - } - JS::RootedObject object(mJSContext, &val.toObject()); - return BundleFromValue(object); - } - - // Object properties - - bool ObjectInValue(JS::HandleValue val) const - { - return val.isObjectOrNull(); - } - - NativeJSObject::LocalRef - ObjectFromValue(JS::HandleValue val) - { - if (val.isNull()) { - return nullptr; - } - JS::RootedObject object(mJSContext, &val.toObject()); - return CreateChild(object); - } - - template<class Prop> typename Prop::NativeArray - ObjectNewArray(JS::HandleObject array, size_t length) - { - auto jarray = Prop::NativeArray::Adopt(mEnv, mEnv->NewObjectArray( - length, typename Prop::ClassType::Context().ClassRef(), - nullptr)); - if (!jarray) { - return nullptr; - } - - // For object arrays, we have to set each element separately. - for (size_t i = 0; i < length; i++) { - JS::RootedValue elem(mJSContext); - if (!CheckJSCall(JS_GetElement(mJSContext, array, i, &elem)) || - !CheckProperty(Prop::InValue, elem)) { - return nullptr; - } - mEnv->SetObjectArrayElement( - jarray.Get(), i, (this->*Prop::FromValue)(elem).Get()); - if (mEnv->ExceptionCheck()) { - return nullptr; - } - } - return jarray; - } - - template<class Class, - bool (Self::*InValue_)(JS::HandleValue) const, - typename Class::LocalRef (Self::*FromValue_)(JS::HandleValue)> - struct BaseObjectProperty - { - // JNI class for the object type (e.g. jni::String) - typedef Class ClassType; - - // See comments in PrimitiveProperty. - typedef typename ClassType::LocalRef NativeType; - typedef const typename ClassType::Ref NativeFallback; - typedef typename jni::ObjectArray::LocalRef NativeArray; - typedef const jni::ObjectArray::Ref ArrayFallback; - - typedef decltype(InValue_) InValue_t; - static constexpr InValue_t InValue = InValue_; - - typedef decltype(FromValue_) FromValue_t; - static constexpr FromValue_t FromValue = FromValue_; - - typedef decltype(&Self::ObjectNewArray<BaseObjectProperty>) NewArray_t; - static constexpr NewArray_t NewArray - = &Self::ObjectNewArray<BaseObjectProperty>; - }; - - // Array properties - - template<class Prop> bool - ArrayInValue(JS::HandleValue val) const - { - if (!val.isObject()) { - return false; - } - JS::RootedObject obj(mJSContext, &val.toObject()); - bool isArray; - uint32_t length = 0; - if (!JS_IsArrayObject(mJSContext, obj, &isArray) || - !isArray || - !JS_GetArrayLength(mJSContext, obj, &length)) { - JS_ClearPendingException(mJSContext); - return false; - } - if (!length) { - // Empty arrays are always okay. - return true; - } - // We only check to see the first element is the target type. If the - // array has mixed types, we'll throw an error during actual conversion. - JS::RootedValue element(mJSContext); - if (!JS_GetElement(mJSContext, obj, 0, &element)) { - JS_ClearPendingException(mJSContext); - return false; - } - return (this->*Prop::InValue)(element); - } - - template<class Prop> typename Prop::NativeArray - ArrayFromValue(JS::HandleValue val) - { - JS::RootedObject obj(mJSContext, &val.toObject()); - uint32_t length = 0; - if (!CheckJSCall(JS_GetArrayLength(mJSContext, obj, &length))) { - return nullptr; - } - return (this->*Prop::NewArray)(obj, length); - } - - template<class Prop> - struct ArrayProperty - { - // See comments in PrimitiveProperty. - typedef typename Prop::NativeArray NativeType; - typedef typename Prop::ArrayFallback NativeFallback; - - typedef decltype(&Self::ArrayInValue<Prop>) InValue_t; - static constexpr InValue_t InValue - = &Self::ArrayInValue<Prop>; - - typedef decltype(&Self::ArrayFromValue<Prop>) FromValue_t; - static constexpr FromValue_t FromValue - = &Self::ArrayFromValue<Prop>; - }; - - // "Has" property is a special property type that is used to implement - // NativeJSObject.has, by returning true from InValue and FromValue for - // every existing property, and having false as the fallback value for - // when a property doesn't exist. - - bool HasValue(JS::HandleValue val) const - { - return true; - } - - struct HasProperty - { - // See comments in PrimitiveProperty. - typedef bool NativeType; - typedef bool NativeFallback; - - typedef decltype(&Self::HasValue) HasValue_t; - static constexpr HasValue_t InValue = &Self::HasValue; - static constexpr HasValue_t FromValue = &Self::HasValue; - }; - - // Statically cast from bool to jboolean (unsigned char); it works - // since false and JNI_FALSE have the same value (0), and true and - // JNI_TRUE have the same value (1). - typedef PrimitiveProperty< - bool, jni::BooleanArray, jboolean, jbooleanArray, - &JS::Value::isBoolean, &JS::Value::toBoolean, - &JNIEnv::NewBooleanArray, &JNIEnv::SetBooleanArrayRegion> - BooleanProperty; - - typedef PrimitiveProperty< - double, jni::DoubleArray, jdouble, jdoubleArray, - &JS::Value::isNumber, &JS::Value::toNumber, - &JNIEnv::NewDoubleArray, &JNIEnv::SetDoubleArrayRegion> - DoubleProperty; - - typedef PrimitiveProperty< - int32_t, jni::IntArray, jint, jintArray, - &JS::Value::isInt32, &JS::Value::toInt32, - &JNIEnv::NewIntArray, &JNIEnv::SetIntArrayRegion> - IntProperty; - - typedef BaseObjectProperty< - jni::String, &Self::StringInValue, &Self::StringFromValue> - StringProperty; - - typedef BaseObjectProperty< - sdk::Bundle, &Self::ObjectInValue, &Self::BundleFromValue> - BundleProperty; - - typedef BaseObjectProperty< - NativeJSObject, &Self::ObjectInValue, &Self::ObjectFromValue> - ObjectProperty; - - typedef ArrayProperty<BooleanProperty> BooleanArrayProperty; - typedef ArrayProperty<DoubleProperty> DoubleArrayProperty; - typedef ArrayProperty<IntProperty> IntArrayProperty; - typedef ArrayProperty<StringProperty> StringArrayProperty; - typedef ArrayProperty<BundleProperty> BundleArrayProperty; - typedef ArrayProperty<ObjectProperty> ObjectArrayProperty; - - template<class Prop> - typename Prop::NativeType - GetProperty(jni::String::Param name, - typename Prop::NativeFallback* fallback = nullptr) - { - if (!CheckThread() || !CheckObject()) { - return typename Prop::NativeType(); - } - - const JSJNIString nameStr(mEnv, name); - JS::RootedValue val(mJSContext); - - if (!CheckJNIArgument(name) || - !CheckJSCall(JS_GetUCProperty( - mJSContext, mJSObject, nameStr, nameStr.Length(), &val))) { - return typename Prop::NativeType(); - } - - // Strictly, null is different from undefined in JS. However, in - // practice, null is often used to indicate a property doesn't exist in - // the same manner as undefined. Therefore, we treat null in the same - // way as undefined when checking property existence (bug 1014965). - if (val.isUndefined() || val.isNull()) { - if (fallback) { - return mozilla::Move(*fallback); - } - jni::ThrowException( - "org/mozilla/gecko/util/NativeJSObject$InvalidPropertyException", - "Property does not exist"); - return typename Prop::NativeType(); - } - - if (!CheckProperty(Prop::InValue, val)) { - return typename Prop::NativeType(); - } - return (this->*Prop::FromValue)(val); - } - - NativeJSObject::LocalRef CreateChild(JS::HandleObject object) - { - auto instance = NativeJSObject::New(); - mozilla::UniquePtr<NativeJSContainerImpl> impl( - new NativeJSContainerImpl(instance.Env(), mJSContext, object)); - - ObjectBase::AttachNative(instance, mozilla::Move(impl)); - if (!mChildren.append(NativeJSObject::GlobalRef(instance))) { - MOZ_CRASH(); - } - return instance; - } - - NativeJSContainerImpl(JNIEnv* env, JSContext* cx, JS::HandleObject object) - : mEnv(env) - , mJSContext(cx) - , mJSObject(cx, object) - {} - -public: - ~NativeJSContainerImpl() - { - // Dispose of all children on destruction. The children will in turn - // dispose any of their children (i.e. our grandchildren) and so on. - NativeJSObject::LocalRef child(mEnv); - for (size_t i = 0; i < mChildren.length(); i++) { - child = mChildren[i]; - ObjectBase::GetNative(child)->ObjectBase::DisposeNative(child); - } - } - - static NativeJSContainer::LocalRef - CreateInstance(JSContext* cx, JS::HandleObject object) - { - auto instance = NativeJSContainer::New(); - mozilla::UniquePtr<NativeJSContainerImpl> impl( - new NativeJSContainerImpl(instance.Env(), cx, object)); - - ContainerBase::AttachNative(instance, mozilla::Move(impl)); - return instance; - } - - // NativeJSContainer methods - - void DisposeNative(const NativeJSContainer::LocalRef& instance) - { - if (!CheckThread()) { - return; - } - ContainerBase::DisposeNative(instance); - } - - NativeJSContainer::LocalRef Clone() - { - if (!CheckThread()) { - return nullptr; - } - return CreateInstance(mJSContext, mJSObject); - } - - // NativeJSObject methods - - bool GetBoolean(jni::String::Param name) - { - return GetProperty<BooleanProperty>(name); - } - - bool OptBoolean(jni::String::Param name, bool fallback) - { - return GetProperty<BooleanProperty>(name, &fallback); - } - - jni::BooleanArray::LocalRef - GetBooleanArray(jni::String::Param name) - { - return GetProperty<BooleanArrayProperty>(name); - } - - jni::BooleanArray::LocalRef - OptBooleanArray(jni::String::Param name, jni::BooleanArray::Param fallback) - { - return GetProperty<BooleanArrayProperty>(name, &fallback); - } - - jni::Object::LocalRef - GetBundle(jni::String::Param name) - { - return GetProperty<BundleProperty>(name); - } - - jni::Object::LocalRef - OptBundle(jni::String::Param name, jni::Object::Param fallback) - { - // Because the GetProperty expects a sdk::Bundle::Param, - // we have to do conversions here from jni::Object::Param. - const auto& fb = sdk::Bundle::Ref::From(fallback.Get()); - return GetProperty<BundleProperty>(name, &fb); - } - - jni::ObjectArray::LocalRef - GetBundleArray(jni::String::Param name) - { - return GetProperty<BundleArrayProperty>(name); - } - - jni::ObjectArray::LocalRef - OptBundleArray(jni::String::Param name, jni::ObjectArray::Param fallback) - { - return GetProperty<BundleArrayProperty>(name, &fallback); - } - - double GetDouble(jni::String::Param name) - { - return GetProperty<DoubleProperty>(name); - } - - double OptDouble(jni::String::Param name, double fallback) - { - return GetProperty<DoubleProperty>(name, &fallback); - } - - jni::DoubleArray::LocalRef - GetDoubleArray(jni::String::Param name) - { - return GetProperty<DoubleArrayProperty>(name); - } - - jni::DoubleArray::LocalRef - OptDoubleArray(jni::String::Param name, jni::DoubleArray::Param fallback) - { - jni::DoubleArray::LocalRef fb(fallback); - return GetProperty<DoubleArrayProperty>(name, &fb); - } - - int GetInt(jni::String::Param name) - { - return GetProperty<IntProperty>(name); - } - - int OptInt(jni::String::Param name, int fallback) - { - return GetProperty<IntProperty>(name, &fallback); - } - - jni::IntArray::LocalRef - GetIntArray(jni::String::Param name) - { - return GetProperty<IntArrayProperty>(name); - } - - jni::IntArray::LocalRef - OptIntArray(jni::String::Param name, jni::IntArray::Param fallback) - { - jni::IntArray::LocalRef fb(fallback); - return GetProperty<IntArrayProperty>(name, &fb); - } - - NativeJSObject::LocalRef - GetObject(jni::String::Param name) - { - return GetProperty<ObjectProperty>(name); - } - - NativeJSObject::LocalRef - OptObject(jni::String::Param name, NativeJSObject::Param fallback) - { - return GetProperty<ObjectProperty>(name, &fallback); - } - - jni::ObjectArray::LocalRef - GetObjectArray(jni::String::Param name) - { - return GetProperty<ObjectArrayProperty>(name); - } - - jni::ObjectArray::LocalRef - OptObjectArray(jni::String::Param name, jni::ObjectArray::Param fallback) - { - return GetProperty<ObjectArrayProperty>(name, &fallback); - } - - jni::String::LocalRef - GetString(jni::String::Param name) - { - return GetProperty<StringProperty>(name); - } - - jni::String::LocalRef - OptString(jni::String::Param name, jni::String::Param fallback) - { - return GetProperty<StringProperty>(name, &fallback); - } - - jni::ObjectArray::LocalRef - GetStringArray(jni::String::Param name) - { - return GetProperty<StringArrayProperty>(name); - } - - jni::ObjectArray::LocalRef - OptStringArray(jni::String::Param name, jni::ObjectArray::Param fallback) - { - return GetProperty<StringArrayProperty>(name, &fallback); - } - - bool Has(jni::String::Param name) - { - bool no = false; - // Fallback to false indicating no such property. - return GetProperty<HasProperty>(name, &no); - } - - jni::Object::LocalRef ToBundle() - { - if (!CheckThread() || !CheckObject()) { - return nullptr; - } - return BundleFromValue(mJSObject); - } - -private: - static bool AppendJSON(const char16_t* buf, uint32_t len, void* data) - { - static_cast<nsAutoString*>(data)->Append(buf, len); - return true; - } - -public: - jni::String::LocalRef ToString() - { - if (!CheckThread() || !CheckObject()) { - return nullptr; - } - - JS::RootedValue value(mJSContext, JS::ObjectValue(*mJSObject)); - nsAutoString json; - if (!CheckJSCall(JS_Stringify(mJSContext, &value, nullptr, - JS::NullHandleValue, AppendJSON, &json))) { - return nullptr; - } - return jni::StringParam(json, mEnv); - } -}; - - -// Define the "static constexpr" members of our property types (e.g. -// PrimitiveProperty<>::InValue). This is tricky because there are a lot of -// template parameters, so we use macros to make it simpler. - -#define DEFINE_PRIMITIVE_PROPERTY_MEMBER(Name) \ - template<typename U, typename UA, typename V, typename VA, \ - bool (JS::Value::*I)() const, \ - U (JS::Value::*T)() const, \ - VA (JNIEnv::*N)(jsize), \ - void (JNIEnv::*S)(VA, jsize, jsize, const V*)> \ - constexpr typename NativeJSContainerImpl \ - ::PrimitiveProperty<U, UA, V, VA, I, T, N, S>::Name##_t \ - NativeJSContainerImpl::PrimitiveProperty<U, UA, V, VA, I, T, N, S>::Name - -DEFINE_PRIMITIVE_PROPERTY_MEMBER(NewJNIArray); -DEFINE_PRIMITIVE_PROPERTY_MEMBER(SetJNIArrayRegion); -DEFINE_PRIMITIVE_PROPERTY_MEMBER(InValue); -DEFINE_PRIMITIVE_PROPERTY_MEMBER(FromValue); -DEFINE_PRIMITIVE_PROPERTY_MEMBER(NewArray); - -#undef DEFINE_PRIMITIVE_PROPERTY_MEMBER - -#define DEFINE_OBJECT_PROPERTY_MEMBER(Name) \ - template<class C, \ - bool (NativeJSContainerImpl::*I)(JS::HandleValue) const, \ - typename C::LocalRef (NativeJSContainerImpl::*F)(JS::HandleValue)> \ - constexpr typename NativeJSContainerImpl \ - ::BaseObjectProperty<C, I, F>::Name##_t \ - NativeJSContainerImpl::BaseObjectProperty<C, I, F>::Name - -DEFINE_OBJECT_PROPERTY_MEMBER(InValue); -DEFINE_OBJECT_PROPERTY_MEMBER(FromValue); -DEFINE_OBJECT_PROPERTY_MEMBER(NewArray); - -#undef DEFINE_OBJECT_PROPERTY_MEMBER - -template<class P> constexpr typename NativeJSContainerImpl::ArrayProperty<P> - ::InValue_t NativeJSContainerImpl::ArrayProperty<P>::InValue; -template<class P> constexpr typename NativeJSContainerImpl::ArrayProperty<P> - ::FromValue_t NativeJSContainerImpl::ArrayProperty<P>::FromValue; - -constexpr NativeJSContainerImpl::HasProperty::HasValue_t - NativeJSContainerImpl::HasProperty::InValue; -constexpr NativeJSContainerImpl::HasProperty::HasValue_t - NativeJSContainerImpl::HasProperty::FromValue; - - -NativeJSContainer::LocalRef -CreateNativeJSContainer(JSContext* cx, JS::HandleObject object) -{ - return NativeJSContainerImpl::CreateInstance(cx, object); -} - -} // namespace widget -} // namespace mozilla - diff --git a/widget/android/NativeJSContainer.h b/widget/android/NativeJSContainer.h deleted file mode 100644 index bebf75f1b..000000000 --- a/widget/android/NativeJSContainer.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NativeJSObject_h__ -#define NativeJSObject_h__ - -#include "GeneratedJNIWrappers.h" -#include "jsapi.h" - -namespace mozilla { -namespace widget { - -java::NativeJSContainer::LocalRef -CreateNativeJSContainer(JSContext* cx, JS::HandleObject object); - -} // namespace widget -} // namespace mozilla - -#endif // NativeJSObject_h__ - diff --git a/widget/android/PrefsHelper.h b/widget/android/PrefsHelper.h deleted file mode 100644 index b053c979a..000000000 --- a/widget/android/PrefsHelper.h +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef PrefsHelper_h -#define PrefsHelper_h - -#include "GeneratedJNINatives.h" -#include "MainThreadUtils.h" -#include "nsAppShell.h" -#include "nsCOMPtr.h" -#include "nsVariant.h" - -#include "mozilla/Preferences.h" -#include "mozilla/Services.h" - -namespace mozilla { - -class PrefsHelper - : public java::PrefsHelper::Natives<PrefsHelper> -{ - PrefsHelper() = delete; - - static bool GetVariantPref(nsIObserverService* aObsServ, - nsIWritableVariant* aVariant, - jni::Object::Param aPrefHandler, - const jni::String::LocalRef& aPrefName) - { - if (NS_FAILED(aObsServ->NotifyObservers(aVariant, "android-get-pref", - aPrefName->ToString().get()))) { - return false; - } - - uint16_t varType = nsIDataType::VTYPE_EMPTY; - if (NS_FAILED(aVariant->GetDataType(&varType))) { - return false; - } - - int32_t type = java::PrefsHelper::PREF_INVALID; - bool boolVal = false; - int32_t intVal = 0; - nsAutoString strVal; - - switch (varType) { - case nsIDataType::VTYPE_BOOL: - type = java::PrefsHelper::PREF_BOOL; - if (NS_FAILED(aVariant->GetAsBool(&boolVal))) { - return false; - } - break; - case nsIDataType::VTYPE_INT32: - type = java::PrefsHelper::PREF_INT; - if (NS_FAILED(aVariant->GetAsInt32(&intVal))) { - return false; - } - break; - case nsIDataType::VTYPE_ASTRING: - type = java::PrefsHelper::PREF_STRING; - if (NS_FAILED(aVariant->GetAsAString(strVal))) { - return false; - } - break; - default: - return false; - } - - jni::StringParam jstrVal(type == java::PrefsHelper::PREF_STRING ? - jni::StringParam(strVal, aPrefName.Env()) : - jni::StringParam(nullptr)); - - if (aPrefHandler) { - java::PrefsHelper::CallPrefHandler( - aPrefHandler, type, aPrefName, - boolVal, intVal, jstrVal); - } else { - java::PrefsHelper::OnPrefChange( - aPrefName, type, boolVal, intVal, jstrVal); - } - return true; - } - - static bool SetVariantPref(nsIObserverService* aObsServ, - nsIWritableVariant* aVariant, - jni::String::Param aPrefName, - bool aFlush, - int32_t aType, - bool aBoolVal, - int32_t aIntVal, - jni::String::Param aStrVal) - { - nsresult rv = NS_ERROR_FAILURE; - - switch (aType) { - case java::PrefsHelper::PREF_BOOL: - rv = aVariant->SetAsBool(aBoolVal); - break; - case java::PrefsHelper::PREF_INT: - rv = aVariant->SetAsInt32(aIntVal); - break; - case java::PrefsHelper::PREF_STRING: - rv = aVariant->SetAsAString(aStrVal->ToString()); - break; - } - - if (NS_SUCCEEDED(rv)) { - rv = aObsServ->NotifyObservers(aVariant, "android-set-pref", - aPrefName->ToString().get()); - } - - uint16_t varType = nsIDataType::VTYPE_EMPTY; - if (NS_SUCCEEDED(rv)) { - rv = aVariant->GetDataType(&varType); - } - - // We use set-to-empty to signal the pref was handled. - const bool handled = varType == nsIDataType::VTYPE_EMPTY; - - if (NS_SUCCEEDED(rv) && handled && aFlush) { - rv = Preferences::GetService()->SavePrefFile(nullptr); - } - - if (NS_SUCCEEDED(rv)) { - return handled; - } - - NS_WARNING(nsPrintfCString("Failed to set pref %s", - aPrefName->ToCString().get()).get()); - // Pretend we handled the pref. - return true; - } - -public: - static void GetPrefs(const jni::Class::LocalRef& aCls, - jni::ObjectArray::Param aPrefNames, - jni::Object::Param aPrefHandler) - { - nsTArray<jni::Object::LocalRef> nameRefArray(aPrefNames->GetElements()); - nsCOMPtr<nsIObserverService> obsServ; - nsCOMPtr<nsIWritableVariant> value; - nsAdoptingString strVal; - - for (jni::Object::LocalRef& nameRef : nameRefArray) { - jni::String::LocalRef nameStr(mozilla::Move(nameRef)); - const nsCString& name = nameStr->ToCString(); - - int32_t type = java::PrefsHelper::PREF_INVALID; - bool boolVal = false; - int32_t intVal = 0; - - switch (Preferences::GetType(name.get())) { - case nsIPrefBranch::PREF_BOOL: - type = java::PrefsHelper::PREF_BOOL; - boolVal = Preferences::GetBool(name.get()); - break; - - case nsIPrefBranch::PREF_INT: - type = java::PrefsHelper::PREF_INT; - intVal = Preferences::GetInt(name.get()); - break; - - case nsIPrefBranch::PREF_STRING: - type = java::PrefsHelper::PREF_STRING; - strVal = Preferences::GetLocalizedString(name.get()); - if (!strVal) { - strVal = Preferences::GetString(name.get()); - } - break; - - default: - // Pref not found; try to find it. - if (!obsServ) { - obsServ = services::GetObserverService(); - if (!obsServ) { - continue; - } - } - if (value) { - value->SetAsEmpty(); - } else { - value = new nsVariant(); - } - if (!GetVariantPref(obsServ, value, - aPrefHandler, nameStr)) { - NS_WARNING(nsPrintfCString("Failed to get pref %s", - name.get()).get()); - } - continue; - } - - java::PrefsHelper::CallPrefHandler( - aPrefHandler, type, nameStr, boolVal, intVal, - jni::StringParam(type == java::PrefsHelper::PREF_STRING ? - jni::StringParam(strVal, aCls.Env()) : - jni::StringParam(nullptr))); - } - - java::PrefsHelper::CallPrefHandler( - aPrefHandler, java::PrefsHelper::PREF_FINISH, - nullptr, false, 0, nullptr); - } - - static void SetPref(jni::String::Param aPrefName, - bool aFlush, - int32_t aType, - bool aBoolVal, - int32_t aIntVal, - jni::String::Param aStrVal) - { - const nsCString& name = aPrefName->ToCString(); - - if (Preferences::GetType(name.get()) == nsIPrefBranch::PREF_INVALID) { - // No pref; try asking first. - nsCOMPtr<nsIObserverService> obsServ = - services::GetObserverService(); - nsCOMPtr<nsIWritableVariant> value = new nsVariant(); - if (obsServ && SetVariantPref(obsServ, value, aPrefName, aFlush, - aType, aBoolVal, aIntVal, aStrVal)) { - // The "pref" has changed; send a notification. - GetVariantPref(obsServ, value, nullptr, - jni::String::LocalRef(aPrefName)); - return; - } - } - - switch (aType) { - case java::PrefsHelper::PREF_BOOL: - Preferences::SetBool(name.get(), aBoolVal); - break; - case java::PrefsHelper::PREF_INT: - Preferences::SetInt(name.get(), aIntVal); - break; - case java::PrefsHelper::PREF_STRING: - Preferences::SetString(name.get(), aStrVal->ToString()); - break; - default: - MOZ_ASSERT(false, "Invalid pref type"); - } - - if (aFlush) { - Preferences::GetService()->SavePrefFile(nullptr); - } - } - - static void AddObserver(const jni::Class::LocalRef& aCls, - jni::ObjectArray::Param aPrefNames, - jni::Object::Param aPrefHandler, - jni::ObjectArray::Param aPrefsToObserve) - { - // Call observer immediately with existing pref values. - GetPrefs(aCls, aPrefNames, aPrefHandler); - - if (!aPrefsToObserve) { - return; - } - - nsTArray<jni::Object::LocalRef> nameRefArray( - aPrefsToObserve->GetElements()); - nsAppShell* const appShell = nsAppShell::Get(); - MOZ_ASSERT(appShell); - - for (jni::Object::LocalRef& nameRef : nameRefArray) { - jni::String::LocalRef nameStr(mozilla::Move(nameRef)); - MOZ_ALWAYS_SUCCEEDS(Preferences::AddStrongObserver( - appShell, nameStr->ToCString().get())); - } - } - - static void RemoveObserver(const jni::Class::LocalRef& aCls, - jni::ObjectArray::Param aPrefsToUnobserve) - { - nsTArray<jni::Object::LocalRef> nameRefArray( - aPrefsToUnobserve->GetElements()); - nsAppShell* const appShell = nsAppShell::Get(); - MOZ_ASSERT(appShell); - - for (jni::Object::LocalRef& nameRef : nameRefArray) { - jni::String::LocalRef nameStr(mozilla::Move(nameRef)); - MOZ_ALWAYS_SUCCEEDS(Preferences::RemoveObserver( - appShell, nameStr->ToCString().get())); - } - } - - static void OnPrefChange(const char16_t* aData) - { - const nsCString& name = NS_LossyConvertUTF16toASCII(aData); - - int32_t type = -1; - bool boolVal = false; - int32_t intVal = false; - nsAdoptingString strVal; - - switch (Preferences::GetType(name.get())) { - case nsIPrefBranch::PREF_BOOL: - type = java::PrefsHelper::PREF_BOOL; - boolVal = Preferences::GetBool(name.get()); - break; - case nsIPrefBranch::PREF_INT: - type = java::PrefsHelper::PREF_INT; - intVal = Preferences::GetInt(name.get()); - break; - case nsIPrefBranch::PREF_STRING: - type = java::PrefsHelper::PREF_STRING; - strVal = Preferences::GetLocalizedString(name.get()); - if (!strVal) { - strVal = Preferences::GetString(name.get()); - } - break; - default: - NS_WARNING(nsPrintfCString("Invalid pref %s", - name.get()).get()); - return; - } - - java::PrefsHelper::OnPrefChange( - name, type, boolVal, intVal, - jni::StringParam(type == java::PrefsHelper::PREF_STRING ? - jni::StringParam(strVal) : jni::StringParam(nullptr))); - } -}; - -} // namespace - -#endif // PrefsHelper_h diff --git a/widget/android/bindings/AndroidRect-classes.txt b/widget/android/bindings/AndroidRect-classes.txt deleted file mode 100644 index cbacca81e..000000000 --- a/widget/android/bindings/AndroidRect-classes.txt +++ /dev/null @@ -1,2 +0,0 @@ -android.graphics.Rect -android.graphics.RectF diff --git a/widget/android/bindings/Bundle-classes.txt b/widget/android/bindings/Bundle-classes.txt deleted file mode 100644 index 9f535cddb..000000000 --- a/widget/android/bindings/Bundle-classes.txt +++ /dev/null @@ -1 +0,0 @@ -android.os.Bundle diff --git a/widget/android/bindings/KeyEvent-classes.txt b/widget/android/bindings/KeyEvent-classes.txt deleted file mode 100644 index b73e621ef..000000000 --- a/widget/android/bindings/KeyEvent-classes.txt +++ /dev/null @@ -1 +0,0 @@ -android.view.KeyEvent diff --git a/widget/android/bindings/Makefile.in b/widget/android/bindings/Makefile.in deleted file mode 100644 index ea66e6022..000000000 --- a/widget/android/bindings/Makefile.in +++ /dev/null @@ -1,27 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# Bug 1099345 - The SDK's lint code (used by the code generator) does not enjoy -# concurrent access to a cache that it generates. -.NOTPARALLEL: - -annotation_processor_jar_files := \ - $(DEPTH)/build/annotationProcessors/annotationProcessors.jar \ - $(ANDROID_TOOLS)/lib/lint.jar \ - $(ANDROID_TOOLS)/lib/lint-checks.jar \ - $(NULL) - -sdk_processor := \ - $(JAVA) \ - -Dcom.android.tools.lint.bindir='$(ANDROID_TOOLS)' \ - -classpath $(subst $(NULL) ,:,$(strip $(annotation_processor_jar_files))) \ - org.mozilla.gecko.annotationProcessors.SDKProcessor - -# For the benefit of readers: the following pattern rule says that, -# for example, MediaCodec.cpp and MediaCodec.h can be produced from -# MediaCodec-classes.txt. This formulation invokes the SDK processor -# at most once. - -%.cpp %.h: $(ANDROID_SDK)/android.jar %-classes.txt $(annotation_processor_jar_files) - $(sdk_processor) $(ANDROID_SDK)/android.jar $(srcdir)/$*-classes.txt $(CURDIR) $* 16 diff --git a/widget/android/bindings/MediaCodec-classes.txt b/widget/android/bindings/MediaCodec-classes.txt deleted file mode 100644 index ea26029af..000000000 --- a/widget/android/bindings/MediaCodec-classes.txt +++ /dev/null @@ -1,5 +0,0 @@ -android.media.MediaCodec -android.media.MediaCodec$BufferInfo -android.media.MediaCodec$CryptoInfo -android.media.MediaDrm$KeyStatus -android.media.MediaFormat diff --git a/widget/android/bindings/MotionEvent-classes.txt b/widget/android/bindings/MotionEvent-classes.txt deleted file mode 100644 index dd38dc000..000000000 --- a/widget/android/bindings/MotionEvent-classes.txt +++ /dev/null @@ -1 +0,0 @@ -android.view.MotionEvent diff --git a/widget/android/bindings/SurfaceTexture-classes.txt b/widget/android/bindings/SurfaceTexture-classes.txt deleted file mode 100644 index 5c7ca8968..000000000 --- a/widget/android/bindings/SurfaceTexture-classes.txt +++ /dev/null @@ -1,2 +0,0 @@ -android.graphics.SurfaceTexture -android.view.Surface diff --git a/widget/android/bindings/ViewConfiguration-classes.txt b/widget/android/bindings/ViewConfiguration-classes.txt deleted file mode 100644 index e6601e65f..000000000 --- a/widget/android/bindings/ViewConfiguration-classes.txt +++ /dev/null @@ -1 +0,0 @@ -android.view.ViewConfiguration diff --git a/widget/android/bindings/moz.build b/widget/android/bindings/moz.build deleted file mode 100644 index 1bd71fa95..000000000 --- a/widget/android/bindings/moz.build +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# List of stems to generate .cpp and .h files for. To add a stem, add it to -# this list and ensure that $(stem)-classes.txt exists in this directory. -generated = [ - 'AndroidRect', - 'Bundle', - 'KeyEvent', - 'MediaCodec', - 'MotionEvent', - 'SurfaceTexture', - 'ViewConfiguration' -] - -SOURCES += ['!%s.cpp' % stem for stem in generated] - -EXPORTS += ['!%s.h' % stem for stem in generated] - -# We'd like to add these to a future GENERATED_EXPORTS list, but for now we mark -# them as generated here and manually install them in Makefile.in. -GENERATED_FILES += [stem + '.h' for stem in generated] - -# There is an unfortunate race condition when using generated SOURCES and -# pattern rules (see Makefile.in) that manifests itself as a VPATH resolution -# conflict: MediaCodec.o looks for MediaCodec.cpp and $(CURDIR)/MediaCodec.cpp, -# and the pattern rule is matched but doesn't resolve both sources, causing a -# failure. Adding the SOURCES to GENERATED_FILES causes the sources -# to be built at export time, which is before MediaCodec.o needs them; and by -# the time MediaCodec.o is built, the source is in place and the VPATH -# resolution works as expected. -GENERATED_FILES += [f[1:] for f in SOURCES] - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '/widget/android', -] diff --git a/widget/android/fennec/FennecJNINatives.h b/widget/android/fennec/FennecJNINatives.h deleted file mode 100644 index 9d0cdd77c..000000000 --- a/widget/android/fennec/FennecJNINatives.h +++ /dev/null @@ -1,244 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#ifndef FennecJNINatives_h -#define FennecJNINatives_h - -#include "FennecJNIWrappers.h" -#include "mozilla/jni/Natives.h" - -namespace mozilla { -namespace java { - -template<class Impl> -class ANRReporter::Natives : public mozilla::jni::NativeImpl<ANRReporter, Impl> -{ -public: - static const JNINativeMethod methods[3]; -}; - -template<class Impl> -const JNINativeMethod ANRReporter::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<ANRReporter::GetNativeStack_t>( - mozilla::jni::NativeStub<ANRReporter::GetNativeStack_t, Impl> - ::template Wrap<&Impl::GetNativeStack>), - - mozilla::jni::MakeNativeMethod<ANRReporter::ReleaseNativeStack_t>( - mozilla::jni::NativeStub<ANRReporter::ReleaseNativeStack_t, Impl> - ::template Wrap<&Impl::ReleaseNativeStack>), - - mozilla::jni::MakeNativeMethod<ANRReporter::RequestNativeStack_t>( - mozilla::jni::NativeStub<ANRReporter::RequestNativeStack_t, Impl> - ::template Wrap<&Impl::RequestNativeStack>) -}; - -template<class Impl> -class GeckoJavaSampler::Natives : public mozilla::jni::NativeImpl<GeckoJavaSampler, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod GeckoJavaSampler::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<GeckoJavaSampler::GetProfilerTime_t>( - mozilla::jni::NativeStub<GeckoJavaSampler::GetProfilerTime_t, Impl> - ::template Wrap<&Impl::GetProfilerTime>) -}; - -template<class Impl> -class MemoryMonitor::Natives : public mozilla::jni::NativeImpl<MemoryMonitor, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod MemoryMonitor::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<MemoryMonitor::DispatchMemoryPressure_t>( - mozilla::jni::NativeStub<MemoryMonitor::DispatchMemoryPressure_t, Impl> - ::template Wrap<&Impl::DispatchMemoryPressure>) -}; - -template<class Impl> -class PresentationMediaPlayerManager::Natives : public mozilla::jni::NativeImpl<PresentationMediaPlayerManager, Impl> -{ -public: - static const JNINativeMethod methods[3]; -}; - -template<class Impl> -const JNINativeMethod PresentationMediaPlayerManager::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::AddPresentationSurface_t>( - mozilla::jni::NativeStub<PresentationMediaPlayerManager::AddPresentationSurface_t, Impl> - ::template Wrap<&Impl::AddPresentationSurface>), - - mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t>( - mozilla::jni::NativeStub<PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t, Impl> - ::template Wrap<&Impl::InvalidateAndScheduleComposite>), - - mozilla::jni::MakeNativeMethod<PresentationMediaPlayerManager::RemovePresentationSurface_t>( - mozilla::jni::NativeStub<PresentationMediaPlayerManager::RemovePresentationSurface_t, Impl> - ::template Wrap<&Impl::RemovePresentationSurface>) -}; - -template<class Impl> -class ScreenManagerHelper::Natives : public mozilla::jni::NativeImpl<ScreenManagerHelper, Impl> -{ -public: - static const JNINativeMethod methods[2]; -}; - -template<class Impl> -const JNINativeMethod ScreenManagerHelper::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<ScreenManagerHelper::AddDisplay_t>( - mozilla::jni::NativeStub<ScreenManagerHelper::AddDisplay_t, Impl> - ::template Wrap<&Impl::AddDisplay>), - - mozilla::jni::MakeNativeMethod<ScreenManagerHelper::RemoveDisplay_t>( - mozilla::jni::NativeStub<ScreenManagerHelper::RemoveDisplay_t, Impl> - ::template Wrap<&Impl::RemoveDisplay>) -}; - -template<class Impl> -class Telemetry::Natives : public mozilla::jni::NativeImpl<Telemetry, Impl> -{ -public: - static const JNINativeMethod methods[5]; -}; - -template<class Impl> -const JNINativeMethod Telemetry::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<Telemetry::AddHistogram_t>( - mozilla::jni::NativeStub<Telemetry::AddHistogram_t, Impl> - ::template Wrap<&Impl::AddHistogram>), - - mozilla::jni::MakeNativeMethod<Telemetry::AddKeyedHistogram_t>( - mozilla::jni::NativeStub<Telemetry::AddKeyedHistogram_t, Impl> - ::template Wrap<&Impl::AddKeyedHistogram>), - - mozilla::jni::MakeNativeMethod<Telemetry::AddUIEvent_t>( - mozilla::jni::NativeStub<Telemetry::AddUIEvent_t, Impl> - ::template Wrap<&Impl::AddUIEvent>), - - mozilla::jni::MakeNativeMethod<Telemetry::StartUISession_t>( - mozilla::jni::NativeStub<Telemetry::StartUISession_t, Impl> - ::template Wrap<&Impl::StartUISession>), - - mozilla::jni::MakeNativeMethod<Telemetry::StopUISession_t>( - mozilla::jni::NativeStub<Telemetry::StopUISession_t, Impl> - ::template Wrap<&Impl::StopUISession>) -}; - -template<class Impl> -class ThumbnailHelper::Natives : public mozilla::jni::NativeImpl<ThumbnailHelper, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod ThumbnailHelper::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<ThumbnailHelper::RequestThumbnail_t>( - mozilla::jni::NativeStub<ThumbnailHelper::RequestThumbnail_t, Impl> - ::template Wrap<&Impl::RequestThumbnail>) -}; - -template<class Impl> -class ZoomedView::Natives : public mozilla::jni::NativeImpl<ZoomedView, Impl> -{ -public: - static const JNINativeMethod methods[1]; -}; - -template<class Impl> -const JNINativeMethod ZoomedView::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<ZoomedView::RequestZoomedViewData_t>( - mozilla::jni::NativeStub<ZoomedView::RequestZoomedViewData_t, Impl> - ::template Wrap<&Impl::RequestZoomedViewData>) -}; - -template<class Impl> -class CodecProxy::NativeCallbacks::Natives : public mozilla::jni::NativeImpl<NativeCallbacks, Impl> -{ -public: - static const JNINativeMethod methods[5]; -}; - -template<class Impl> -const JNINativeMethod CodecProxy::NativeCallbacks::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<CodecProxy::NativeCallbacks::DisposeNative_t>( - mozilla::jni::NativeStub<CodecProxy::NativeCallbacks::DisposeNative_t, Impl> - ::template Wrap<&Impl::DisposeNative>), - - mozilla::jni::MakeNativeMethod<CodecProxy::NativeCallbacks::OnError_t>( - mozilla::jni::NativeStub<CodecProxy::NativeCallbacks::OnError_t, Impl> - ::template Wrap<&Impl::OnError>), - - mozilla::jni::MakeNativeMethod<CodecProxy::NativeCallbacks::OnInputExhausted_t>( - mozilla::jni::NativeStub<CodecProxy::NativeCallbacks::OnInputExhausted_t, Impl> - ::template Wrap<&Impl::OnInputExhausted>), - - mozilla::jni::MakeNativeMethod<CodecProxy::NativeCallbacks::OnOutput_t>( - mozilla::jni::NativeStub<CodecProxy::NativeCallbacks::OnOutput_t, Impl> - ::template Wrap<&Impl::OnOutput>), - - mozilla::jni::MakeNativeMethod<CodecProxy::NativeCallbacks::OnOutputFormatChanged_t>( - mozilla::jni::NativeStub<CodecProxy::NativeCallbacks::OnOutputFormatChanged_t, Impl> - ::template Wrap<&Impl::OnOutputFormatChanged>) -}; - -template<class Impl> -class MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives : public mozilla::jni::NativeImpl<NativeMediaDrmProxyCallbacks, Impl> -{ -public: - static const JNINativeMethod methods[7]; -}; - -template<class Impl> -const JNINativeMethod MediaDrmProxy::NativeMediaDrmProxyCallbacks::Natives<Impl>::methods[] = { - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t, Impl> - ::template Wrap<&Impl::OnRejectPromise>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t, Impl> - ::template Wrap<&Impl::OnSessionBatchedKeyChanged>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t, Impl> - ::template Wrap<&Impl::OnSessionClosed>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t, Impl> - ::template Wrap<&Impl::OnSessionCreated>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t, Impl> - ::template Wrap<&Impl::OnSessionError>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t, Impl> - ::template Wrap<&Impl::OnSessionMessage>), - - mozilla::jni::MakeNativeMethod<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t>( - mozilla::jni::NativeStub<MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t, Impl> - ::template Wrap<&Impl::OnSessionUpdated>) -}; - -} /* java */ -} /* mozilla */ -#endif // FennecJNINatives_h diff --git a/widget/android/fennec/FennecJNIWrappers.cpp b/widget/android/fennec/FennecJNIWrappers.cpp deleted file mode 100644 index f8be6833b..000000000 --- a/widget/android/fennec/FennecJNIWrappers.cpp +++ /dev/null @@ -1,443 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#include "FennecJNIWrappers.h" -#include "mozilla/jni/Accessors.h" - -namespace mozilla { -namespace java { - -const char ANRReporter::name[] = - "org/mozilla/gecko/ANRReporter"; - -constexpr char ANRReporter::GetNativeStack_t::name[]; -constexpr char ANRReporter::GetNativeStack_t::signature[]; - -constexpr char ANRReporter::ReleaseNativeStack_t::name[]; -constexpr char ANRReporter::ReleaseNativeStack_t::signature[]; - -constexpr char ANRReporter::RequestNativeStack_t::name[]; -constexpr char ANRReporter::RequestNativeStack_t::signature[]; - -const char DownloadsIntegration::name[] = - "org/mozilla/gecko/DownloadsIntegration"; - -constexpr char DownloadsIntegration::GetTemporaryDownloadDirectory_t::name[]; -constexpr char DownloadsIntegration::GetTemporaryDownloadDirectory_t::signature[]; - -auto DownloadsIntegration::GetTemporaryDownloadDirectory() -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetTemporaryDownloadDirectory_t>::Call(DownloadsIntegration::Context(), nullptr); -} - -constexpr char DownloadsIntegration::ScanMedia_t::name[]; -constexpr char DownloadsIntegration::ScanMedia_t::signature[]; - -auto DownloadsIntegration::ScanMedia(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> void -{ - return mozilla::jni::Method<ScanMedia_t>::Call(DownloadsIntegration::Context(), nullptr, a0, a1); -} - -const char GeckoJavaSampler::name[] = - "org/mozilla/gecko/GeckoJavaSampler"; - -constexpr char GeckoJavaSampler::GetFrameName_t::name[]; -constexpr char GeckoJavaSampler::GetFrameName_t::signature[]; - -auto GeckoJavaSampler::GetFrameName(int32_t a0, int32_t a1, int32_t a2) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetFrameName_t>::Call(GeckoJavaSampler::Context(), nullptr, a0, a1, a2); -} - -constexpr char GeckoJavaSampler::GetProfilerTime_t::name[]; -constexpr char GeckoJavaSampler::GetProfilerTime_t::signature[]; - -constexpr char GeckoJavaSampler::GetSampleTime_t::name[]; -constexpr char GeckoJavaSampler::GetSampleTime_t::signature[]; - -auto GeckoJavaSampler::GetSampleTime(int32_t a0, int32_t a1) -> double -{ - return mozilla::jni::Method<GetSampleTime_t>::Call(GeckoJavaSampler::Context(), nullptr, a0, a1); -} - -constexpr char GeckoJavaSampler::GetThreadName_t::name[]; -constexpr char GeckoJavaSampler::GetThreadName_t::signature[]; - -auto GeckoJavaSampler::GetThreadName(int32_t a0) -> mozilla::jni::String::LocalRef -{ - return mozilla::jni::Method<GetThreadName_t>::Call(GeckoJavaSampler::Context(), nullptr, a0); -} - -constexpr char GeckoJavaSampler::Pause_t::name[]; -constexpr char GeckoJavaSampler::Pause_t::signature[]; - -auto GeckoJavaSampler::Pause() -> void -{ - return mozilla::jni::Method<Pause_t>::Call(GeckoJavaSampler::Context(), nullptr); -} - -constexpr char GeckoJavaSampler::Start_t::name[]; -constexpr char GeckoJavaSampler::Start_t::signature[]; - -auto GeckoJavaSampler::Start(int32_t a0, int32_t a1) -> void -{ - return mozilla::jni::Method<Start_t>::Call(GeckoJavaSampler::Context(), nullptr, a0, a1); -} - -constexpr char GeckoJavaSampler::Stop_t::name[]; -constexpr char GeckoJavaSampler::Stop_t::signature[]; - -auto GeckoJavaSampler::Stop() -> void -{ - return mozilla::jni::Method<Stop_t>::Call(GeckoJavaSampler::Context(), nullptr); -} - -constexpr char GeckoJavaSampler::Unpause_t::name[]; -constexpr char GeckoJavaSampler::Unpause_t::signature[]; - -auto GeckoJavaSampler::Unpause() -> void -{ - return mozilla::jni::Method<Unpause_t>::Call(GeckoJavaSampler::Context(), nullptr); -} - -const char MemoryMonitor::name[] = - "org/mozilla/gecko/MemoryMonitor"; - -constexpr char MemoryMonitor::DispatchMemoryPressure_t::name[]; -constexpr char MemoryMonitor::DispatchMemoryPressure_t::signature[]; - -const char PresentationMediaPlayerManager::name[] = - "org/mozilla/gecko/PresentationMediaPlayerManager"; - -constexpr char PresentationMediaPlayerManager::AddPresentationSurface_t::name[]; -constexpr char PresentationMediaPlayerManager::AddPresentationSurface_t::signature[]; - -constexpr char PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t::name[]; -constexpr char PresentationMediaPlayerManager::InvalidateAndScheduleComposite_t::signature[]; - -constexpr char PresentationMediaPlayerManager::RemovePresentationSurface_t::name[]; -constexpr char PresentationMediaPlayerManager::RemovePresentationSurface_t::signature[]; - -const char ScreenManagerHelper::name[] = - "org/mozilla/gecko/ScreenManagerHelper"; - -constexpr char ScreenManagerHelper::AddDisplay_t::name[]; -constexpr char ScreenManagerHelper::AddDisplay_t::signature[]; - -constexpr char ScreenManagerHelper::RemoveDisplay_t::name[]; -constexpr char ScreenManagerHelper::RemoveDisplay_t::signature[]; - -const char Telemetry::name[] = - "org/mozilla/gecko/Telemetry"; - -constexpr char Telemetry::AddHistogram_t::name[]; -constexpr char Telemetry::AddHistogram_t::signature[]; - -constexpr char Telemetry::AddKeyedHistogram_t::name[]; -constexpr char Telemetry::AddKeyedHistogram_t::signature[]; - -constexpr char Telemetry::AddUIEvent_t::name[]; -constexpr char Telemetry::AddUIEvent_t::signature[]; - -constexpr char Telemetry::StartUISession_t::name[]; -constexpr char Telemetry::StartUISession_t::signature[]; - -constexpr char Telemetry::StopUISession_t::name[]; -constexpr char Telemetry::StopUISession_t::signature[]; - -const char ThumbnailHelper::name[] = - "org/mozilla/gecko/ThumbnailHelper"; - -constexpr char ThumbnailHelper::NotifyThumbnail_t::name[]; -constexpr char ThumbnailHelper::NotifyThumbnail_t::signature[]; - -auto ThumbnailHelper::NotifyThumbnail(mozilla::jni::ByteBuffer::Param a0, mozilla::jni::Object::Param a1, bool a2, bool a3) -> void -{ - return mozilla::jni::Method<NotifyThumbnail_t>::Call(ThumbnailHelper::Context(), nullptr, a0, a1, a2, a3); -} - -constexpr char ThumbnailHelper::RequestThumbnail_t::name[]; -constexpr char ThumbnailHelper::RequestThumbnail_t::signature[]; - -const char ZoomedView::name[] = - "org/mozilla/gecko/ZoomedView"; - -constexpr char ZoomedView::RequestZoomedViewData_t::name[]; -constexpr char ZoomedView::RequestZoomedViewData_t::signature[]; - -const char AudioFocusAgent::name[] = - "org/mozilla/gecko/media/AudioFocusAgent"; - -constexpr char AudioFocusAgent::NotifyStartedPlaying_t::name[]; -constexpr char AudioFocusAgent::NotifyStartedPlaying_t::signature[]; - -auto AudioFocusAgent::NotifyStartedPlaying() -> void -{ - return mozilla::jni::Method<NotifyStartedPlaying_t>::Call(AudioFocusAgent::Context(), nullptr); -} - -constexpr char AudioFocusAgent::NotifyStoppedPlaying_t::name[]; -constexpr char AudioFocusAgent::NotifyStoppedPlaying_t::signature[]; - -auto AudioFocusAgent::NotifyStoppedPlaying() -> void -{ - return mozilla::jni::Method<NotifyStoppedPlaying_t>::Call(AudioFocusAgent::Context(), nullptr); -} - -const char CodecProxy::name[] = - "org/mozilla/gecko/media/CodecProxy"; - -constexpr char CodecProxy::Create_t::name[]; -constexpr char CodecProxy::Create_t::signature[]; - -auto CodecProxy::Create(mozilla::jni::Object::Param a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2) -> CodecProxy::LocalRef -{ - return mozilla::jni::Method<Create_t>::Call(CodecProxy::Context(), nullptr, a0, a1, a2); -} - -constexpr char CodecProxy::Flush_t::name[]; -constexpr char CodecProxy::Flush_t::signature[]; - -auto CodecProxy::Flush() const -> bool -{ - return mozilla::jni::Method<Flush_t>::Call(CodecProxy::mCtx, nullptr); -} - -constexpr char CodecProxy::Input_t::name[]; -constexpr char CodecProxy::Input_t::signature[]; - -auto CodecProxy::Input(mozilla::jni::ByteBuffer::Param a0, mozilla::jni::Object::Param a1, mozilla::jni::Object::Param a2) const -> bool -{ - return mozilla::jni::Method<Input_t>::Call(CodecProxy::mCtx, nullptr, a0, a1, a2); -} - -constexpr char CodecProxy::Release_t::name[]; -constexpr char CodecProxy::Release_t::signature[]; - -auto CodecProxy::Release() const -> bool -{ - return mozilla::jni::Method<Release_t>::Call(CodecProxy::mCtx, nullptr); -} - -const char CodecProxy::NativeCallbacks::name[] = - "org/mozilla/gecko/media/CodecProxy$NativeCallbacks"; - -constexpr char CodecProxy::NativeCallbacks::New_t::name[]; -constexpr char CodecProxy::NativeCallbacks::New_t::signature[]; - -auto CodecProxy::NativeCallbacks::New() -> NativeCallbacks::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(NativeCallbacks::Context(), nullptr); -} - -constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::name[]; -constexpr char CodecProxy::NativeCallbacks::DisposeNative_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnError_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnError_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnInputExhausted_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnOutput_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnOutput_t::signature[]; - -constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::name[]; -constexpr char CodecProxy::NativeCallbacks::OnOutputFormatChanged_t::signature[]; - -const char MediaDrmProxy::name[] = - "org/mozilla/gecko/media/MediaDrmProxy"; - -constexpr char MediaDrmProxy::CanDecode_t::name[]; -constexpr char MediaDrmProxy::CanDecode_t::signature[]; - -auto MediaDrmProxy::CanDecode(mozilla::jni::String::Param a0) -> bool -{ - return mozilla::jni::Method<CanDecode_t>::Call(MediaDrmProxy::Context(), nullptr, a0); -} - -constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::name[]; -constexpr char MediaDrmProxy::IsCryptoSchemeSupported_t::signature[]; - -auto MediaDrmProxy::IsCryptoSchemeSupported(mozilla::jni::String::Param a0, mozilla::jni::String::Param a1) -> bool -{ - return mozilla::jni::Method<IsCryptoSchemeSupported_t>::Call(MediaDrmProxy::Context(), nullptr, a0, a1); -} - -constexpr char MediaDrmProxy::CloseSession_t::name[]; -constexpr char MediaDrmProxy::CloseSession_t::signature[]; - -auto MediaDrmProxy::CloseSession(int32_t a0, mozilla::jni::String::Param a1) const -> void -{ - return mozilla::jni::Method<CloseSession_t>::Call(MediaDrmProxy::mCtx, nullptr, a0, a1); -} - -constexpr char MediaDrmProxy::Create_t::name[]; -constexpr char MediaDrmProxy::Create_t::signature[]; - -auto MediaDrmProxy::Create(mozilla::jni::String::Param a0, mozilla::jni::Object::Param a1, bool a2) -> MediaDrmProxy::LocalRef -{ - return mozilla::jni::Method<Create_t>::Call(MediaDrmProxy::Context(), nullptr, a0, a1, a2); -} - -constexpr char MediaDrmProxy::CreateSession_t::name[]; -constexpr char MediaDrmProxy::CreateSession_t::signature[]; - -auto MediaDrmProxy::CreateSession(int32_t a0, int32_t a1, mozilla::jni::String::Param a2, mozilla::jni::ByteArray::Param a3) const -> void -{ - return mozilla::jni::Method<CreateSession_t>::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2, a3); -} - -constexpr char MediaDrmProxy::Destroy_t::name[]; -constexpr char MediaDrmProxy::Destroy_t::signature[]; - -auto MediaDrmProxy::Destroy() const -> void -{ - return mozilla::jni::Method<Destroy_t>::Call(MediaDrmProxy::mCtx, nullptr); -} - -constexpr char MediaDrmProxy::IsSchemeSupported_t::name[]; -constexpr char MediaDrmProxy::IsSchemeSupported_t::signature[]; - -auto MediaDrmProxy::IsSchemeSupported(mozilla::jni::String::Param a0) -> bool -{ - return mozilla::jni::Method<IsSchemeSupported_t>::Call(MediaDrmProxy::Context(), nullptr, a0); -} - -constexpr char MediaDrmProxy::UpdateSession_t::name[]; -constexpr char MediaDrmProxy::UpdateSession_t::signature[]; - -auto MediaDrmProxy::UpdateSession(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::ByteArray::Param a2) const -> void -{ - return mozilla::jni::Method<UpdateSession_t>::Call(MediaDrmProxy::mCtx, nullptr, a0, a1, a2); -} - -const char16_t MediaDrmProxy::AAC[] = u"audio/mp4a-latm"; - -const char16_t MediaDrmProxy::AVC[] = u"video/avc"; - -const char16_t MediaDrmProxy::OPUS[] = u"audio/opus"; - -const char16_t MediaDrmProxy::VORBIS[] = u"audio/vorbis"; - -const char16_t MediaDrmProxy::VP8[] = u"video/x-vnd.on2.vp8"; - -const char16_t MediaDrmProxy::VP9[] = u"video/x-vnd.on2.vp9"; - -const char MediaDrmProxy::NativeMediaDrmProxyCallbacks::name[] = - "org/mozilla/gecko/media/MediaDrmProxy$NativeMediaDrmProxyCallbacks"; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::New_t::signature[]; - -auto MediaDrmProxy::NativeMediaDrmProxyCallbacks::New() -> NativeMediaDrmProxyCallbacks::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(NativeMediaDrmProxyCallbacks::Context(), nullptr); -} - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnRejectPromise_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionBatchedKeyChanged_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionClosed_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionCreated_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionError_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionMessage_t::signature[]; - -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::name[]; -constexpr char MediaDrmProxy::NativeMediaDrmProxyCallbacks::OnSessionUpdated_t::signature[]; - -const char Sample::name[] = - "org/mozilla/gecko/media/Sample"; - -constexpr char Sample::WriteToByteBuffer_t::name[]; -constexpr char Sample::WriteToByteBuffer_t::signature[]; - -auto Sample::WriteToByteBuffer(mozilla::jni::ByteBuffer::Param a0) const -> void -{ - return mozilla::jni::Method<WriteToByteBuffer_t>::Call(Sample::mCtx, nullptr, a0); -} - -constexpr char Sample::Info_t::name[]; -constexpr char Sample::Info_t::signature[]; - -auto Sample::Info() const -> mozilla::jni::Object::LocalRef -{ - return mozilla::jni::Field<Info_t>::Get(Sample::mCtx, nullptr); -} - -auto Sample::Info(mozilla::jni::Object::Param a0) const -> void -{ - return mozilla::jni::Field<Info_t>::Set(Sample::mCtx, nullptr, a0); -} - -const char SessionKeyInfo::name[] = - "org/mozilla/gecko/media/SessionKeyInfo"; - -constexpr char SessionKeyInfo::New_t::name[]; -constexpr char SessionKeyInfo::New_t::signature[]; - -auto SessionKeyInfo::New(mozilla::jni::ByteArray::Param a0, int32_t a1) -> SessionKeyInfo::LocalRef -{ - return mozilla::jni::Constructor<New_t>::Call(SessionKeyInfo::Context(), nullptr, a0, a1); -} - -constexpr char SessionKeyInfo::KeyId_t::name[]; -constexpr char SessionKeyInfo::KeyId_t::signature[]; - -auto SessionKeyInfo::KeyId() const -> mozilla::jni::ByteArray::LocalRef -{ - return mozilla::jni::Field<KeyId_t>::Get(SessionKeyInfo::mCtx, nullptr); -} - -auto SessionKeyInfo::KeyId(mozilla::jni::ByteArray::Param a0) const -> void -{ - return mozilla::jni::Field<KeyId_t>::Set(SessionKeyInfo::mCtx, nullptr, a0); -} - -constexpr char SessionKeyInfo::Status_t::name[]; -constexpr char SessionKeyInfo::Status_t::signature[]; - -auto SessionKeyInfo::Status() const -> int32_t -{ - return mozilla::jni::Field<Status_t>::Get(SessionKeyInfo::mCtx, nullptr); -} - -auto SessionKeyInfo::Status(int32_t a0) const -> void -{ - return mozilla::jni::Field<Status_t>::Set(SessionKeyInfo::mCtx, nullptr, a0); -} - -const char Restrictions::name[] = - "org/mozilla/gecko/restrictions/Restrictions"; - -constexpr char Restrictions::IsAllowed_t::name[]; -constexpr char Restrictions::IsAllowed_t::signature[]; - -auto Restrictions::IsAllowed(int32_t a0, mozilla::jni::String::Param a1) -> bool -{ - return mozilla::jni::Method<IsAllowed_t>::Call(Restrictions::Context(), nullptr, a0, a1); -} - -constexpr char Restrictions::IsUserRestricted_t::name[]; -constexpr char Restrictions::IsUserRestricted_t::signature[]; - -auto Restrictions::IsUserRestricted() -> bool -{ - return mozilla::jni::Method<IsUserRestricted_t>::Call(Restrictions::Context(), nullptr); -} - -} /* java */ -} /* mozilla */ diff --git a/widget/android/fennec/FennecJNIWrappers.h b/widget/android/fennec/FennecJNIWrappers.h deleted file mode 100644 index bb94cd142..000000000 --- a/widget/android/fennec/FennecJNIWrappers.h +++ /dev/null @@ -1,1469 +0,0 @@ -// GENERATED CODE -// Generated by the Java program at /build/annotationProcessors at compile time -// from annotations on Java methods. To update, change the annotations on the -// corresponding Java methods and rerun the build. Manually updating this file -// will cause your build to fail. - -#ifndef FennecJNIWrappers_h -#define FennecJNIWrappers_h - -#include "mozilla/jni/Refs.h" - -namespace mozilla { -namespace java { - -class ANRReporter : public mozilla::jni::ObjectBase<ANRReporter> -{ -public: - static const char name[]; - - explicit ANRReporter(const Context& ctx) : ObjectBase<ANRReporter>(ctx) {} - - struct GetNativeStack_t { - typedef ANRReporter Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getNativeStack"; - static constexpr char signature[] = - "()Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct ReleaseNativeStack_t { - typedef ANRReporter Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "releaseNativeStack"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct RequestNativeStack_t { - typedef ANRReporter Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "requestNativeStack"; - static constexpr char signature[] = - "(Z)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class DownloadsIntegration : public mozilla::jni::ObjectBase<DownloadsIntegration> -{ -public: - static const char name[]; - - explicit DownloadsIntegration(const Context& ctx) : ObjectBase<DownloadsIntegration>(ctx) {} - - struct GetTemporaryDownloadDirectory_t { - typedef DownloadsIntegration Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getTemporaryDownloadDirectory"; - static constexpr char signature[] = - "()Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetTemporaryDownloadDirectory() -> mozilla::jni::String::LocalRef; - - struct ScanMedia_t { - typedef DownloadsIntegration Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "scanMedia"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto ScanMedia(mozilla::jni::String::Param, mozilla::jni::String::Param) -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - -}; - -class GeckoJavaSampler : public mozilla::jni::ObjectBase<GeckoJavaSampler> -{ -public: - static const char name[]; - - explicit GeckoJavaSampler(const Context& ctx) : ObjectBase<GeckoJavaSampler>(ctx) {} - - struct GetFrameName_t { - typedef GeckoJavaSampler Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "getFrameName"; - static constexpr char signature[] = - "(III)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetFrameName(int32_t, int32_t, int32_t) -> mozilla::jni::String::LocalRef; - - struct GetProfilerTime_t { - typedef GeckoJavaSampler Owner; - typedef double ReturnType; - typedef double SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "getProfilerTime"; - static constexpr char signature[] = - "()D"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct GetSampleTime_t { - typedef GeckoJavaSampler Owner; - typedef double ReturnType; - typedef double SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "getSampleTime"; - static constexpr char signature[] = - "(II)D"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetSampleTime(int32_t, int32_t) -> double; - - struct GetThreadName_t { - typedef GeckoJavaSampler Owner; - typedef mozilla::jni::String::LocalRef ReturnType; - typedef mozilla::jni::String::Param SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "getThreadName"; - static constexpr char signature[] = - "(I)Ljava/lang/String;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto GetThreadName(int32_t) -> mozilla::jni::String::LocalRef; - - struct Pause_t { - typedef GeckoJavaSampler Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "pause"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Pause() -> void; - - struct Start_t { - typedef GeckoJavaSampler Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t> Args; - static constexpr char name[] = "start"; - static constexpr char signature[] = - "(II)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Start(int32_t, int32_t) -> void; - - struct Stop_t { - typedef GeckoJavaSampler Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "stop"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Stop() -> void; - - struct Unpause_t { - typedef GeckoJavaSampler Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "unpause"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Unpause() -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class MemoryMonitor : public mozilla::jni::ObjectBase<MemoryMonitor> -{ -public: - static const char name[]; - - explicit MemoryMonitor(const Context& ctx) : ObjectBase<MemoryMonitor>(ctx) {} - - struct DispatchMemoryPressure_t { - typedef MemoryMonitor Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "dispatchMemoryPressure"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - - template<class Impl> class Natives; -}; - -class PresentationMediaPlayerManager : public mozilla::jni::ObjectBase<PresentationMediaPlayerManager> -{ -public: - static const char name[]; - - explicit PresentationMediaPlayerManager(const Context& ctx) : ObjectBase<PresentationMediaPlayerManager>(ctx) {} - - struct AddPresentationSurface_t { - typedef PresentationMediaPlayerManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "addPresentationSurface"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView;Landroid/view/Surface;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct InvalidateAndScheduleComposite_t { - typedef PresentationMediaPlayerManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "invalidateAndScheduleComposite"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/GeckoView;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct RemovePresentationSurface_t { - typedef PresentationMediaPlayerManager Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "removePresentationSurface"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::UI; - - template<class Impl> class Natives; -}; - -class ScreenManagerHelper : public mozilla::jni::ObjectBase<ScreenManagerHelper> -{ -public: - static const char name[]; - - explicit ScreenManagerHelper(const Context& ctx) : ObjectBase<ScreenManagerHelper>(ctx) {} - - struct AddDisplay_t { - typedef ScreenManagerHelper Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - int32_t, - float> Args; - static constexpr char name[] = "addDisplay"; - static constexpr char signature[] = - "(IIIF)I"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct RemoveDisplay_t { - typedef ScreenManagerHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t> Args; - static constexpr char name[] = "removeDisplay"; - static constexpr char signature[] = - "(I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class Telemetry : public mozilla::jni::ObjectBase<Telemetry> -{ -public: - static const char name[]; - - explicit Telemetry(const Context& ctx) : ObjectBase<Telemetry>(ctx) {} - - struct AddHistogram_t { - typedef Telemetry Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "nativeAddHistogram"; - static constexpr char signature[] = - "(Ljava/lang/String;I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct AddKeyedHistogram_t { - typedef Telemetry Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - int32_t> Args; - static constexpr char name[] = "nativeAddKeyedHistogram"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;I)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct AddUIEvent_t { - typedef Telemetry Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - int64_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "nativeAddUiEvent"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct StartUISession_t { - typedef Telemetry Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - int64_t> Args; - static constexpr char name[] = "nativeStartUiSession"; - static constexpr char signature[] = - "(Ljava/lang/String;J)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct StopUISession_t { - typedef Telemetry Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param, - int64_t> Args; - static constexpr char name[] = "nativeStopUiSession"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;J)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class ThumbnailHelper : public mozilla::jni::ObjectBase<ThumbnailHelper> -{ -public: - static const char name[]; - - explicit ThumbnailHelper(const Context& ctx) : ObjectBase<ThumbnailHelper>(ctx) {} - - struct NotifyThumbnail_t { - typedef ThumbnailHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param, - mozilla::jni::Object::Param, - bool, - bool> Args; - static constexpr char name[] = "notifyThumbnail"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;Lorg/mozilla/gecko/Tab;ZZ)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto NotifyThumbnail(mozilla::jni::ByteBuffer::Param, mozilla::jni::Object::Param, bool, bool) -> void; - - struct RequestThumbnail_t { - typedef ThumbnailHelper Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param, - mozilla::jni::Object::Param, - int32_t, - int32_t, - int32_t> Args; - static constexpr char name[] = "requestThumbnailLocked"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;Lorg/mozilla/gecko/Tab;III)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::PROXY; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class ZoomedView : public mozilla::jni::ObjectBase<ZoomedView> -{ -public: - static const char name[]; - - explicit ZoomedView(const Context& ctx) : ObjectBase<ZoomedView>(ctx) {} - - struct RequestZoomedViewData_t { - typedef ZoomedView Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param, - int32_t, - int32_t, - int32_t, - int32_t, - int32_t, - float> Args; - static constexpr char name[] = "requestZoomedViewData"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;IIIIIF)V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class AudioFocusAgent : public mozilla::jni::ObjectBase<AudioFocusAgent> -{ -public: - static const char name[]; - - explicit AudioFocusAgent(const Context& ctx) : ObjectBase<AudioFocusAgent>(ctx) {} - - struct NotifyStartedPlaying_t { - typedef AudioFocusAgent Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "notifyStartedPlaying"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto NotifyStartedPlaying() -> void; - - struct NotifyStoppedPlaying_t { - typedef AudioFocusAgent Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "notifyStoppedPlaying"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto NotifyStoppedPlaying() -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - -}; - -class CodecProxy : public mozilla::jni::ObjectBase<CodecProxy> -{ -public: - static const char name[]; - - explicit CodecProxy(const Context& ctx) : ObjectBase<CodecProxy>(ctx) {} - - class NativeCallbacks; - - struct Create_t { - typedef CodecProxy Owner; - typedef CodecProxy::LocalRef ReturnType; - typedef CodecProxy::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param, - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "create"; - static constexpr char signature[] = - "(Landroid/media/MediaFormat;Landroid/view/Surface;Lorg/mozilla/gecko/media/CodecProxy$Callbacks;)Lorg/mozilla/gecko/media/CodecProxy;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Create(mozilla::jni::Object::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param) -> CodecProxy::LocalRef; - - struct Flush_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "flush"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Flush() const -> bool; - - struct Input_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param, - mozilla::jni::Object::Param, - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "input"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;Landroid/media/MediaCodec$BufferInfo;Landroid/media/MediaCodec$CryptoInfo;)Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Input(mozilla::jni::ByteBuffer::Param, mozilla::jni::Object::Param, mozilla::jni::Object::Param) const -> bool; - - struct Release_t { - typedef CodecProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "release"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Release() const -> bool; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class CodecProxy::NativeCallbacks : public mozilla::jni::ObjectBase<NativeCallbacks> -{ -public: - static const char name[]; - - explicit NativeCallbacks(const Context& ctx) : ObjectBase<NativeCallbacks>(ctx) {} - - struct New_t { - typedef NativeCallbacks Owner; - typedef NativeCallbacks::LocalRef ReturnType; - typedef NativeCallbacks::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeCallbacks::LocalRef; - - struct DisposeNative_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "disposeNative"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnError_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - bool> Args; - static constexpr char name[] = "onError"; - static constexpr char signature[] = - "(Z)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnInputExhausted_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "onInputExhausted"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnOutput_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onOutput"; - static constexpr char signature[] = - "(Lorg/mozilla/gecko/media/Sample;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - struct OnOutputFormatChanged_t { - typedef NativeCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::Object::Param> Args; - static constexpr char name[] = "onOutputFormatChanged"; - static constexpr char signature[] = - "(Landroid/media/MediaFormat;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class MediaDrmProxy : public mozilla::jni::ObjectBase<MediaDrmProxy> -{ -public: - static const char name[]; - - explicit MediaDrmProxy(const Context& ctx) : ObjectBase<MediaDrmProxy>(ctx) {} - - class NativeMediaDrmProxyCallbacks; - - struct CanDecode_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "CanDecode"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto CanDecode(mozilla::jni::String::Param) -> bool; - - struct IsCryptoSchemeSupported_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "IsCryptoSchemeSupported"; - static constexpr char signature[] = - "(Ljava/lang/String;Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsCryptoSchemeSupported(mozilla::jni::String::Param, mozilla::jni::String::Param) -> bool; - - struct CloseSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "closeSession"; - static constexpr char signature[] = - "(ILjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CloseSession(int32_t, mozilla::jni::String::Param) const -> void; - - struct Create_t { - typedef MediaDrmProxy Owner; - typedef MediaDrmProxy::LocalRef ReturnType; - typedef MediaDrmProxy::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param, - mozilla::jni::Object::Param, - bool> Args; - static constexpr char name[] = "create"; - static constexpr char signature[] = - "(Ljava/lang/String;Lorg/mozilla/gecko/media/MediaDrmProxy$Callbacks;Z)Lorg/mozilla/gecko/media/MediaDrmProxy;"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto Create(mozilla::jni::String::Param, mozilla::jni::Object::Param, bool) -> MediaDrmProxy::LocalRef; - - struct CreateSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::String::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "createSession"; - static constexpr char signature[] = - "(IILjava/lang/String;[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto CreateSession(int32_t, int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; - - struct Destroy_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "destroy"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Destroy() const -> void; - - struct IsSchemeSupported_t { - typedef MediaDrmProxy Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - mozilla::jni::String::Param> Args; - static constexpr char name[] = "isSchemeSupported"; - static constexpr char signature[] = - "(Ljava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsSchemeSupported(mozilla::jni::String::Param) -> bool; - - struct UpdateSession_t { - typedef MediaDrmProxy Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "updateSession"; - static constexpr char signature[] = - "(ILjava/lang/String;[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto UpdateSession(int32_t, mozilla::jni::String::Param, mozilla::jni::ByteArray::Param) const -> void; - - static const char16_t AAC[]; - - static const char16_t AVC[]; - - static const char16_t OPUS[]; - - static const char16_t VORBIS[]; - - static const char16_t VP8[]; - - static const char16_t VP9[]; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class MediaDrmProxy::NativeMediaDrmProxyCallbacks : public mozilla::jni::ObjectBase<NativeMediaDrmProxyCallbacks> -{ -public: - static const char name[]; - - explicit NativeMediaDrmProxyCallbacks(const Context& ctx) : ObjectBase<NativeMediaDrmProxyCallbacks>(ctx) {} - - struct New_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef NativeMediaDrmProxyCallbacks::LocalRef ReturnType; - typedef NativeMediaDrmProxyCallbacks::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "()V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New() -> NativeMediaDrmProxyCallbacks::LocalRef; - - struct OnRejectPromise_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onRejectPromise"; - static constexpr char signature[] = - "(ILjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionBatchedKeyChanged_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - mozilla::jni::ObjectArray::Param> Args; - static constexpr char name[] = "onSessionBatchedKeyChanged"; - static constexpr char signature[] = - "([B[Lorg/mozilla/gecko/media/SessionKeyInfo;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionClosed_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionClosed"; - static constexpr char signature[] = - "(I[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionCreated_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - int32_t, - mozilla::jni::ByteArray::Param, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionCreated"; - static constexpr char signature[] = - "(II[B[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionError_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "onSessionError"; - static constexpr char signature[] = - "([BLjava/lang/String;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionMessage_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionMessage"; - static constexpr char signature[] = - "([BI[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - struct OnSessionUpdated_t { - typedef NativeMediaDrmProxyCallbacks Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::ByteArray::Param> Args; - static constexpr char name[] = "onSessionUpdated"; - static constexpr char signature[] = - "(I[B)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::GECKO; - }; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - - template<class Impl> class Natives; -}; - -class Sample : public mozilla::jni::ObjectBase<Sample> -{ -public: - static const char name[]; - - explicit Sample(const Context& ctx) : ObjectBase<Sample>(ctx) {} - - struct WriteToByteBuffer_t { - typedef Sample Owner; - typedef void ReturnType; - typedef void SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteBuffer::Param> Args; - static constexpr char name[] = "writeToByteBuffer"; - static constexpr char signature[] = - "(Ljava/nio/ByteBuffer;)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto WriteToByteBuffer(mozilla::jni::ByteBuffer::Param) const -> void; - - struct Info_t { - typedef Sample Owner; - typedef mozilla::jni::Object::LocalRef ReturnType; - typedef mozilla::jni::Object::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "info"; - static constexpr char signature[] = - "Landroid/media/MediaCodec$BufferInfo;"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Info() const -> mozilla::jni::Object::LocalRef; - - auto Info(mozilla::jni::Object::Param) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class SessionKeyInfo : public mozilla::jni::ObjectBase<SessionKeyInfo> -{ -public: - static const char name[]; - - explicit SessionKeyInfo(const Context& ctx) : ObjectBase<SessionKeyInfo>(ctx) {} - - struct New_t { - typedef SessionKeyInfo Owner; - typedef SessionKeyInfo::LocalRef ReturnType; - typedef SessionKeyInfo::Param SetterType; - typedef mozilla::jni::Args< - mozilla::jni::ByteArray::Param, - int32_t> Args; - static constexpr char name[] = "<init>"; - static constexpr char signature[] = - "([BI)V"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto New(mozilla::jni::ByteArray::Param, int32_t) -> SessionKeyInfo::LocalRef; - - struct KeyId_t { - typedef SessionKeyInfo Owner; - typedef mozilla::jni::ByteArray::LocalRef ReturnType; - typedef mozilla::jni::ByteArray::Param SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "keyId"; - static constexpr char signature[] = - "[B"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto KeyId() const -> mozilla::jni::ByteArray::LocalRef; - - auto KeyId(mozilla::jni::ByteArray::Param) const -> void; - - struct Status_t { - typedef SessionKeyInfo Owner; - typedef int32_t ReturnType; - typedef int32_t SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "status"; - static constexpr char signature[] = - "I"; - static const bool isStatic = false; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - auto Status() const -> int32_t; - - auto Status(int32_t) const -> void; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::ANY; - -}; - -class Restrictions : public mozilla::jni::ObjectBase<Restrictions> -{ -public: - static const char name[]; - - explicit Restrictions(const Context& ctx) : ObjectBase<Restrictions>(ctx) {} - - struct IsAllowed_t { - typedef Restrictions Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args< - int32_t, - mozilla::jni::String::Param> Args; - static constexpr char name[] = "isAllowed"; - static constexpr char signature[] = - "(ILjava/lang/String;)Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsAllowed(int32_t, mozilla::jni::String::Param) -> bool; - - struct IsUserRestricted_t { - typedef Restrictions Owner; - typedef bool ReturnType; - typedef bool SetterType; - typedef mozilla::jni::Args<> Args; - static constexpr char name[] = "isUserRestricted"; - static constexpr char signature[] = - "()Z"; - static const bool isStatic = true; - static const mozilla::jni::ExceptionMode exceptionMode = - mozilla::jni::ExceptionMode::ABORT; - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - static const mozilla::jni::DispatchTarget dispatchTarget = - mozilla::jni::DispatchTarget::CURRENT; - }; - - static auto IsUserRestricted() -> bool; - - static const mozilla::jni::CallingThread callingThread = - mozilla::jni::CallingThread::GECKO; - -}; - -} /* java */ -} /* mozilla */ -#endif // FennecJNIWrappers_h diff --git a/widget/android/fennec/MemoryMonitor.h b/widget/android/fennec/MemoryMonitor.h deleted file mode 100644 index c87538424..000000000 --- a/widget/android/fennec/MemoryMonitor.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MemoryMonitor_h -#define MemoryMonitor_h - -#include "FennecJNINatives.h" -#include "nsMemoryPressure.h" - -namespace mozilla { - -class MemoryMonitor final - : public java::MemoryMonitor::Natives<MemoryMonitor> -{ -public: - static void - DispatchMemoryPressure() - { - NS_DispatchMemoryPressure(MemoryPressureState::MemPressure_New); - } -}; - -} // namespace mozilla - -#endif // MemoryMonitor_h diff --git a/widget/android/fennec/Telemetry.h b/widget/android/fennec/Telemetry.h deleted file mode 100644 index 458889ef0..000000000 --- a/widget/android/fennec/Telemetry.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_widget_Telemetry_h__ -#define mozilla_widget_Telemetry_h__ - -#include "FennecJNINatives.h" -#include "nsAppShell.h" -#include "nsIAndroidBridge.h" - -#include "mozilla/Telemetry.h" - -namespace mozilla { -namespace widget { - -class Telemetry final - : public java::Telemetry::Natives<Telemetry> -{ - Telemetry() = delete; - - static already_AddRefed<nsIUITelemetryObserver> - GetObserver() - { - nsAppShell* const appShell = nsAppShell::Get(); - if (!appShell) { - return nullptr; - } - - nsCOMPtr<nsIAndroidBrowserApp> browserApp = appShell->GetBrowserApp(); - nsCOMPtr<nsIUITelemetryObserver> obs; - - if (!browserApp || NS_FAILED(browserApp->GetUITelemetryObserver( - getter_AddRefs(obs))) || !obs) { - return nullptr; - } - - return obs.forget(); - } - -public: - static void - AddHistogram(jni::String::Param aName, int32_t aValue) - { - MOZ_ASSERT(aName); - } - - static void - AddKeyedHistogram(jni::String::Param aName, jni::String::Param aKey, - int32_t aValue) - { - MOZ_ASSERT(aName && aKey); - } - - static void - StartUISession(jni::String::Param aName, int64_t aTimestamp) - { - MOZ_ASSERT(aName); - nsCOMPtr<nsIUITelemetryObserver> obs = GetObserver(); - if (obs) { - obs->StartSession(aName->ToString().get(), aTimestamp); - } - } - - static void - StopUISession(jni::String::Param aName, jni::String::Param aReason, - int64_t aTimestamp) - { - MOZ_ASSERT(aName); - nsCOMPtr<nsIUITelemetryObserver> obs = GetObserver(); - if (obs) { - obs->StopSession(aName->ToString().get(), - aReason ? aReason->ToString().get() : nullptr, - aTimestamp); - } - } - - static void - AddUIEvent(jni::String::Param aAction, jni::String::Param aMethod, - int64_t aTimestamp, jni::String::Param aExtras) - { - MOZ_ASSERT(aAction); - nsCOMPtr<nsIUITelemetryObserver> obs = GetObserver(); - if (obs) { - obs->AddEvent(aAction->ToString().get(), - aMethod ? aMethod->ToString().get() : nullptr, - aTimestamp, - aExtras ? aExtras->ToString().get() : nullptr); - } - } -}; - -} // namespace widget -} // namespace mozilla - -#endif // mozilla_widget_Telemetry_h__ diff --git a/widget/android/fennec/ThumbnailHelper.h b/widget/android/fennec/ThumbnailHelper.h deleted file mode 100644 index 08fae787e..000000000 --- a/widget/android/fennec/ThumbnailHelper.h +++ /dev/null @@ -1,302 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef ThumbnailHelper_h -#define ThumbnailHelper_h - -#include "AndroidBridge.h" -#include "FennecJNINatives.h" -#include "gfxPlatform.h" -#include "mozIDOMWindow.h" -#include "nsAppShell.h" -#include "nsCOMPtr.h" -#include "nsIChannel.h" -#include "nsIDOMWindowUtils.h" -#include "nsIDOMClientRect.h" -#include "nsIDocShell.h" -#include "nsIHttpChannel.h" -#include "nsIPresShell.h" -#include "nsIURI.h" -#include "nsPIDOMWindow.h" -#include "nsPresContext.h" - -#include "mozilla/Preferences.h" - -namespace mozilla { - -class ThumbnailHelper final - : public java::ThumbnailHelper::Natives<ThumbnailHelper> - , public java::ZoomedView::Natives<ThumbnailHelper> -{ - ThumbnailHelper() = delete; - - static already_AddRefed<mozIDOMWindowProxy> - GetWindowForTab(int32_t aTabId) - { - nsAppShell* const appShell = nsAppShell::Get(); - if (!appShell) { - return nullptr; - } - - nsCOMPtr<nsIAndroidBrowserApp> browserApp = appShell->GetBrowserApp(); - if (!browserApp) { - return nullptr; - } - - nsCOMPtr<mozIDOMWindowProxy> window; - nsCOMPtr<nsIBrowserTab> tab; - - if (NS_FAILED(browserApp->GetBrowserTab(aTabId, getter_AddRefs(tab))) || - !tab || - NS_FAILED(tab->GetWindow(getter_AddRefs(window))) || - !window) { - return nullptr; - } - - return window.forget(); - } - - // Decides if we should store thumbnails for a given docshell based on the - // presence of a Cache-Control: no-store header and the - // "browser.cache.disk_cache_ssl" pref. - static bool - ShouldStoreThumbnail(nsIDocShell* docShell) - { - nsCOMPtr<nsIChannel> channel; - if (NS_FAILED(docShell->GetCurrentDocumentChannel( - getter_AddRefs(channel))) || !channel) { - return false; - } - - nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel); - if (!httpChannel) { - // Allow storing non-HTTP thumbnails. - return true; - } - - // Don't store thumbnails for sites that didn't load or have - // Cache-Control: no-store. - uint32_t responseStatus = 0; - bool isNoStoreResponse = false; - - if (NS_FAILED(httpChannel->GetResponseStatus(&responseStatus)) || - (responseStatus / 100) != 2 || - NS_FAILED(httpChannel->IsNoStoreResponse(&isNoStoreResponse)) || - isNoStoreResponse) { - return false; - } - - // Deny storage if we're viewing a HTTPS page with a 'Cache-Control' - // header having a value that is not 'public', unless enabled by user. - nsCOMPtr<nsIURI> uri; - bool isHttps = false; - - if (NS_FAILED(channel->GetURI(getter_AddRefs(uri))) || - !uri || - NS_FAILED(uri->SchemeIs("https", &isHttps))) { - return false; - } - - if (!isHttps || - Preferences::GetBool("browser.cache.disk_cache_ssl", false)) { - // Allow storing non-HTTPS thumbnails, and HTTPS ones if enabled by - // user. - return true; - } - - nsAutoCString cacheControl; - if (NS_FAILED(httpChannel->GetResponseHeader( - NS_LITERAL_CSTRING("Cache-Control"), cacheControl))) { - return false; - } - - if (cacheControl.IsEmpty() || - cacheControl.LowerCaseEqualsLiteral("public")) { - // Allow no cache-control, or public cache-control. - return true; - } - return false; - } - - // Return a non-null nsIDocShell to indicate success. - static already_AddRefed<nsIDocShell> - GetThumbnailAndDocShell(mozIDOMWindowProxy* aWindow, - jni::ByteBuffer::Param aData, - int32_t aThumbWidth, int32_t aThumbHeight, - const CSSRect& aPageRect, float aZoomFactor) - { - nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(aWindow); - nsCOMPtr<nsIDocShell> docShell = win->GetDocShell(); - RefPtr<nsPresContext> presContext; - - if (!docShell || NS_FAILED(docShell->GetPresContext( - getter_AddRefs(presContext))) || !presContext) { - return nullptr; - } - - uint8_t* const data = static_cast<uint8_t*>(aData->Address()); - if (!data) { - return nullptr; - } - - const bool is24bit = !AndroidBridge::Bridge() || - AndroidBridge::Bridge()->GetScreenDepth() == 24; - const uint32_t stride = aThumbWidth * (is24bit ? 4 : 2); - - RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForData( - data, - IntSize(aThumbWidth, aThumbHeight), - stride, - is24bit ? SurfaceFormat::B8G8R8A8 - : SurfaceFormat::R5G6B5_UINT16); - - if (!dt || !dt->IsValid()) { - return nullptr; - } - - nsCOMPtr<nsIPresShell> presShell = presContext->PresShell(); - RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt); - MOZ_ASSERT(context); // checked the draw target above - - context->SetMatrix(context->CurrentMatrix().Scale( - aZoomFactor * float(aThumbWidth) / aPageRect.width, - aZoomFactor * float(aThumbHeight) / aPageRect.height)); - - const nsRect drawRect( - nsPresContext::CSSPixelsToAppUnits(aPageRect.x), - nsPresContext::CSSPixelsToAppUnits(aPageRect.y), - nsPresContext::CSSPixelsToAppUnits(aPageRect.width), - nsPresContext::CSSPixelsToAppUnits(aPageRect.height)); - const uint32_t renderDocFlags = - nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING | - nsIPresShell::RENDER_DOCUMENT_RELATIVE; - const nscolor bgColor = NS_RGB(255, 255, 255); - - if (NS_FAILED(presShell->RenderDocument( - drawRect, renderDocFlags, bgColor, context))) { - return nullptr; - } - - if (is24bit) { - gfxUtils::ConvertBGRAtoRGBA(data, stride * aThumbHeight); - } - - return docShell.forget(); - } - -public: - static void Init() - { - java::ThumbnailHelper::Natives<ThumbnailHelper>::Init(); - java::ZoomedView::Natives<ThumbnailHelper>::Init(); - } - - template<class Functor> - static void OnNativeCall(Functor&& aCall) - { - class IdleEvent : public nsAppShell::LambdaEvent<Functor> - { - using Base = nsAppShell::LambdaEvent<Functor>; - - public: - IdleEvent(Functor&& aCall) - : Base(Forward<Functor>(aCall)) - {} - - void Run() override - { - MessageLoop::current()->PostIdleTask( - NS_NewRunnableFunction(Move(Base::lambda))); - } - }; - - // Invoke RequestThumbnail on the main thread when the thread is idle. - nsAppShell::PostEvent(MakeUnique<IdleEvent>(Forward<Functor>(aCall))); - } - - static void - RequestThumbnail(jni::ByteBuffer::Param aData, jni::Object::Param aTab, - int32_t aTabId, int32_t aWidth, int32_t aHeight) - { - nsCOMPtr<mozIDOMWindowProxy> window = GetWindowForTab(aTabId); - if (!window || !aData) { - java::ThumbnailHelper::NotifyThumbnail( - aData, aTab, /* success */ false, /* store */ false); - return; - } - - // take a screenshot, as wide as possible, proportional to the destination size - nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window); - nsCOMPtr<nsIDOMClientRect> rect; - float pageLeft = 0.0f, pageTop = 0.0f, pageWidth = 0.0f, pageHeight = 0.0f; - - if (!utils || - NS_FAILED(utils->GetRootBounds(getter_AddRefs(rect))) || - !rect || - NS_FAILED(rect->GetLeft(&pageLeft)) || - NS_FAILED(rect->GetTop(&pageTop)) || - NS_FAILED(rect->GetWidth(&pageWidth)) || - NS_FAILED(rect->GetHeight(&pageHeight)) || - int32_t(pageWidth) == 0 || int32_t(pageHeight) == 0) { - java::ThumbnailHelper::NotifyThumbnail( - aData, aTab, /* success */ false, /* store */ false); - return; - } - - const float aspectRatio = float(aWidth) / float(aHeight); - if (pageWidth / aspectRatio < pageHeight) { - pageHeight = pageWidth / aspectRatio; - } else { - pageWidth = pageHeight * aspectRatio; - } - - nsCOMPtr<nsIDocShell> docShell = GetThumbnailAndDocShell( - window, aData, aWidth, aHeight, - CSSRect(pageLeft, pageTop, pageWidth, pageHeight), - /* aZoomFactor */ 1.0f); - const bool success = !!docShell; - const bool store = success ? ShouldStoreThumbnail(docShell) : false; - - java::ThumbnailHelper::NotifyThumbnail(aData, aTab, success, store); - } - - static void - RequestZoomedViewData(jni::ByteBuffer::Param aData, int32_t aTabId, - int32_t aX, int32_t aY, - int32_t aWidth, int32_t aHeight, float aScale) - { - nsCOMPtr<mozIDOMWindowProxy> window = GetWindowForTab(aTabId); - if (!window || !aData) { - return; - } - - nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(window); - nsCOMPtr<nsIDocShell> docShell = win->GetDocShell(); - RefPtr<nsPresContext> presContext; - - if (!docShell || NS_FAILED(docShell->GetPresContext( - getter_AddRefs(presContext))) || !presContext) { - return; - } - - nsCOMPtr<nsIPresShell> presShell = presContext->PresShell(); - LayoutDeviceRect rect = LayoutDeviceRect(aX, aY, aWidth, aHeight); - const float resolution = presShell->GetCumulativeResolution(); - rect.Scale(1.0f / LayoutDeviceToLayerScale(resolution).scale); - - docShell = GetThumbnailAndDocShell( - window, aData, aWidth, aHeight, CSSRect::FromAppUnits( - rect.ToAppUnits(rect, presContext->AppUnitsPerDevPixel())), - aScale); - - if (docShell) { - java::LayerView::UpdateZoomedView(aData); - } - } -}; - -} // namespace mozilla - -#endif // ThumbnailHelper_h diff --git a/widget/android/fennec/moz.build b/widget/android/fennec/moz.build deleted file mode 100644 index 0d6a8e0cd..000000000 --- a/widget/android/fennec/moz.build +++ /dev/null @@ -1,21 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -EXPORTS += [ - 'FennecJNINatives.h', - 'FennecJNIWrappers.h', -] - -UNIFIED_SOURCES += [ - 'FennecJNIWrappers.cpp', -] - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '/widget', - '/widget/android', -] diff --git a/widget/android/jni/Accessors.h b/widget/android/jni/Accessors.h deleted file mode 100644 index fe2cbc9d4..000000000 --- a/widget/android/jni/Accessors.h +++ /dev/null @@ -1,274 +0,0 @@ -#ifndef mozilla_jni_Accessors_h__ -#define mozilla_jni_Accessors_h__ - -#include <jni.h> - -#include "mozilla/jni/Refs.h" -#include "mozilla/jni/Types.h" -#include "mozilla/jni/Utils.h" -#include "AndroidBridge.h" - -namespace mozilla { -namespace jni { - -namespace detail { - -// Helper class to convert an arbitrary type to a jvalue, e.g. Value(123).val. -struct Value -{ - Value(jboolean z) { val.z = z; } - Value(jbyte b) { val.b = b; } - Value(jchar c) { val.c = c; } - Value(jshort s) { val.s = s; } - Value(jint i) { val.i = i; } - Value(jlong j) { val.j = j; } - Value(jfloat f) { val.f = f; } - Value(jdouble d) { val.d = d; } - Value(jobject l) { val.l = l; } - - jvalue val; -}; - -} // namespace detail - -using namespace detail; - -// Base class for Method<>, Field<>, and Constructor<>. -class Accessor -{ - static void GetNsresult(JNIEnv* env, nsresult* rv) - { - if (env->ExceptionCheck()) { -#ifdef MOZ_CHECK_JNI - env->ExceptionDescribe(); -#endif - env->ExceptionClear(); - *rv = NS_ERROR_FAILURE; - } else { - *rv = NS_OK; - } - } - -protected: - // Called after making a JNIEnv call. - template<class Traits> - static void EndAccess(const typename Traits::Owner::Context& ctx, - nsresult* rv) - { - if (Traits::exceptionMode == ExceptionMode::ABORT) { - MOZ_CATCH_JNI_EXCEPTION(ctx.Env()); - - } else if (Traits::exceptionMode == ExceptionMode::NSRESULT) { - GetNsresult(ctx.Env(), rv); - } - } -}; - - -// Member<> is used to call a JNI method given a traits class. -template<class Traits, typename ReturnType = typename Traits::ReturnType> -class Method : public Accessor -{ - typedef Accessor Base; - typedef typename Traits::Owner::Context Context; - -protected: - static jmethodID sID; - - static void BeginAccess(const Context& ctx) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - static_assert(Traits::dispatchTarget == DispatchTarget::CURRENT, - "Dispatching not supported for method call"); - - if (sID) { - return; - } - - if (Traits::isStatic) { - MOZ_ALWAYS_TRUE(sID = AndroidBridge::GetStaticMethodID( - ctx.Env(), ctx.ClassRef(), Traits::name, Traits::signature)); - } else { - MOZ_ALWAYS_TRUE(sID = AndroidBridge::GetMethodID( - ctx.Env(), ctx.ClassRef(), Traits::name, Traits::signature)); - } - } - - static void EndAccess(const Context& ctx, nsresult* rv) - { - return Base::EndAccess<Traits>(ctx, rv); - } - -public: - template<typename... Args> - static ReturnType Call(const Context& ctx, nsresult* rv, const Args&... args) - { - JNIEnv* const env = ctx.Env(); - BeginAccess(ctx); - - jvalue jargs[] = { - Value(TypeAdapter<Args>::FromNative(env, args)).val ... - }; - - auto result = TypeAdapter<ReturnType>::ToNative(env, - Traits::isStatic ? - (env->*TypeAdapter<ReturnType>::StaticCall)( - ctx.RawClassRef(), sID, jargs) : - (env->*TypeAdapter<ReturnType>::Call)( - ctx.Get(), sID, jargs)); - - EndAccess(ctx, rv); - return result; - } -}; - -// Define sID member. -template<class T, typename R> jmethodID Method<T, R>::sID; - - -// Specialize void because C++ forbids us from -// using a "void" temporary result variable. -template<class Traits> -class Method<Traits, void> : public Method<Traits, bool> -{ - typedef Method<Traits, bool> Base; - typedef typename Traits::Owner::Context Context; - -public: - template<typename... Args> - static void Call(const Context& ctx, nsresult* rv, - const Args&... args) - { - JNIEnv* const env = ctx.Env(); - Base::BeginAccess(ctx); - - jvalue jargs[] = { - Value(TypeAdapter<Args>::FromNative(env, args)).val ... - }; - - if (Traits::isStatic) { - env->CallStaticVoidMethodA(ctx.RawClassRef(), Base::sID, jargs); - } else { - env->CallVoidMethodA(ctx.Get(), Base::sID, jargs); - } - - Base::EndAccess(ctx, rv); - } -}; - - -// Constructor<> is used to construct a JNI instance given a traits class. -template<class Traits> -class Constructor : protected Method<Traits, typename Traits::ReturnType> { - typedef typename Traits::Owner::Context Context; - typedef typename Traits::ReturnType ReturnType; - typedef Method<Traits, ReturnType> Base; - -public: - template<typename... Args> - static ReturnType Call(const Context& ctx, nsresult* rv, - const Args&... args) - { - JNIEnv* const env = ctx.Env(); - Base::BeginAccess(ctx); - - jvalue jargs[] = { - Value(TypeAdapter<Args>::FromNative(env, args)).val ... - }; - - auto result = TypeAdapter<ReturnType>::ToNative( - env, env->NewObjectA(ctx.RawClassRef(), Base::sID, jargs)); - - Base::EndAccess(ctx, rv); - return result; - } -}; - - -// Field<> is used to access a JNI field given a traits class. -template<class Traits> -class Field : public Accessor -{ - typedef Accessor Base; - typedef typename Traits::Owner::Context Context; - typedef typename Traits::ReturnType GetterType; - typedef typename Traits::SetterType SetterType; - -private: - - static jfieldID sID; - - static void BeginAccess(const Context& ctx) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - static_assert(Traits::dispatchTarget == DispatchTarget::CURRENT, - "Dispatching not supported for field access"); - - if (sID) { - return; - } - - if (Traits::isStatic) { - MOZ_ALWAYS_TRUE(sID = AndroidBridge::GetStaticFieldID( - ctx.Env(), ctx.ClassRef(), Traits::name, Traits::signature)); - } else { - MOZ_ALWAYS_TRUE(sID = AndroidBridge::GetFieldID( - ctx.Env(), ctx.ClassRef(), Traits::name, Traits::signature)); - } - } - - static void EndAccess(const Context& ctx, nsresult* rv) - { - return Base::EndAccess<Traits>(ctx, rv); - } - -public: - static GetterType Get(const Context& ctx, nsresult* rv) - { - JNIEnv* const env = ctx.Env(); - BeginAccess(ctx); - - auto result = TypeAdapter<GetterType>::ToNative( - env, Traits::isStatic ? - - (env->*TypeAdapter<GetterType>::StaticGet) - (ctx.RawClassRef(), sID) : - - (env->*TypeAdapter<GetterType>::Get) - (ctx.Get(), sID)); - - EndAccess(ctx, rv); - return result; - } - - static void Set(const Context& ctx, nsresult* rv, SetterType val) - { - JNIEnv* const env = ctx.Env(); - BeginAccess(ctx); - - if (Traits::isStatic) { - (env->*TypeAdapter<SetterType>::StaticSet)( - ctx.RawClassRef(), sID, - TypeAdapter<SetterType>::FromNative(env, val)); - } else { - (env->*TypeAdapter<SetterType>::Set)( - ctx.Get(), sID, - TypeAdapter<SetterType>::FromNative(env, val)); - } - - EndAccess(ctx, rv); - } -}; - -// Define sID member. -template<class T> jfieldID Field<T>::sID; - - -// Define the sClassRef member declared in Refs.h and -// used by Method and Field above. -template<class C, typename T> jclass Context<C, T>::sClassRef; - -} // namespace jni -} // namespace mozilla - -#endif // mozilla_jni_Accessors_h__ diff --git a/widget/android/jni/Natives.h b/widget/android/jni/Natives.h deleted file mode 100644 index 511d96a87..000000000 --- a/widget/android/jni/Natives.h +++ /dev/null @@ -1,707 +0,0 @@ -#ifndef mozilla_jni_Natives_h__ -#define mozilla_jni_Natives_h__ - -#include <jni.h> - -#include "mozilla/IndexSequence.h" -#include "mozilla/Move.h" -#include "mozilla/Tuple.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/WeakPtr.h" -#include "mozilla/Unused.h" -#include "mozilla/jni/Accessors.h" -#include "mozilla/jni/Refs.h" -#include "mozilla/jni/Types.h" -#include "mozilla/jni/Utils.h" - -namespace mozilla { -namespace jni { - -/** - * C++ classes implementing instance (non-static) native methods can choose - * from one of two ownership models, when associating a C++ object with a Java - * instance. - * - * * If the C++ class inherits from mozilla::SupportsWeakPtr, weak pointers - * will be used. The Java instance will store and own the pointer to a - * WeakPtr object. The C++ class itself is otherwise not owned or directly - * referenced. To attach a Java instance to a C++ instance, pass in a pointer - * to the C++ class (i.e. MyClass*). - * - * class MyClass : public SupportsWeakPtr<MyClass> - * , public MyJavaClass::Natives<MyClass> - * { - * // ... - * - * public: - * MOZ_DECLARE_WEAKREFERENCE_TYPENAME(MyClass) - * using MyJavaClass::Natives<MyClass>::Dispose; - * - * void AttachTo(const MyJavaClass::LocalRef& instance) - * { - * MyJavaClass::Natives<MyClass>::AttachInstance(instance, this); - * - * // "instance" does NOT own "this", so the C++ object - * // lifetime is separate from the Java object lifetime. - * } - * }; - * - * * If the C++ class doesn't inherit from mozilla::SupportsWeakPtr, the Java - * instance will store and own a pointer to the C++ object itself. This - * pointer must not be stored or deleted elsewhere. To attach a Java instance - * to a C++ instance, pass in a reference to a UniquePtr of the C++ class - * (i.e. UniquePtr<MyClass>). - * - * class MyClass : public MyJavaClass::Natives<MyClass> - * { - * // ... - * - * public: - * using MyJavaClass::Natives<MyClass>::Dispose; - * - * static void AttachTo(const MyJavaClass::LocalRef& instance) - * { - * MyJavaClass::Natives<MyClass>::AttachInstance( - * instance, mozilla::MakeUnique<MyClass>()); - * - * // "instance" owns the newly created C++ object, so the C++ - * // object is destroyed as soon as instance.dispose() is called. - * } - * }; - */ - -namespace detail { - -inline uintptr_t CheckNativeHandle(JNIEnv* env, uintptr_t handle) -{ - if (!handle) { - if (!env->ExceptionCheck()) { - ThrowException(env, "java/lang/NullPointerException", - "Null native pointer"); - } - return 0; - } - return handle; -} - -template<class Impl, bool UseWeakPtr = mozilla::IsBaseOf< - SupportsWeakPtr<Impl>, Impl>::value /* = false */> -struct NativePtr -{ - static Impl* Get(JNIEnv* env, jobject instance) - { - return reinterpret_cast<Impl*>(CheckNativeHandle( - env, GetNativeHandle(env, instance))); - } - - template<class LocalRef> - static Impl* Get(const LocalRef& instance) - { - return Get(instance.Env(), instance.Get()); - } - - template<class LocalRef> - static void Set(const LocalRef& instance, UniquePtr<Impl>&& ptr) - { - Clear(instance); - SetNativeHandle(instance.Env(), instance.Get(), - reinterpret_cast<uintptr_t>(ptr.release())); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - } - - template<class LocalRef> - static void Clear(const LocalRef& instance) - { - UniquePtr<Impl> ptr(reinterpret_cast<Impl*>( - GetNativeHandle(instance.Env(), instance.Get()))); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - - if (ptr) { - SetNativeHandle(instance.Env(), instance.Get(), 0); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - } - } -}; - -template<class Impl> -struct NativePtr<Impl, /* UseWeakPtr = */ true> -{ - static Impl* Get(JNIEnv* env, jobject instance) - { - const auto ptr = reinterpret_cast<WeakPtr<Impl>*>( - CheckNativeHandle(env, GetNativeHandle(env, instance))); - if (!ptr) { - return nullptr; - } - - Impl* const impl = *ptr; - if (!impl) { - ThrowException(env, "java/lang/NullPointerException", - "Native object already released"); - } - return impl; - } - - template<class LocalRef> - static Impl* Get(const LocalRef& instance) - { - return Get(instance.Env(), instance.Get()); - } - - template<class LocalRef> - static void Set(const LocalRef& instance, Impl* ptr) - { - Clear(instance); - SetNativeHandle(instance.Env(), instance.Get(), - reinterpret_cast<uintptr_t>(new WeakPtr<Impl>(ptr))); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - } - - template<class LocalRef> - static void Clear(const LocalRef& instance) - { - const auto ptr = reinterpret_cast<WeakPtr<Impl>*>( - GetNativeHandle(instance.Env(), instance.Get())); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - - if (ptr) { - SetNativeHandle(instance.Env(), instance.Get(), 0); - MOZ_CATCH_JNI_EXCEPTION(instance.Env()); - delete ptr; - } - } -}; - -} // namespace detail - -using namespace detail; - -/** - * For JNI native methods that are dispatched to a proxy, i.e. using - * @WrapForJNI(dispatchTo = "proxy"), the implementing C++ class must provide a - * OnNativeCall member. Subsequently, every native call is automatically - * wrapped in a functor object, and the object is passed to OnNativeCall. The - * OnNativeCall implementation can choose to invoke the call, save it, dispatch - * it to a different thread, etc. Each copy of functor may only be invoked - * once. - * - * class MyClass : public MyJavaClass::Natives<MyClass> - * { - * // ... - * - * template<class Functor> - * class ProxyRunnable final : public Runnable - * { - * Functor mCall; - * public: - * ProxyRunnable(Functor&& call) : mCall(mozilla::Move(call)) {} - * virtual void run() override { mCall(); } - * }; - * - * public: - * template<class Functor> - * static void OnNativeCall(Functor&& call) - * { - * RunOnAnotherThread(new ProxyRunnable(mozilla::Move(call))); - * } - * }; - */ - -namespace detail { - -// ProxyArg is used to handle JNI ref arguments for proxies. Because a proxied -// call may happen outside of the original JNI native call, we must save all -// JNI ref arguments as global refs to avoid the arguments going out of scope. -template<typename T> -struct ProxyArg -{ - static_assert(mozilla::IsPod<T>::value, "T must be primitive type"); - - // Primitive types can be saved by value. - typedef T Type; - typedef typename TypeAdapter<T>::JNIType JNIType; - - static void Clear(JNIEnv* env, Type&) {} - - static Type From(JNIEnv* env, JNIType val) - { - return TypeAdapter<T>::ToNative(env, val); - } -}; - -template<class C, typename T> -struct ProxyArg<Ref<C, T>> -{ - // Ref types need to be saved by global ref. - typedef typename C::GlobalRef Type; - typedef typename TypeAdapter<Ref<C, T>>::JNIType JNIType; - - static void Clear(JNIEnv* env, Type& ref) { ref.Clear(env); } - - static Type From(JNIEnv* env, JNIType val) - { - return Type(env, C::Ref::From(val)); - } -}; - -template<typename C> struct ProxyArg<const C&> : ProxyArg<C> {}; -template<> struct ProxyArg<StringParam> : ProxyArg<String::Ref> {}; -template<class C> struct ProxyArg<LocalRef<C>> : ProxyArg<typename C::Ref> {}; - -// ProxyNativeCall implements the functor object that is passed to OnNativeCall -template<class Impl, class Owner, bool IsStatic, - bool HasThisArg /* has instance/class local ref in the call */, - typename... Args> -class ProxyNativeCall : public AbstractCall -{ - // "this arg" refers to the Class::LocalRef (for static methods) or - // Owner::LocalRef (for instance methods) that we optionally (as indicated - // by HasThisArg) pass into the destination C++ function. - typedef typename mozilla::Conditional<IsStatic, - Class, Owner>::Type ThisArgClass; - typedef typename mozilla::Conditional<IsStatic, - jclass, jobject>::Type ThisArgJNIType; - - // Type signature of the destination C++ function, which matches the - // Method template parameter in NativeStubImpl::Wrap. - typedef typename mozilla::Conditional<IsStatic, - typename mozilla::Conditional<HasThisArg, - void (*) (const Class::LocalRef&, Args...), - void (*) (Args...)>::Type, - typename mozilla::Conditional<HasThisArg, - void (Impl::*) (const typename Owner::LocalRef&, Args...), - void (Impl::*) (Args...)>::Type>::Type NativeCallType; - - // Destination C++ function. - NativeCallType mNativeCall; - // Saved this arg. - typename ThisArgClass::GlobalRef mThisArg; - // Saved arguments. - mozilla::Tuple<typename ProxyArg<Args>::Type...> mArgs; - - // We cannot use IsStatic and HasThisArg directly (without going through - // extra hoops) because GCC complains about invalid overloads, so we use - // another pair of template parameters, Static and ThisArg. - - template<bool Static, bool ThisArg, size_t... Indices> - typename mozilla::EnableIf<Static && ThisArg, void>::Type - Call(const Class::LocalRef& cls, - mozilla::IndexSequence<Indices...>) const - { - (*mNativeCall)(cls, mozilla::Get<Indices>(mArgs)...); - } - - template<bool Static, bool ThisArg, size_t... Indices> - typename mozilla::EnableIf<Static && !ThisArg, void>::Type - Call(const Class::LocalRef& cls, - mozilla::IndexSequence<Indices...>) const - { - (*mNativeCall)(mozilla::Get<Indices>(mArgs)...); - } - - template<bool Static, bool ThisArg, size_t... Indices> - typename mozilla::EnableIf<!Static && ThisArg, void>::Type - Call(const typename Owner::LocalRef& inst, - mozilla::IndexSequence<Indices...>) const - { - Impl* const impl = NativePtr<Impl>::Get(inst); - MOZ_CATCH_JNI_EXCEPTION(inst.Env()); - (impl->*mNativeCall)(inst, mozilla::Get<Indices>(mArgs)...); - } - - template<bool Static, bool ThisArg, size_t... Indices> - typename mozilla::EnableIf<!Static && !ThisArg, void>::Type - Call(const typename Owner::LocalRef& inst, - mozilla::IndexSequence<Indices...>) const - { - Impl* const impl = NativePtr<Impl>::Get(inst); - MOZ_CATCH_JNI_EXCEPTION(inst.Env()); - (impl->*mNativeCall)(mozilla::Get<Indices>(mArgs)...); - } - - template<size_t... Indices> - void Clear(JNIEnv* env, mozilla::IndexSequence<Indices...>) - { - int dummy[] = { - (ProxyArg<Args>::Clear(env, Get<Indices>(mArgs)), 0)... - }; - mozilla::Unused << dummy; - } - -public: - // The class that implements the call target. - typedef Impl TargetClass; - typedef typename ThisArgClass::Param ThisArgType; - - static const bool isStatic = IsStatic; - - ProxyNativeCall(ThisArgJNIType thisArg, - NativeCallType nativeCall, - JNIEnv* env, - typename ProxyArg<Args>::JNIType... args) - : mNativeCall(nativeCall) - , mThisArg(env, ThisArgClass::Ref::From(thisArg)) - , mArgs(ProxyArg<Args>::From(env, args)...) - {} - - ProxyNativeCall(ProxyNativeCall&&) = default; - ProxyNativeCall(const ProxyNativeCall&) = default; - - // Get class ref for static calls or object ref for instance calls. - typename ThisArgClass::Param GetThisArg() const { return mThisArg; } - - // Return if target is the given function pointer / pointer-to-member. - // Because we can only compare pointers of the same type, we use a - // templated overload that is chosen only if given a different type of - // pointer than our target pointer type. - bool IsTarget(NativeCallType call) const { return call == mNativeCall; } - template<typename T> bool IsTarget(T&&) const { return false; } - - // Redirect the call to another function / class member with the same - // signature as the original target. Crash if given a wrong signature. - void SetTarget(NativeCallType call) { mNativeCall = call; } - template<typename T> void SetTarget(T&&) const { MOZ_CRASH(); } - - void operator()() override - { - JNIEnv* const env = GetEnvForThread(); - typename ThisArgClass::LocalRef thisArg(env, mThisArg); - Call<IsStatic, HasThisArg>( - thisArg, typename IndexSequenceFor<Args...>::Type()); - - // Clear all saved global refs. We do this after the call is invoked, - // and not inside the destructor because we already have a JNIEnv here, - // so it's more efficient to clear out the saved args here. The - // downside is that the call can only be invoked once. - Clear(env, typename IndexSequenceFor<Args...>::Type()); - mThisArg.Clear(env); - } -}; - -template<class Impl, bool HasThisArg, typename... Args> -struct Dispatcher -{ - template<class Traits, bool IsStatic = Traits::isStatic, - typename... ProxyArgs> - static typename EnableIf< - Traits::dispatchTarget == DispatchTarget::PROXY, void>::Type - Run(ProxyArgs&&... args) - { - Impl::OnNativeCall(ProxyNativeCall< - Impl, typename Traits::Owner, IsStatic, - HasThisArg, Args...>(Forward<ProxyArgs>(args)...)); - } - - template<class Traits, bool IsStatic = Traits::isStatic, - typename ThisArg, typename... ProxyArgs> - static typename EnableIf< - Traits::dispatchTarget == DispatchTarget::GECKO, void>::Type - Run(ThisArg thisArg, ProxyArgs&&... args) - { - // For a static method, do not forward the "this arg" (i.e. the class - // local ref) if the implementation does not request it. This saves us - // a pair of calls to add/delete global ref. - DispatchToGeckoThread(MakeUnique<ProxyNativeCall< - Impl, typename Traits::Owner, IsStatic, HasThisArg, - Args...>>(HasThisArg || !IsStatic ? thisArg : nullptr, - Forward<ProxyArgs>(args)...)); - } - - template<class Traits, bool IsStatic = false, typename... ProxyArgs> - static typename EnableIf< - Traits::dispatchTarget == DispatchTarget::CURRENT, void>::Type - Run(ProxyArgs&&... args) {} -}; - -} // namespace detail - -// Wrapper methods that convert arguments from the JNI types to the native -// types, e.g. from jobject to jni::Object::Ref. For instance methods, the -// wrapper methods also convert calls to calls on objects. -// -// We need specialization for static/non-static because the two have different -// signatures (jobject vs jclass and Impl::*Method vs *Method). -// We need specialization for return type, because void return type requires -// us to not deal with the return value. - -// Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry -#ifdef __i386__ -#define MOZ_JNICALL JNICALL __attribute__((force_align_arg_pointer)) -#else -#define MOZ_JNICALL JNICALL -#endif - -template<class Traits, class Impl, class Args = typename Traits::Args> -class NativeStub; - -template<class Traits, class Impl, typename... Args> -class NativeStub<Traits, Impl, jni::Args<Args...>> -{ - using Owner = typename Traits::Owner; - using ReturnType = typename Traits::ReturnType; - - static constexpr bool isStatic = Traits::isStatic; - static constexpr bool isVoid = mozilla::IsVoid<ReturnType>::value; - - struct VoidType { using JNIType = void; }; - using ReturnJNIType = typename Conditional< - isVoid, VoidType, TypeAdapter<ReturnType>>::Type::JNIType; - - using ReturnTypeForNonVoidInstance = typename Conditional< - !isStatic && !isVoid, ReturnType, VoidType>::Type; - using ReturnTypeForVoidInstance = typename Conditional< - !isStatic && isVoid, ReturnType, VoidType&>::Type; - using ReturnTypeForNonVoidStatic = typename Conditional< - isStatic && !isVoid, ReturnType, VoidType>::Type; - using ReturnTypeForVoidStatic = typename Conditional< - isStatic && isVoid, ReturnType, VoidType&>::Type; - - static_assert(Traits::dispatchTarget == DispatchTarget::CURRENT || isVoid, - "Dispatched calls must have void return type"); - -public: - // Non-void instance method - template<ReturnTypeForNonVoidInstance (Impl::*Method) (Args...)> - static MOZ_JNICALL ReturnJNIType - Wrap(JNIEnv* env, jobject instance, - typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - Impl* const impl = NativePtr<Impl>::Get(env, instance); - if (!impl) { - // There is a pending JNI exception at this point. - return ReturnJNIType(); - } - return TypeAdapter<ReturnType>::FromNative(env, - (impl->*Method)(TypeAdapter<Args>::ToNative(env, args)...)); - } - - // Non-void instance method with instance reference - template<ReturnTypeForNonVoidInstance (Impl::*Method) - (const typename Owner::LocalRef&, Args...)> - static MOZ_JNICALL ReturnJNIType - Wrap(JNIEnv* env, jobject instance, - typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - Impl* const impl = NativePtr<Impl>::Get(env, instance); - if (!impl) { - // There is a pending JNI exception at this point. - return ReturnJNIType(); - } - auto self = Owner::LocalRef::Adopt(env, instance); - const auto res = TypeAdapter<ReturnType>::FromNative(env, - (impl->*Method)(self, TypeAdapter<Args>::ToNative(env, args)...)); - self.Forget(); - return res; - } - - // Void instance method - template<ReturnTypeForVoidInstance (Impl::*Method) (Args...)> - static MOZ_JNICALL void - Wrap(JNIEnv* env, jobject instance, - typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - if (Traits::dispatchTarget != DispatchTarget::CURRENT) { - Dispatcher<Impl, /* HasThisArg */ false, Args...>:: - template Run<Traits>(instance, Method, env, args...); - return; - } - - Impl* const impl = NativePtr<Impl>::Get(env, instance); - if (!impl) { - // There is a pending JNI exception at this point. - return; - } - (impl->*Method)(TypeAdapter<Args>::ToNative(env, args)...); - } - - // Void instance method with instance reference - template<ReturnTypeForVoidInstance (Impl::*Method) - (const typename Owner::LocalRef&, Args...)> - static MOZ_JNICALL void - Wrap(JNIEnv* env, jobject instance, - typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - if (Traits::dispatchTarget != DispatchTarget::CURRENT) { - Dispatcher<Impl, /* HasThisArg */ true, Args...>:: - template Run<Traits>(instance, Method, env, args...); - return; - } - - Impl* const impl = NativePtr<Impl>::Get(env, instance); - if (!impl) { - // There is a pending JNI exception at this point. - return; - } - auto self = Owner::LocalRef::Adopt(env, instance); - (impl->*Method)(self, TypeAdapter<Args>::ToNative(env, args)...); - self.Forget(); - } - - // Overload for DisposeNative - template<ReturnTypeForVoidInstance (*DisposeNative) - (const typename Owner::LocalRef&)> - static MOZ_JNICALL void - Wrap(JNIEnv* env, jobject instance) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - if (Traits::dispatchTarget != DispatchTarget::CURRENT) { - using LocalRef = typename Owner::LocalRef; - Dispatcher<Impl, /* HasThisArg */ false, const LocalRef&>:: - template Run<Traits, /* IsStatic */ true>( - /* ThisArg */ nullptr, DisposeNative, env, instance); - return; - } - - auto self = Owner::LocalRef::Adopt(env, instance); - (Impl::DisposeNative)(self); - self.Forget(); - } - - // Non-void static method - template<ReturnTypeForNonVoidStatic (*Method) (Args...)> - static MOZ_JNICALL ReturnJNIType - Wrap(JNIEnv* env, jclass, typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - return TypeAdapter<ReturnType>::FromNative(env, - (*Method)(TypeAdapter<Args>::ToNative(env, args)...)); - } - - // Non-void static method with class reference - template<ReturnTypeForNonVoidStatic (*Method) - (const Class::LocalRef&, Args...)> - static MOZ_JNICALL ReturnJNIType - Wrap(JNIEnv* env, jclass cls, typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - auto clazz = Class::LocalRef::Adopt(env, cls); - const auto res = TypeAdapter<ReturnType>::FromNative(env, - (*Method)(clazz, TypeAdapter<Args>::ToNative(env, args)...)); - clazz.Forget(); - return res; - } - - // Void static method - template<ReturnTypeForVoidStatic (*Method) (Args...)> - static MOZ_JNICALL void - Wrap(JNIEnv* env, jclass cls, typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - if (Traits::dispatchTarget != DispatchTarget::CURRENT) { - Dispatcher<Impl, /* HasThisArg */ false, Args...>:: - template Run<Traits>(cls, Method, env, args...); - return; - } - - (*Method)(TypeAdapter<Args>::ToNative(env, args)...); - } - - // Void static method with class reference - template<ReturnTypeForVoidStatic (*Method) - (const Class::LocalRef&, Args...)> - static MOZ_JNICALL void - Wrap(JNIEnv* env, jclass cls, typename TypeAdapter<Args>::JNIType... args) - { - MOZ_ASSERT_JNI_THREAD(Traits::callingThread); - - if (Traits::dispatchTarget != DispatchTarget::CURRENT) { - Dispatcher<Impl, /* HasThisArg */ true, Args...>:: - template Run<Traits>(cls, Method, env, args...); - return; - } - - auto clazz = Class::LocalRef::Adopt(env, cls); - (*Method)(clazz, TypeAdapter<Args>::ToNative(env, args)...); - clazz.Forget(); - } -}; - -// Generate a JNINativeMethod from a native -// method's traits class and a wrapped stub. -template<class Traits, typename Ret, typename... Args> -constexpr JNINativeMethod MakeNativeMethod(MOZ_JNICALL Ret (*stub)(JNIEnv*, Args...)) -{ - return { - Traits::name, - Traits::signature, - reinterpret_cast<void*>(stub) - }; -} - -// Class inherited by implementing class. -template<class Cls, class Impl> -class NativeImpl -{ - typedef typename Cls::template Natives<Impl> Natives; - - static bool sInited; - -public: - static void Init() { - if (sInited) { - return; - } - const auto& ctx = typename Cls::Context(); - ctx.Env()->RegisterNatives( - ctx.ClassRef(), Natives::methods, - sizeof(Natives::methods) / sizeof(Natives::methods[0])); - MOZ_CATCH_JNI_EXCEPTION(ctx.Env()); - sInited = true; - } - -protected: - - // Associate a C++ instance with a Java instance. - static void AttachNative(const typename Cls::LocalRef& instance, - SupportsWeakPtr<Impl>* ptr) - { - static_assert(mozilla::IsBaseOf<SupportsWeakPtr<Impl>, Impl>::value, - "Attach with UniquePtr&& when not using WeakPtr"); - return NativePtr<Impl>::Set(instance, static_cast<Impl*>(ptr)); - } - - static void AttachNative(const typename Cls::LocalRef& instance, - UniquePtr<Impl>&& ptr) - { - static_assert(!mozilla::IsBaseOf<SupportsWeakPtr<Impl>, Impl>::value, - "Attach with SupportsWeakPtr* when using WeakPtr"); - return NativePtr<Impl>::Set(instance, mozilla::Move(ptr)); - } - - // Get the C++ instance associated with a Java instance. - // There is always a pending exception if the return value is nullptr. - static Impl* GetNative(const typename Cls::LocalRef& instance) { - return NativePtr<Impl>::Get(instance); - } - - static void DisposeNative(const typename Cls::LocalRef& instance) { - NativePtr<Impl>::Clear(instance); - } - - NativeImpl() { - // Initialize on creation if not already initialized. - Init(); - } -}; - -// Define static member. -template<class C, class I> -bool NativeImpl<C, I>::sInited; - -} // namespace jni -} // namespace mozilla - -#endif // mozilla_jni_Natives_h__ diff --git a/widget/android/jni/Refs.h b/widget/android/jni/Refs.h deleted file mode 100644 index 9f54ee5cd..000000000 --- a/widget/android/jni/Refs.h +++ /dev/null @@ -1,953 +0,0 @@ -#ifndef mozilla_jni_Refs_h__ -#define mozilla_jni_Refs_h__ - -#include <jni.h> - -#include "mozilla/Move.h" -#include "mozilla/jni/Utils.h" - -#include "nsError.h" // for nsresult -#include "nsString.h" -#include "nsTArray.h" - -namespace mozilla { -namespace jni { - -// Wrapped object reference (e.g. jobject, jclass, etc...) -template<class Cls, typename JNIType> class Ref; -// Represents a calling context for JNI methods. -template<class Cls, typename JNIType> class Context; -// Wrapped local reference that inherits from Ref. -template<class Cls> class LocalRef; -// Wrapped global reference that inherits from Ref. -template<class Cls> class GlobalRef; -// Wrapped dangling reference that's owned by someone else. -template<class Cls> class DependentRef; - - -// Class to hold the native types of a method's arguments. -// For example, if a method has signature (ILjava/lang/String;)V, -// its arguments class would be jni::Args<int32_t, jni::String::Param> -template<typename...> -struct Args {}; - - -class Object; - -// Base class for Ref and its specializations. -template<class Cls, typename Type> -class Ref -{ - template<class C, typename T> friend class Ref; - - using Self = Ref<Cls, Type>; - using bool_type = void (Self::*)() const; - void non_null_reference() const {} - - // A Cls-derivative that allows copying - // (e.g. when acting as a return value). - struct CopyableCtx : public Context<Cls, Type> - { - CopyableCtx(JNIEnv* env, Type instance) - : Context<Cls, Type>(env, instance) - {} - - CopyableCtx(const CopyableCtx& cls) - : Context<Cls, Type>(cls.Env(), cls.Get()) - {} - }; - - // Private copy constructor so that there's no danger of assigning a - // temporary LocalRef/GlobalRef to a Ref, and potentially use the Ref - // after the source had been freed. - Ref(const Ref&) = default; - -protected: - static JNIEnv* FindEnv() - { - return Cls::callingThread == CallingThread::GECKO ? - GetGeckoThreadEnv() : GetEnvForThread(); - } - - Type mInstance; - - // Protected jobject constructor because outside code should be using - // Ref::From. Using Ref::From makes it very easy to see which code is using - // raw JNI types for future refactoring. - explicit Ref(Type instance) : mInstance(instance) {} - -public: - using JNIType = Type; - - // Construct a Ref form a raw JNI reference. - static Ref<Cls, Type> From(JNIType obj) - { - return Ref<Cls, Type>(obj); - } - - // Construct a Ref form a generic object reference. - static Ref<Cls, Type> From(const Ref<Object, jobject>& obj) - { - return Ref<Cls, Type>(JNIType(obj.Get())); - } - - MOZ_IMPLICIT Ref(decltype(nullptr)) : mInstance(nullptr) {} - - // Get the raw JNI reference. - JNIType Get() const - { - return mInstance; - } - - bool operator==(const Ref& other) const - { - // Treat two references of the same object as being the same. - return mInstance == other.mInstance || JNI_FALSE != - FindEnv()->IsSameObject(mInstance, other.mInstance); - } - - bool operator!=(const Ref& other) const - { - return !operator==(other); - } - - bool operator==(decltype(nullptr)) const - { - return !mInstance; - } - - bool operator!=(decltype(nullptr)) const - { - return !!mInstance; - } - - CopyableCtx operator->() const - { - return CopyableCtx(FindEnv(), mInstance); - } - - // Any ref can be cast to an object ref. - operator Ref<Object, jobject>() const - { - return Ref<Object, jobject>(mInstance); - } - - // Null checking (e.g. !!ref) using the safe-bool idiom. - operator bool_type() const - { - return mInstance ? &Self::non_null_reference : nullptr; - } - - // We don't allow implicit conversion to jobject because that can lead - // to easy mistakes such as assigning a temporary LocalRef to a jobject, - // and using the jobject after the LocalRef has been freed. - - // We don't allow explicit conversion, to make outside code use Ref::Get. - // Using Ref::Get makes it very easy to see which code is using raw JNI - // types to make future refactoring easier. - - // operator JNIType() const = delete; -}; - - -// Represents a calling context for JNI methods. -template<class Cls, typename Type> -class Context : public Ref<Cls, Type> -{ - using Ref = jni::Ref<Cls, Type>; - - static jclass sClassRef; // global reference - -protected: - JNIEnv* const mEnv; - -public: - static jclass RawClassRef() - { - return sClassRef; - } - - Context() - : Ref(nullptr) - , mEnv(Ref::FindEnv()) - {} - - Context(JNIEnv* env, Type instance) - : Ref(instance) - , mEnv(env) - {} - - jclass ClassRef() const - { - if (!sClassRef) { - const jclass cls = GetClassRef(mEnv, Cls::name); - sClassRef = jclass(mEnv->NewGlobalRef(cls)); - mEnv->DeleteLocalRef(cls); - } - return sClassRef; - } - - JNIEnv* Env() const - { - return mEnv; - } - - bool operator==(const Ref& other) const - { - // Treat two references of the same object as being the same. - return Ref::mInstance == other.mInstance || JNI_FALSE != - mEnv->IsSameObject(Ref::mInstance, other.mInstance); - } - - bool operator!=(const Ref& other) const - { - return !operator==(other); - } - - bool operator==(decltype(nullptr)) const - { - return !Ref::mInstance; - } - - bool operator!=(decltype(nullptr)) const - { - return !!Ref::mInstance; - } - - Cls operator->() const - { - MOZ_ASSERT(Ref::mInstance, "Null jobject"); - return Cls(*this); - } -}; - - -template<class Cls, typename Type = jobject> -class ObjectBase -{ -protected: - const jni::Context<Cls, Type>& mCtx; - - jclass ClassRef() const { return mCtx.ClassRef(); } - JNIEnv* Env() const { return mCtx.Env(); } - Type Instance() const { return mCtx.Get(); } - -public: - using Ref = jni::Ref<Cls, Type>; - using Context = jni::Context<Cls, Type>; - using LocalRef = jni::LocalRef<Cls>; - using GlobalRef = jni::GlobalRef<Cls>; - using Param = const Ref&; - - static const CallingThread callingThread = CallingThread::ANY; - static const char name[]; - - explicit ObjectBase(const Context& ctx) : mCtx(ctx) {} - - Cls* operator->() - { - return static_cast<Cls*>(this); - } -}; - -// Binding for a plain jobject. -class Object : public ObjectBase<Object, jobject> -{ -public: - explicit Object(const Context& ctx) : ObjectBase<Object, jobject>(ctx) {} -}; - -// Binding for a built-in object reference other than jobject. -template<typename T> -class TypedObject : public ObjectBase<TypedObject<T>, T> -{ -public: - explicit TypedObject(const Context<TypedObject<T>, T>& ctx) - : ObjectBase<TypedObject<T>, T>(ctx) - {} -}; - - -// Define bindings for built-in types. -using String = TypedObject<jstring>; -using Class = TypedObject<jclass>; -using Throwable = TypedObject<jthrowable>; - -using BooleanArray = TypedObject<jbooleanArray>; -using ByteArray = TypedObject<jbyteArray>; -using CharArray = TypedObject<jcharArray>; -using ShortArray = TypedObject<jshortArray>; -using IntArray = TypedObject<jintArray>; -using LongArray = TypedObject<jlongArray>; -using FloatArray = TypedObject<jfloatArray>; -using DoubleArray = TypedObject<jdoubleArray>; -using ObjectArray = TypedObject<jobjectArray>; - - -namespace detail { - -// See explanation in LocalRef. -template<class Cls> struct GenericObject { using Type = Object; }; -template<> struct GenericObject<Object> -{ - struct Type { - using Ref = jni::Ref<Type, jobject>; - using Context = jni::Context<Type, jobject>; - }; -}; -template<class Cls> struct GenericLocalRef -{ - template<class C> struct Type : jni::Object {}; -}; -template<> struct GenericLocalRef<Object> -{ - template<class C> using Type = jni::LocalRef<C>; -}; - -} // namespace - -template<class Cls> -class LocalRef : public Cls::Context -{ - template<class C> friend class LocalRef; - - using Ctx = typename Cls::Context; - using Ref = typename Cls::Ref; - using JNIType = typename Ref::JNIType; - - // In order to be able to convert LocalRef<Object> to LocalRef<Cls>, we - // need constructors and copy assignment operators that take in a - // LocalRef<Object> argument. However, if Cls *is* Object, we would have - // duplicated constructors and operators with LocalRef<Object> arguments. To - // avoid this conflict, we use GenericObject, which is defined as Object for - // LocalRef<non-Object> and defined as a dummy class for LocalRef<Object>. - using GenericObject = typename detail::GenericObject<Cls>::Type; - - // Similarly, GenericLocalRef is useed to convert LocalRef<Cls> to, - // LocalRef<Object>. It's defined as LocalRef<C> for Cls == Object, - // and defined as a dummy template class for Cls != Object. - template<class C> using GenericLocalRef - = typename detail::GenericLocalRef<Cls>::template Type<C>; - - static JNIType NewLocalRef(JNIEnv* env, JNIType obj) - { - return JNIType(obj ? env->NewLocalRef(obj) : nullptr); - } - - LocalRef(JNIEnv* env, JNIType instance) : Ctx(env, instance) {} - - LocalRef& swap(LocalRef& other) - { - auto instance = other.mInstance; - other.mInstance = Ctx::mInstance; - Ctx::mInstance = instance; - return *this; - } - -public: - // Construct a LocalRef from a raw JNI local reference. Unlike Ref::From, - // LocalRef::Adopt returns a LocalRef that will delete the local reference - // when going out of scope. - static LocalRef Adopt(JNIType instance) - { - return LocalRef(Ref::FindEnv(), instance); - } - - static LocalRef Adopt(JNIEnv* env, JNIType instance) - { - return LocalRef(env, instance); - } - - // Copy constructor. - LocalRef(const LocalRef<Cls>& ref) - : Ctx(ref.mEnv, NewLocalRef(ref.mEnv, ref.mInstance)) - {} - - // Move constructor. - LocalRef(LocalRef<Cls>&& ref) - : Ctx(ref.mEnv, ref.mInstance) - { - ref.mInstance = nullptr; - } - - explicit LocalRef(JNIEnv* env = Ref::FindEnv()) - : Ctx(env, nullptr) - {} - - // Construct a LocalRef from any Ref, - // which means creating a new local reference. - MOZ_IMPLICIT LocalRef(const Ref& ref) - : Ctx(Ref::FindEnv(), nullptr) - { - Ctx::mInstance = NewLocalRef(Ctx::mEnv, ref.Get()); - } - - LocalRef(JNIEnv* env, const Ref& ref) - : Ctx(env, NewLocalRef(env, ref.Get())) - {} - - // Move a LocalRef<Object> into a LocalRef<Cls> without - // creating/deleting local references. - MOZ_IMPLICIT LocalRef(LocalRef<GenericObject>&& ref) - : Ctx(ref.mEnv, JNIType(ref.mInstance)) - { - ref.mInstance = nullptr; - } - - template<class C> - MOZ_IMPLICIT LocalRef(GenericLocalRef<C>&& ref) - : Ctx(ref.mEnv, ref.mInstance) - { - ref.mInstance = nullptr; - } - - // Implicitly converts nullptr to LocalRef. - MOZ_IMPLICIT LocalRef(decltype(nullptr)) - : Ctx(Ref::FindEnv(), nullptr) - {} - - ~LocalRef() - { - if (Ctx::mInstance) { - Ctx::mEnv->DeleteLocalRef(Ctx::mInstance); - Ctx::mInstance = nullptr; - } - } - - // Get the raw JNI reference that can be used as a return value. - // Returns the same JNI type (jobject, jstring, etc.) as the underlying Ref. - typename Ref::JNIType Forget() - { - const auto obj = Ctx::Get(); - Ctx::mInstance = nullptr; - return obj; - } - - LocalRef<Cls>& operator=(LocalRef<Cls> ref) - { - return swap(ref); - } - - LocalRef<Cls>& operator=(const Ref& ref) - { - LocalRef<Cls> newRef(Ctx::mEnv, ref); - return swap(newRef); - } - - LocalRef<Cls>& operator=(LocalRef<GenericObject>&& ref) - { - LocalRef<Cls> newRef(mozilla::Move(ref)); - return swap(newRef); - } - - template<class C> - LocalRef<Cls>& operator=(GenericLocalRef<C>&& ref) - { - LocalRef<Cls> newRef(mozilla::Move(ref)); - return swap(newRef); - } - - LocalRef<Cls>& operator=(decltype(nullptr)) - { - LocalRef<Cls> newRef(Ctx::mEnv, nullptr); - return swap(newRef); - } -}; - - -template<class Cls> -class GlobalRef : public Cls::Ref -{ - using Ref = typename Cls::Ref; - using JNIType = typename Ref::JNIType; - - static JNIType NewGlobalRef(JNIEnv* env, JNIType instance) - { - return JNIType(instance ? env->NewGlobalRef(instance) : nullptr); - } - - GlobalRef& swap(GlobalRef& other) - { - auto instance = other.mInstance; - other.mInstance = Ref::mInstance; - Ref::mInstance = instance; - return *this; - } - -public: - GlobalRef() - : Ref(nullptr) - {} - - // Copy constructor - GlobalRef(const GlobalRef& ref) - : Ref(NewGlobalRef(GetEnvForThread(), ref.mInstance)) - {} - - // Move constructor - GlobalRef(GlobalRef&& ref) - : Ref(ref.mInstance) - { - ref.mInstance = nullptr; - } - - MOZ_IMPLICIT GlobalRef(const Ref& ref) - : Ref(NewGlobalRef(GetEnvForThread(), ref.Get())) - {} - - GlobalRef(JNIEnv* env, const Ref& ref) - : Ref(NewGlobalRef(env, ref.Get())) - {} - - MOZ_IMPLICIT GlobalRef(const LocalRef<Cls>& ref) - : Ref(NewGlobalRef(ref.Env(), ref.Get())) - {} - - // Implicitly converts nullptr to GlobalRef. - MOZ_IMPLICIT GlobalRef(decltype(nullptr)) - : Ref(nullptr) - {} - - ~GlobalRef() - { - if (Ref::mInstance) { - Clear(GetEnvForThread()); - } - } - - // Get the raw JNI reference that can be used as a return value. - // Returns the same JNI type (jobject, jstring, etc.) as the underlying Ref. - typename Ref::JNIType Forget() - { - const auto obj = Ref::Get(); - Ref::mInstance = nullptr; - return obj; - } - - void Clear(JNIEnv* env) - { - if (Ref::mInstance) { - env->DeleteGlobalRef(Ref::mInstance); - Ref::mInstance = nullptr; - } - } - - GlobalRef<Cls>& operator=(GlobalRef<Cls> ref) - { - return swap(ref); - } - - GlobalRef<Cls>& operator=(const Ref& ref) - { - GlobalRef<Cls> newRef(ref); - return swap(newRef); - } - - GlobalRef<Cls>& operator=(const LocalRef<Cls>& ref) - { - GlobalRef<Cls> newRef(ref); - return swap(newRef); - } - - GlobalRef<Cls>& operator=(decltype(nullptr)) - { - GlobalRef<Cls> newRef(nullptr); - return swap(newRef); - } -}; - - -template<class Cls> -class DependentRef : public Cls::Ref -{ - using Ref = typename Cls::Ref; - -public: - DependentRef(typename Ref::JNIType instance) - : Ref(instance) - {} - - DependentRef(const DependentRef& ref) - : Ref(ref.Get()) - {} -}; - - -class StringParam; - -template<> -class TypedObject<jstring> : public ObjectBase<TypedObject<jstring>, jstring> -{ - using Base = ObjectBase<TypedObject<jstring>, jstring>; - -public: - using Param = const StringParam&; - - explicit TypedObject(const Context& ctx) : Base(ctx) {} - - size_t Length() const - { - const size_t ret = Base::Env()->GetStringLength(Base::Instance()); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - return ret; - } - - nsString ToString() const - { - const jchar* const str = Base::Env()->GetStringChars( - Base::Instance(), nullptr); - const jsize len = Base::Env()->GetStringLength(Base::Instance()); - - nsString result(reinterpret_cast<const char16_t*>(str), len); - Base::Env()->ReleaseStringChars(Base::Instance(), str); - return result; - } - - nsCString ToCString() const - { - return NS_ConvertUTF16toUTF8(ToString()); - } - - // Convert jstring to a nsString. - operator nsString() const - { - return ToString(); - } - - // Convert jstring to a nsCString. - operator nsCString() const - { - return ToCString(); - } -}; - -// Define a custom parameter type for String, -// which accepts both String::Ref and nsAString/nsACString -class StringParam : public String::Ref -{ - using Ref = String::Ref; - -private: - // Not null if we should delete ref on destruction. - JNIEnv* const mEnv; - - static jstring GetString(JNIEnv* env, const nsAString& str) - { - const jstring result = env->NewString( - reinterpret_cast<const jchar*>(str.BeginReading()), - str.Length()); - MOZ_CATCH_JNI_EXCEPTION(env); - return result; - } - -public: - MOZ_IMPLICIT StringParam(decltype(nullptr)) - : Ref(nullptr) - , mEnv(nullptr) - {} - - MOZ_IMPLICIT StringParam(const Ref& ref) - : Ref(ref.Get()) - , mEnv(nullptr) - {} - - MOZ_IMPLICIT StringParam(const nsAString& str, JNIEnv* env = Ref::FindEnv()) - : Ref(GetString(env, str)) - , mEnv(env) - {} - - MOZ_IMPLICIT StringParam(const char16_t* str, JNIEnv* env = Ref::FindEnv()) - : Ref(GetString(env, nsDependentString(str))) - , mEnv(env) - {} - - MOZ_IMPLICIT StringParam(const nsACString& str, JNIEnv* env = Ref::FindEnv()) - : Ref(GetString(env, NS_ConvertUTF8toUTF16(str))) - , mEnv(env) - {} - - MOZ_IMPLICIT StringParam(const char* str, JNIEnv* env = Ref::FindEnv()) - : Ref(GetString(env, NS_ConvertUTF8toUTF16(str))) - , mEnv(env) - {} - - StringParam(StringParam&& other) - : Ref(other.Get()) - , mEnv(other.mEnv) - { - other.mInstance = nullptr; - } - - ~StringParam() - { - if (mEnv && Get()) { - mEnv->DeleteLocalRef(Get()); - } - } - - operator String::LocalRef() const - { - // We can't return our existing ref because the returned - // LocalRef could be freed first, so we need a new local ref. - return String::LocalRef(mEnv ? mEnv : Ref::FindEnv(), *this); - } -}; - - -namespace detail { - template<typename T> struct TypeAdapter; -} - -// Ref specialization for arrays. -template<typename JNIType, class ElementType> -class ArrayRefBase : public ObjectBase<TypedObject<JNIType>, JNIType> -{ - using Base = ObjectBase<TypedObject<JNIType>, JNIType>; - -public: - explicit ArrayRefBase(const Context<TypedObject<JNIType>, JNIType>& ctx) - : Base(ctx) - {} - - static typename Base::LocalRef New(const ElementType* data, size_t length) { - using JNIElemType = typename detail::TypeAdapter<ElementType>::JNIType; - static_assert(sizeof(ElementType) == sizeof(JNIElemType), - "Size of native type must match size of JNI type"); - JNIEnv* const jenv = mozilla::jni::GetEnvForThread(); - auto result = - (jenv->*detail::TypeAdapter<ElementType>::NewArray)(length); - MOZ_CATCH_JNI_EXCEPTION(jenv); - (jenv->*detail::TypeAdapter<ElementType>::SetArray)( - result, jsize(0), length, - reinterpret_cast<const JNIElemType*>(data)); - MOZ_CATCH_JNI_EXCEPTION(jenv); - return Base::LocalRef::Adopt(jenv, result); - } - - size_t Length() const - { - const size_t ret = Base::Env()->GetArrayLength(Base::Instance()); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - return ret; - } - - ElementType GetElement(size_t index) const - { - using JNIElemType = typename detail::TypeAdapter<ElementType>::JNIType; - static_assert(sizeof(ElementType) == sizeof(JNIElemType), - "Size of native type must match size of JNI type"); - - ElementType ret; - (Base::Env()->*detail::TypeAdapter<ElementType>::GetArray)( - Base::Instance(), jsize(index), 1, - reinterpret_cast<JNIElemType*>(&ret)); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - return ret; - } - - nsTArray<ElementType> GetElements() const - { - using JNIElemType = typename detail::TypeAdapter<ElementType>::JNIType; - static_assert(sizeof(ElementType) == sizeof(JNIElemType), - "Size of native type must match size of JNI type"); - - const jsize len = size_t(Base::Env()->GetArrayLength(Base::Instance())); - - nsTArray<ElementType> array((size_t(len))); - array.SetLength(size_t(len)); - (Base::Env()->*detail::TypeAdapter<ElementType>::GetArray)( - Base::Instance(), 0, len, - reinterpret_cast<JNIElemType*>(array.Elements())); - return array; - } - - ElementType operator[](size_t index) const - { - return GetElement(index); - } - - operator nsTArray<ElementType>() const - { - return GetElements(); - } -}; - -#define DEFINE_PRIMITIVE_ARRAY_REF(JNIType, ElementType) \ - template<> \ - class TypedObject<JNIType> : public ArrayRefBase<JNIType, ElementType> \ - { \ - public: \ - explicit TypedObject(const Context& ctx) \ - : ArrayRefBase<JNIType, ElementType>(ctx) \ - {} \ - } - -DEFINE_PRIMITIVE_ARRAY_REF(jbooleanArray, bool); -DEFINE_PRIMITIVE_ARRAY_REF(jbyteArray, int8_t); -DEFINE_PRIMITIVE_ARRAY_REF(jcharArray, char16_t); -DEFINE_PRIMITIVE_ARRAY_REF(jshortArray, int16_t); -DEFINE_PRIMITIVE_ARRAY_REF(jintArray, int32_t); -DEFINE_PRIMITIVE_ARRAY_REF(jlongArray, int64_t); -DEFINE_PRIMITIVE_ARRAY_REF(jfloatArray, float); -DEFINE_PRIMITIVE_ARRAY_REF(jdoubleArray, double); - -#undef DEFINE_PRIMITIVE_ARRAY_REF - - -class ByteBuffer : public ObjectBase<ByteBuffer, jobject> -{ -public: - explicit ByteBuffer(const Context& ctx) - : ObjectBase<ByteBuffer, jobject>(ctx) - {} - - static LocalRef New(void* data, size_t capacity) - { - JNIEnv* const env = GetEnvForThread(); - const auto ret = LocalRef::Adopt( - env, env->NewDirectByteBuffer(data, jlong(capacity))); - MOZ_CATCH_JNI_EXCEPTION(env); - return ret; - } - - void* Address() - { - void* const ret = Env()->GetDirectBufferAddress(Instance()); - MOZ_CATCH_JNI_EXCEPTION(Env()); - return ret; - } - - size_t Capacity() - { - const size_t ret = size_t(Env()->GetDirectBufferCapacity(Instance())); - MOZ_CATCH_JNI_EXCEPTION(Env()); - return ret; - } -}; - - -template<> -class TypedObject<jobjectArray> - : public ObjectBase<TypedObject<jobjectArray>, jobjectArray> -{ - using Base = ObjectBase<TypedObject<jobjectArray>, jobjectArray>; - -public: - explicit TypedObject(const Context& ctx) : Base(ctx) {} - - size_t Length() const - { - const size_t ret = Base::Env()->GetArrayLength(Base::Instance()); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - return ret; - } - - Object::LocalRef GetElement(size_t index) const - { - auto ret = Object::LocalRef::Adopt( - Base::Env(), Base::Env()->GetObjectArrayElement( - Base::Instance(), jsize(index))); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - return ret; - } - - nsTArray<Object::LocalRef> GetElements() const - { - const jsize len = size_t(Base::Env()->GetArrayLength(Base::Instance())); - - nsTArray<Object::LocalRef> array((size_t(len))); - for (jsize i = 0; i < len; i++) { - array.AppendElement(Object::LocalRef::Adopt( - Base::Env(), Base::Env()->GetObjectArrayElement( - Base::Instance(), i))); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - } - return array; - } - - Object::LocalRef operator[](size_t index) const - { - return GetElement(index); - } - - operator nsTArray<Object::LocalRef>() const - { - return GetElements(); - } - - void SetElement(size_t index, Object::Param element) const - { - Base::Env()->SetObjectArrayElement( - Base::Instance(), jsize(index), element.Get()); - MOZ_CATCH_JNI_EXCEPTION(Base::Env()); - } -}; - - -// Support conversion from LocalRef<T>* to LocalRef<Object>*: -// LocalRef<Foo> foo; -// Foo::GetFoo(&foo); // error because parameter type is LocalRef<Object>*. -// Foo::GetFoo(ReturnTo(&foo)); // OK because ReturnTo converts the argument. -template<class Cls> -class ReturnToLocal -{ -private: - LocalRef<Cls>* const localRef; - LocalRef<Object> objRef; - -public: - explicit ReturnToLocal(LocalRef<Cls>* ref) : localRef(ref) {} - operator LocalRef<Object>*() { return &objRef; } - - ~ReturnToLocal() - { - if (objRef) { - *localRef = mozilla::Move(objRef); - } - } -}; - -template<class Cls> -ReturnToLocal<Cls> ReturnTo(LocalRef<Cls>* ref) -{ - return ReturnToLocal<Cls>(ref); -} - - -// Support conversion from GlobalRef<T>* to LocalRef<Object/T>*: -// GlobalRef<Foo> foo; -// Foo::GetFoo(&foo); // error because parameter type is LocalRef<Foo>*. -// Foo::GetFoo(ReturnTo(&foo)); // OK because ReturnTo converts the argument. -template<class Cls> -class ReturnToGlobal -{ -private: - GlobalRef<Cls>* const globalRef; - LocalRef<Object> objRef; - LocalRef<Cls> clsRef; - -public: - explicit ReturnToGlobal(GlobalRef<Cls>* ref) : globalRef(ref) {} - operator LocalRef<Object>*() { return &objRef; } - operator LocalRef<Cls>*() { return &clsRef; } - - ~ReturnToGlobal() - { - if (objRef) { - *globalRef = (clsRef = mozilla::Move(objRef)); - } else if (clsRef) { - *globalRef = clsRef; - } - } -}; - -template<class Cls> -ReturnToGlobal<Cls> ReturnTo(GlobalRef<Cls>* ref) -{ - return ReturnToGlobal<Cls>(ref); -} - -} // namespace jni -} // namespace mozilla - -#endif // mozilla_jni_Refs_h__ diff --git a/widget/android/jni/Types.h b/widget/android/jni/Types.h deleted file mode 100644 index a083d3e50..000000000 --- a/widget/android/jni/Types.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef mozilla_jni_Types_h__ -#define mozilla_jni_Types_h__ - -#include <jni.h> - -#include "mozilla/jni/Refs.h" - -namespace mozilla { -namespace jni { -namespace detail { - -// TypeAdapter specializations are the interfaces between native/C++ types such -// as int32_t and JNI types such as jint. The template parameter T is the native -// type, and each TypeAdapter specialization can have the following members: -// -// * Call: JNIEnv member pointer for making a method call that returns T. -// * StaticCall: JNIEnv member pointer for making a static call that returns T. -// * Get: JNIEnv member pointer for getting a field of type T. -// * StaticGet: JNIEnv member pointer for getting a static field of type T. -// * Set: JNIEnv member pointer for setting a field of type T. -// * StaticGet: JNIEnv member pointer for setting a static field of type T. -// * ToNative: static function that converts the JNI type to the native type. -// * FromNative: static function that converts the native type to the JNI type. - -template<typename T> struct TypeAdapter; - - -// TypeAdapter<LocalRef<Cls>> applies when jobject is a return value. -template<class Cls> struct TypeAdapter<LocalRef<Cls>> { - using JNIType = typename Cls::Ref::JNIType; - - static constexpr auto Call = &JNIEnv::CallObjectMethodA; - static constexpr auto StaticCall = &JNIEnv::CallStaticObjectMethodA; - static constexpr auto Get = &JNIEnv::GetObjectField; - static constexpr auto StaticGet = &JNIEnv::GetStaticObjectField; - - // Declare instance as jobject because JNI methods return - // jobject even if the return value is really jstring, etc. - static LocalRef<Cls> ToNative(JNIEnv* env, jobject instance) { - return LocalRef<Cls>::Adopt(env, JNIType(instance)); - } - - static JNIType FromNative(JNIEnv*, LocalRef<Cls>&& instance) { - return instance.Forget(); - } -}; - -// clang is picky about function types, including attributes that modify the calling -// convention, lining up. GCC appears to be somewhat less so. -#ifdef __clang__ -#define MOZ_JNICALL_ABI JNICALL -#else -#define MOZ_JNICALL_ABI -#endif - -template<class Cls> constexpr jobject - (JNIEnv::*TypeAdapter<LocalRef<Cls>>::Call)(jobject, jmethodID, jvalue*) MOZ_JNICALL_ABI; -template<class Cls> constexpr jobject - (JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticCall)(jclass, jmethodID, jvalue*) MOZ_JNICALL_ABI; -template<class Cls> constexpr jobject - (JNIEnv::*TypeAdapter<LocalRef<Cls>>::Get)(jobject, jfieldID); -template<class Cls> constexpr jobject - (JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticGet)(jclass, jfieldID); - - -// TypeAdapter<Ref<Cls>> applies when jobject is a parameter value. -template<class Cls, typename T> struct TypeAdapter<Ref<Cls, T>> { - using JNIType = typename Ref<Cls, T>::JNIType; - - static constexpr auto Set = &JNIEnv::SetObjectField; - static constexpr auto StaticSet = &JNIEnv::SetStaticObjectField; - - static DependentRef<Cls> ToNative(JNIEnv* env, JNIType instance) { - return DependentRef<Cls>(instance); - } - - static JNIType FromNative(JNIEnv*, const Ref<Cls, T>& instance) { - return instance.Get(); - } -}; - -template<class Cls, typename T> constexpr void - (JNIEnv::*TypeAdapter<Ref<Cls, T>>::Set)(jobject, jfieldID, jobject); -template<class Cls, typename T> constexpr void - (JNIEnv::*TypeAdapter<Ref<Cls, T>>::StaticSet)(jclass, jfieldID, jobject); - - -// jstring has its own Param type. -template<> struct TypeAdapter<StringParam> - : public TypeAdapter<String::Ref> -{}; - -template<class Cls> struct TypeAdapter<const Cls&> - : public TypeAdapter<Cls> -{}; - - -#define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName) \ - \ - template<> struct TypeAdapter<NativeType> { \ - using JNI##Type = JNIType; \ - \ - static constexpr auto Call = &JNIEnv::Call ## JNIName ## MethodA; \ - static constexpr auto StaticCall = &JNIEnv::CallStatic ## JNIName ## MethodA; \ - static constexpr auto Get = &JNIEnv::Get ## JNIName ## Field; \ - static constexpr auto StaticGet = &JNIEnv::GetStatic ## JNIName ## Field; \ - static constexpr auto Set = &JNIEnv::Set ## JNIName ## Field; \ - static constexpr auto StaticSet = &JNIEnv::SetStatic ## JNIName ## Field; \ - static constexpr auto GetArray = &JNIEnv::Get ## JNIName ## ArrayRegion; \ - static constexpr auto SetArray = &JNIEnv::Set ## JNIName ## ArrayRegion; \ - static constexpr auto NewArray = &JNIEnv::New ## JNIName ## Array; \ - \ - static JNIType FromNative(JNIEnv*, NativeType val) { \ - return static_cast<JNIType>(val); \ - } \ - static NativeType ToNative(JNIEnv*, JNIType val) { \ - return static_cast<NativeType>(val); \ - } \ - } - - -DEFINE_PRIMITIVE_TYPE_ADAPTER(bool, jboolean, Boolean); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int8_t, jbyte, Byte); -DEFINE_PRIMITIVE_TYPE_ADAPTER(char16_t, jchar, Char); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int16_t, jshort, Short); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int32_t, jint, Int); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int64_t, jlong, Long); -DEFINE_PRIMITIVE_TYPE_ADAPTER(float, jfloat, Float); -DEFINE_PRIMITIVE_TYPE_ADAPTER(double, jdouble, Double); - -#undef DEFINE_PRIMITIVE_TYPE_ADAPTER - -} // namespace detail - -using namespace detail; - -} // namespace jni -} // namespace mozilla - -#endif // mozilla_jni_Types_h__ diff --git a/widget/android/jni/Utils.cpp b/widget/android/jni/Utils.cpp deleted file mode 100644 index 919588851..000000000 --- a/widget/android/jni/Utils.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include "Utils.h" -#include "Types.h" - -#include <android/log.h> -#include <pthread.h> - -#include "mozilla/Assertions.h" - -#include "GeneratedJNIWrappers.h" -#include "nsAppShell.h" - -namespace mozilla { -namespace jni { - -namespace detail { - -#define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName, ABIName) \ - \ - constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Call) \ - (jobject, jmethodID, jvalue*) MOZ_JNICALL_ABI; \ - constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticCall) \ - (jclass, jmethodID, jvalue*) MOZ_JNICALL_ABI; \ - constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Get) \ - (jobject, jfieldID) ABIName; \ - constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticGet) \ - (jclass, jfieldID) ABIName; \ - constexpr void (JNIEnv::*TypeAdapter<NativeType>::Set) \ - (jobject, jfieldID, JNIType) ABIName; \ - constexpr void (JNIEnv::*TypeAdapter<NativeType>::StaticSet) \ - (jclass, jfieldID, JNIType) ABIName; \ - constexpr void (JNIEnv::*TypeAdapter<NativeType>::GetArray) \ - (JNIType ## Array, jsize, jsize, JNIType*) - -DEFINE_PRIMITIVE_TYPE_ADAPTER(bool, jboolean, Boolean, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int8_t, jbyte, Byte, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(char16_t, jchar, Char, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int16_t, jshort, Short, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int32_t, jint, Int, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(int64_t, jlong, Long, /*nothing*/); -DEFINE_PRIMITIVE_TYPE_ADAPTER(float, jfloat, Float, MOZ_JNICALL_ABI); -DEFINE_PRIMITIVE_TYPE_ADAPTER(double, jdouble, Double, MOZ_JNICALL_ABI); - -#undef DEFINE_PRIMITIVE_TYPE_ADAPTER - -} // namespace detail - -template<> const char ObjectBase<Object, jobject>::name[] = "java/lang/Object"; -template<> const char ObjectBase<TypedObject<jstring>, jstring>::name[] = "java/lang/String"; -template<> const char ObjectBase<TypedObject<jclass>, jclass>::name[] = "java/lang/Class"; -template<> const char ObjectBase<TypedObject<jthrowable>, jthrowable>::name[] = "java/lang/Throwable"; -template<> const char ObjectBase<TypedObject<jbooleanArray>, jbooleanArray>::name[] = "[Z"; -template<> const char ObjectBase<TypedObject<jbyteArray>, jbyteArray>::name[] = "[B"; -template<> const char ObjectBase<TypedObject<jcharArray>, jcharArray>::name[] = "[C"; -template<> const char ObjectBase<TypedObject<jshortArray>, jshortArray>::name[] = "[S"; -template<> const char ObjectBase<TypedObject<jintArray>, jintArray>::name[] = "[I"; -template<> const char ObjectBase<TypedObject<jlongArray>, jlongArray>::name[] = "[J"; -template<> const char ObjectBase<TypedObject<jfloatArray>, jfloatArray>::name[] = "[F"; -template<> const char ObjectBase<TypedObject<jdoubleArray>, jdoubleArray>::name[] = "[D"; -template<> const char ObjectBase<TypedObject<jobjectArray>, jobjectArray>::name[] = "[Ljava/lang/Object;"; -template<> const char ObjectBase<ByteBuffer, jobject>::name[] = "java/nio/ByteBuffer"; - - -JNIEnv* sGeckoThreadEnv; - -namespace { - -JavaVM* sJavaVM; -pthread_key_t sThreadEnvKey; -jclass sOOMErrorClass; -jobject sClassLoader; -jmethodID sClassLoaderLoadClass; -bool sIsFennec; - -void UnregisterThreadEnv(void* env) -{ - if (!env) { - // We were never attached. - return; - } - // The thread may have already been detached. In that case, it's still - // okay to call DetachCurrentThread(); it'll simply return an error. - // However, we must not access | env | because it may be invalid. - MOZ_ASSERT(sJavaVM); - sJavaVM->DetachCurrentThread(); -} - -} // namespace - -void SetGeckoThreadEnv(JNIEnv* aEnv) -{ - MOZ_ASSERT(aEnv); - MOZ_ASSERT(!sGeckoThreadEnv || sGeckoThreadEnv == aEnv); - - if (!sGeckoThreadEnv - && pthread_key_create(&sThreadEnvKey, UnregisterThreadEnv)) { - MOZ_CRASH("Failed to initialize required TLS"); - } - - sGeckoThreadEnv = aEnv; - MOZ_ALWAYS_TRUE(!pthread_setspecific(sThreadEnvKey, aEnv)); - - MOZ_ALWAYS_TRUE(!aEnv->GetJavaVM(&sJavaVM)); - MOZ_ASSERT(sJavaVM); - - sOOMErrorClass = Class::GlobalRef(Class::LocalRef::Adopt( - aEnv->FindClass("java/lang/OutOfMemoryError"))).Forget(); - aEnv->ExceptionClear(); - - sClassLoader = Object::GlobalRef(java::GeckoThread::ClsLoader()).Forget(); - sClassLoaderLoadClass = aEnv->GetMethodID( - Class::LocalRef::Adopt(aEnv->GetObjectClass(sClassLoader)).Get(), - "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); - MOZ_ASSERT(sClassLoader && sClassLoaderLoadClass); - - auto geckoAppClass = Class::LocalRef::Adopt( - aEnv->FindClass("org/mozilla/gecko/GeckoApp")); - aEnv->ExceptionClear(); - sIsFennec = !!geckoAppClass; -} - -JNIEnv* GetEnvForThread() -{ - MOZ_ASSERT(sGeckoThreadEnv); - - JNIEnv* env = static_cast<JNIEnv*>(pthread_getspecific(sThreadEnvKey)); - if (env) { - return env; - } - - // We don't have a saved JNIEnv, so try to get one. - // AttachCurrentThread() does the same thing as GetEnv() when a thread is - // already attached, so we don't have to call GetEnv() at all. - if (!sJavaVM->AttachCurrentThread(&env, nullptr)) { - MOZ_ASSERT(env); - MOZ_ALWAYS_TRUE(!pthread_setspecific(sThreadEnvKey, env)); - return env; - } - - MOZ_CRASH("Failed to get JNIEnv for thread"); - return nullptr; // unreachable -} - -bool ThrowException(JNIEnv *aEnv, const char *aClass, - const char *aMessage) -{ - MOZ_ASSERT(aEnv, "Invalid thread JNI env"); - - Class::LocalRef cls = Class::LocalRef::Adopt(aEnv->FindClass(aClass)); - MOZ_ASSERT(cls, "Cannot find exception class"); - - return !aEnv->ThrowNew(cls.Get(), aMessage); -} - -bool HandleUncaughtException(JNIEnv* aEnv) -{ - MOZ_ASSERT(aEnv, "Invalid thread JNI env"); - - if (!aEnv->ExceptionCheck()) { - return false; - } - -#ifdef MOZ_CHECK_JNI - aEnv->ExceptionDescribe(); -#endif - - Throwable::LocalRef e = - Throwable::LocalRef::Adopt(aEnv, aEnv->ExceptionOccurred()); - MOZ_ASSERT(e); - aEnv->ExceptionClear(); - - String::LocalRef stack = java::GeckoAppShell::GetExceptionStackTrace(e); - if (stack && ReportException(aEnv, e.Get(), stack.Get())) { - return true; - } - - aEnv->ExceptionClear(); - java::GeckoAppShell::HandleUncaughtException(e); - - if (NS_WARN_IF(aEnv->ExceptionCheck())) { - aEnv->ExceptionDescribe(); - aEnv->ExceptionClear(); - } - - return true; -} - -bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) -{ - bool result = true; - - if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { - NS_ABORT_OOM(0); // Unknown OOM size - } - return result; -} - -namespace { - -jclass sJNIObjectClass; -jfieldID sJNIObjectHandleField; - -bool EnsureJNIObject(JNIEnv* env, jobject instance) { - if (!sJNIObjectClass) { - sJNIObjectClass = Class::GlobalRef(Class::LocalRef::Adopt(GetClassRef( - env, "org/mozilla/gecko/mozglue/JNIObject"))).Forget(); - - sJNIObjectHandleField = env->GetFieldID( - sJNIObjectClass, "mHandle", "J"); - } - - MOZ_ASSERT(env->IsInstanceOf(instance, sJNIObjectClass)); - return true; -} - -} // namespace - -uintptr_t GetNativeHandle(JNIEnv* env, jobject instance) -{ - if (!EnsureJNIObject(env, instance)) { - return 0; - } - - return static_cast<uintptr_t>( - env->GetLongField(instance, sJNIObjectHandleField)); -} - -void SetNativeHandle(JNIEnv* env, jobject instance, uintptr_t handle) -{ - if (!EnsureJNIObject(env, instance)) { - return; - } - - env->SetLongField(instance, sJNIObjectHandleField, - static_cast<jlong>(handle)); -} - -jclass GetClassRef(JNIEnv* aEnv, const char* aClassName) -{ - // First try the default class loader. - auto classRef = Class::LocalRef::Adopt(aEnv, aEnv->FindClass(aClassName)); - - if (!classRef && sClassLoader) { - // If the default class loader failed but we have an app class loader, try that. - // Clear the pending exception from failed FindClass call above. - aEnv->ExceptionClear(); - classRef = Class::LocalRef::Adopt(aEnv, jclass( - aEnv->CallObjectMethod(sClassLoader, sClassLoaderLoadClass, - StringParam(aClassName, aEnv).Get()))); - } - - if (classRef) { - return classRef.Forget(); - } - - __android_log_print( - ANDROID_LOG_ERROR, "Gecko", - ">>> FATAL JNI ERROR! FindClass(className=\"%s\") failed. " - "Did ProGuard optimize away something it shouldn't have?", - aClassName); - aEnv->ExceptionDescribe(); - MOZ_CRASH("Cannot find JNI class"); - return nullptr; -} - -void DispatchToGeckoThread(UniquePtr<AbstractCall>&& aCall) -{ - class AbstractCallEvent : public nsAppShell::Event - { - UniquePtr<AbstractCall> mCall; - - public: - AbstractCallEvent(UniquePtr<AbstractCall>&& aCall) - : mCall(Move(aCall)) - {} - - void Run() override - { - (*mCall)(); - } - }; - - nsAppShell::PostEvent(MakeUnique<AbstractCallEvent>(Move(aCall))); -} - -bool IsFennec() -{ - return sIsFennec; -} - -} // jni -} // mozilla diff --git a/widget/android/jni/Utils.h b/widget/android/jni/Utils.h deleted file mode 100644 index 38e0b6b0c..000000000 --- a/widget/android/jni/Utils.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef mozilla_jni_Utils_h__ -#define mozilla_jni_Utils_h__ - -#include <jni.h> - -#include "mozilla/UniquePtr.h" - -#if defined(DEBUG) || !defined(RELEASE_OR_BETA) -#define MOZ_CHECK_JNI -#endif - -#ifdef MOZ_CHECK_JNI -#include <pthread.h> -#include "mozilla/Assertions.h" -#include "APKOpen.h" -#include "MainThreadUtils.h" -#endif - -namespace mozilla { -namespace jni { - -// How exception during a JNI call should be treated. -enum class ExceptionMode -{ - // Abort on unhandled excepion (default). - ABORT, - // Ignore the exception and return to caller. - IGNORE, - // Catch any exception and return a nsresult. - NSRESULT, -}; - -// Thread that a particular JNI call is allowed on. -enum class CallingThread -{ - // Can be called from any thread (default). - ANY, - // Can be called from the Gecko thread. - GECKO, - // Can be called from the Java UI thread. - UI, -}; - -// If and where a JNI call will be dispatched. -enum class DispatchTarget -{ - // Call happens synchronously on the calling thread (default). - CURRENT, - // Call happens synchronously on the calling thread, but the call is - // wrapped in a function object and is passed thru UsesNativeCallProxy. - // Method must return void. - PROXY, - // Call is dispatched asynchronously on the Gecko thread. Method must - // return void. - GECKO, -}; - - -extern JNIEnv* sGeckoThreadEnv; - -inline bool IsAvailable() -{ - return !!sGeckoThreadEnv; -} - -inline JNIEnv* GetGeckoThreadEnv() -{ -#ifdef MOZ_CHECK_JNI - MOZ_RELEASE_ASSERT(NS_IsMainThread(), "Must be on Gecko thread"); - MOZ_RELEASE_ASSERT(sGeckoThreadEnv, "Must have a JNIEnv"); -#endif - return sGeckoThreadEnv; -} - -void SetGeckoThreadEnv(JNIEnv* aEnv); - -JNIEnv* GetEnvForThread(); - -#ifdef MOZ_CHECK_JNI -#define MOZ_ASSERT_JNI_THREAD(thread) \ - do { \ - if ((thread) == mozilla::jni::CallingThread::GECKO) { \ - MOZ_RELEASE_ASSERT(::NS_IsMainThread()); \ - } else if ((thread) == mozilla::jni::CallingThread::UI) { \ - const bool isOnUiThread = ::pthread_equal(::pthread_self(), \ - ::getJavaUiThread()); \ - MOZ_RELEASE_ASSERT(isOnUiThread); \ - } \ - } while (0) -#else -#define MOZ_ASSERT_JNI_THREAD(thread) do {} while (0) -#endif - -bool ThrowException(JNIEnv *aEnv, const char *aClass, - const char *aMessage); - -inline bool ThrowException(JNIEnv *aEnv, const char *aMessage) -{ - return ThrowException(aEnv, "java/lang/Exception", aMessage); -} - -inline bool ThrowException(const char *aClass, const char *aMessage) -{ - return ThrowException(GetEnvForThread(), aClass, aMessage); -} - -inline bool ThrowException(const char *aMessage) -{ - return ThrowException(GetEnvForThread(), aMessage); -} - -bool HandleUncaughtException(JNIEnv* aEnv); - -bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack); - -#define MOZ_CATCH_JNI_EXCEPTION(env) \ - do { \ - if (mozilla::jni::HandleUncaughtException((env))) { \ - MOZ_CRASH("JNI exception"); \ - } \ - } while (0) - - -uintptr_t GetNativeHandle(JNIEnv* env, jobject instance); - -void SetNativeHandle(JNIEnv* env, jobject instance, uintptr_t handle); - -jclass GetClassRef(JNIEnv* aEnv, const char* aClassName); - -struct AbstractCall -{ - virtual ~AbstractCall() {} - virtual void operator()() = 0; -}; - -void DispatchToGeckoThread(UniquePtr<AbstractCall>&& aCall); - -/** - * Returns whether Gecko is running in a Fennec environment, as determined by - * the presence of the GeckoApp class. - */ -bool IsFennec(); - -} // jni -} // mozilla - -#endif // mozilla_jni_Utils_h__ diff --git a/widget/android/jni/moz.build b/widget/android/jni/moz.build deleted file mode 100644 index 31d7d32e6..000000000 --- a/widget/android/jni/moz.build +++ /dev/null @@ -1,24 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -EXPORTS.mozilla.jni += [ - 'Accessors.h', - 'Natives.h', - 'Refs.h', - 'Types.h', - 'Utils.h', -] - -UNIFIED_SOURCES += [ - 'Utils.cpp', -] - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '/widget', - '/widget/android', -] diff --git a/widget/android/moz.build b/widget/android/moz.build deleted file mode 100644 index e80ed01c1..000000000 --- a/widget/android/moz.build +++ /dev/null @@ -1,73 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DIRS += [ - 'bindings', - 'fennec', - 'jni', -] - -XPIDL_SOURCES += [ - 'nsIAndroidBridge.idl', -] - -XPIDL_MODULE = 'widget_android' - -EXPORTS += [ - 'AndroidBridge.h', - 'AndroidJavaWrappers.h', - 'AndroidJNIWrapper.h', - 'GeneratedJNINatives.h', - 'GeneratedJNIWrappers.h', -] - -EXPORTS.mozilla.widget += [ - 'AndroidCompositorWidget.h', -] - -UNIFIED_SOURCES += [ - 'AndroidAlerts.cpp', - 'AndroidBridge.cpp', - 'AndroidCompositorWidget.cpp', - 'AndroidContentController.cpp', - 'AndroidJavaWrappers.cpp', - 'AndroidJNI.cpp', - 'AndroidJNIWrapper.cpp', - 'ANRReporter.cpp', - 'GeneratedJNIWrappers.cpp', - 'GfxInfo.cpp', - 'NativeJSContainer.cpp', - 'nsAndroidProtocolHandler.cpp', - 'nsAppShell.cpp', - 'nsClipboard.cpp', - 'nsDeviceContextAndroid.cpp', - 'nsIdleServiceAndroid.cpp', - 'nsLookAndFeel.cpp', - 'nsPrintOptionsAndroid.cpp', - 'nsScreenManagerAndroid.cpp', - 'nsWidgetFactory.cpp', - 'nsWindow.cpp', -] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '/docshell/base', - '/dom/base', - '/dom/system/android', - '/netwerk/base', - '/netwerk/cache', - '/widget', -] - -CXXFLAGS += ['-Wno-error=shadow'] - -OS_LIBS += ['android'] - -#DEFINES['DEBUG_WIDGETS'] = True - diff --git a/widget/android/nsAndroidProtocolHandler.cpp b/widget/android/nsAndroidProtocolHandler.cpp deleted file mode 100644 index e59a5d5cf..000000000 --- a/widget/android/nsAndroidProtocolHandler.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:set ts=4 sw=4 sts=4 et cin: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsAndroidProtocolHandler.h" -#include "nsCOMPtr.h" -#include "nsIChannel.h" -#include "nsIIOService.h" -#include "nsIStandardURL.h" -#include "nsIURL.h" -#include "android/log.h" -#include "nsBaseChannel.h" -#include "AndroidBridge.h" -#include "GeneratedJNIWrappers.h" - -using namespace mozilla; - -class AndroidInputStream : public nsIInputStream -{ -public: - AndroidInputStream(jni::Object::Param connection) { - mBridgeInputStream = java::GeckoAppShell::CreateInputStream(connection); - mBridgeChannel = AndroidBridge::ChannelCreate(mBridgeInputStream); - } - -private: - virtual ~AndroidInputStream() { - } - -public: - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_NSIINPUTSTREAM - -private: - jni::Object::GlobalRef mBridgeInputStream; - jni::Object::GlobalRef mBridgeChannel; -}; - -NS_IMPL_ISUPPORTS(AndroidInputStream, nsIInputStream) - -NS_IMETHODIMP AndroidInputStream::Close(void) { - AndroidBridge::InputStreamClose(mBridgeInputStream); - return NS_OK; -} - -NS_IMETHODIMP AndroidInputStream::Available(uint64_t *_retval) { - *_retval = AndroidBridge::InputStreamAvailable(mBridgeInputStream); - return NS_OK; -} - -NS_IMETHODIMP AndroidInputStream::Read(char *aBuf, uint32_t aCount, uint32_t *_retval) { - return AndroidBridge::InputStreamRead(mBridgeChannel, aBuf, aCount, _retval); -} - -NS_IMETHODIMP AndroidInputStream::ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, uint32_t aCount, uint32_t *_retval) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP AndroidInputStream::IsNonBlocking(bool *_retval) { - *_retval = false; - return NS_OK; -} - - -class AndroidChannel : public nsBaseChannel -{ -private: - AndroidChannel(nsIURI *aURI, jni::Object::Param aConnection) { - mConnection = aConnection; - SetURI(aURI); - - auto type = java::GeckoAppShell::ConnectionGetMimeType(mConnection); - if (type) { - SetContentType(type->ToCString()); - } - } - -public: - static AndroidChannel* CreateChannel(nsIURI *aURI) { - nsCString spec; - aURI->GetSpec(spec); - - auto connection = java::GeckoAppShell::GetConnection(spec); - return connection ? new AndroidChannel(aURI, connection) : nullptr; - } - - virtual ~AndroidChannel() { - } - - virtual nsresult OpenContentStream(bool async, nsIInputStream **result, - nsIChannel** channel) { - nsCOMPtr<nsIInputStream> stream = new AndroidInputStream(mConnection); - NS_ADDREF(*result = stream); - return NS_OK; - } - -private: - jni::Object::GlobalRef mConnection; -}; - -NS_IMPL_ISUPPORTS(nsAndroidProtocolHandler, - nsIProtocolHandler, - nsISupportsWeakReference) - - -NS_IMETHODIMP -nsAndroidProtocolHandler::GetScheme(nsACString &result) -{ - result.AssignLiteral("android"); - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::GetDefaultPort(int32_t *result) -{ - *result = -1; // no port for android: URLs - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::AllowPort(int32_t port, const char *scheme, bool *_retval) -{ - // don't override anything. - *_retval = false; - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::GetProtocolFlags(uint32_t *result) -{ - *result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE | URI_NORELATIVE | URI_DANGEROUS_TO_LOAD; - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::NewURI(const nsACString &aSpec, - const char *aCharset, - nsIURI *aBaseURI, - nsIURI **result) -{ - nsresult rv; - - nsCOMPtr<nsIStandardURL> surl(do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = surl->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr<nsIURL> url(do_QueryInterface(surl, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - surl->SetMutable(false); - - NS_ADDREF(*result = url); - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::NewChannel2(nsIURI* aURI, - nsILoadInfo* aLoadInfo, - nsIChannel** aResult) -{ - nsCOMPtr<nsIChannel> channel = AndroidChannel::CreateChannel(aURI); - if (!channel) - return NS_ERROR_FAILURE; - - // set the loadInfo on the new channel - nsresult rv = channel->SetLoadInfo(aLoadInfo); - NS_ENSURE_SUCCESS(rv, rv); - - NS_ADDREF(*aResult = channel); - return NS_OK; -} - -NS_IMETHODIMP -nsAndroidProtocolHandler::NewChannel(nsIURI* aURI, - nsIChannel* *aResult) -{ - return NewChannel2(aURI, nullptr, aResult); -} diff --git a/widget/android/nsAndroidProtocolHandler.h b/widget/android/nsAndroidProtocolHandler.h deleted file mode 100644 index 11705dd0a..000000000 --- a/widget/android/nsAndroidProtocolHandler.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsAndroidProtocolHandler_h___ -#define nsAndroidProtocolHandler_h___ - -#include "nsIProtocolHandler.h" -#include "nsWeakReference.h" -#include "mozilla/Attributes.h" - -#define NS_ANDROIDPROTOCOLHANDLER_CID \ -{ /* e9cd2b7f-8386-441b-aaf5-0b371846bfd0 */ \ - 0xe9cd2b7f, \ - 0x8386, \ - 0x441b, \ - {0x0b, 0x37, 0x18, 0x46, 0xbf, 0xd0} \ -} - -class nsAndroidProtocolHandler final : public nsIProtocolHandler, - public nsSupportsWeakReference -{ -public: - NS_DECL_THREADSAFE_ISUPPORTS - - // nsIProtocolHandler methods: - NS_DECL_NSIPROTOCOLHANDLER - - // nsAndroidProtocolHandler methods: - nsAndroidProtocolHandler() {} - -private: - ~nsAndroidProtocolHandler() {} -}; - -#endif /* nsAndroidProtocolHandler_h___ */ diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp deleted file mode 100644 index 09548c27b..000000000 --- a/widget/android/nsAppShell.cpp +++ /dev/null @@ -1,683 +0,0 @@ -/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsAppShell.h" - -#include "base/basictypes.h" -#include "base/message_loop.h" -#include "base/task.h" -#include "mozilla/Hal.h" -#include "nsIScreen.h" -#include "nsIScreenManager.h" -#include "nsWindow.h" -#include "nsThreadUtils.h" -#include "nsICommandLineRunner.h" -#include "nsIObserverService.h" -#include "nsIAppStartup.h" -#include "nsIGeolocationProvider.h" -#include "nsCacheService.h" -#include "nsIDOMEventListener.h" -#include "nsIDOMClientRectList.h" -#include "nsIDOMClientRect.h" -#include "nsIDOMWakeLockListener.h" -#include "nsIPowerManagerService.h" -#include "nsISpeculativeConnect.h" -#include "nsIURIFixup.h" -#include "nsCategoryManagerUtils.h" -#include "nsCDefaultURIFixup.h" -#include "nsToolkitCompsCID.h" -#include "nsGeoPosition.h" - -#include "mozilla/Services.h" -#include "mozilla/Preferences.h" -#include "mozilla/Hal.h" -#include "prenv.h" - -#include "AndroidBridge.h" -#include "AndroidBridgeUtilities.h" -#include "GeneratedJNINatives.h" -#include <android/log.h> -#include <pthread.h> -#include <wchar.h> - -#include "GeckoProfiler.h" -#ifdef MOZ_ANDROID_HISTORY -#include "nsNetUtil.h" -#include "nsIURI.h" -#include "IHistory.h" -#endif - -#ifdef MOZ_LOGGING -#include "mozilla/Logging.h" -#endif - -#include "AndroidAlerts.h" -#include "ANRReporter.h" -#include "GeckoBatteryManager.h" -#include "GeckoNetworkManager.h" -#include "GeckoScreenOrientation.h" -#include "PrefsHelper.h" -#include "fennec/MemoryMonitor.h" -#include "fennec/Telemetry.h" -#include "fennec/ThumbnailHelper.h" - -#ifdef DEBUG_ANDROID_EVENTS -#define EVLOG(args...) ALOG(args) -#else -#define EVLOG(args...) do { } while (0) -#endif - -using namespace mozilla; - -nsIGeolocationUpdate *gLocationCallback = nullptr; - -nsAppShell* nsAppShell::sAppShell; -StaticAutoPtr<Mutex> nsAppShell::sAppShellLock; - -NS_IMPL_ISUPPORTS_INHERITED(nsAppShell, nsBaseAppShell, nsIObserver) - -class WakeLockListener final : public nsIDOMMozWakeLockListener { -private: - ~WakeLockListener() {} - -public: - NS_DECL_ISUPPORTS; - - nsresult Callback(const nsAString& topic, const nsAString& state) override { - java::GeckoAppShell::NotifyWakeLockChanged(topic, state); - return NS_OK; - } -}; - -NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener) -nsCOMPtr<nsIPowerManagerService> sPowerManagerService = nullptr; -StaticRefPtr<WakeLockListener> sWakeLockListener; - - -class GeckoThreadSupport final - : public java::GeckoThread::Natives<GeckoThreadSupport> -{ - // When this number goes above 0, the app is paused. When less than or - // equal to zero, the app is resumed. - static int32_t sPauseCount; - -public: - static void SpeculativeConnect(jni::String::Param aUriStr) - { - if (!NS_IsMainThread()) { - // We will be on the main thread if the call was queued on the Java - // side during startup. Otherwise, the call was not queued, which - // means Gecko is already sufficiently loaded, and we don't really - // care about speculative connections at this point. - return; - } - - nsCOMPtr<nsIIOService> ioServ = do_GetIOService(); - nsCOMPtr<nsISpeculativeConnect> specConn = do_QueryInterface(ioServ); - if (!specConn) { - return; - } - - nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUriStr->ToCString()); - if (!uri) { - return; - } - specConn->SpeculativeConnect(uri, nullptr); - } - - static void WaitOnGecko() - { - struct NoOpEvent : nsAppShell::Event { - void Run() override {} - }; - nsAppShell::SyncRunEvent(NoOpEvent()); - } - - static void OnPause() - { - MOZ_ASSERT(NS_IsMainThread()); - - sPauseCount++; - // If sPauseCount is now 1, we just crossed the threshold from "resumed" - // "paused". so we should notify observers and so on. - if (sPauseCount != 1) { - return; - } - - nsCOMPtr<nsIObserverService> obsServ = - mozilla::services::GetObserverService(); - obsServ->NotifyObservers(nullptr, "application-background", nullptr); - - NS_NAMED_LITERAL_STRING(minimize, "heap-minimize"); - obsServ->NotifyObservers(nullptr, "memory-pressure", minimize.get()); - - // If we are OOM killed with the disk cache enabled, the entire - // cache will be cleared (bug 105843), so shut down the cache here - // and re-init on foregrounding - if (nsCacheService::GlobalInstance()) { - nsCacheService::GlobalInstance()->Shutdown(); - } - - // We really want to send a notification like profile-before-change, - // but profile-before-change ends up shutting some things down instead - // of flushing data - nsIPrefService* prefs = Preferences::GetService(); - if (prefs) { - prefs->SavePrefFile(nullptr); - } - } - - static void OnResume() - { - MOZ_ASSERT(NS_IsMainThread()); - - sPauseCount--; - // If sPauseCount is now 0, we just crossed the threshold from "paused" - // to "resumed", so we should notify observers and so on. - if (sPauseCount != 0) { - return; - } - - // If we are OOM killed with the disk cache enabled, the entire - // cache will be cleared (bug 105843), so shut down cache on backgrounding - // and re-init here - if (nsCacheService::GlobalInstance()) { - nsCacheService::GlobalInstance()->Init(); - } - - // We didn't return from one of our own activities, so restore - // to foreground status - nsCOMPtr<nsIObserverService> obsServ = - mozilla::services::GetObserverService(); - obsServ->NotifyObservers(nullptr, "application-foreground", nullptr); - } - - static void CreateServices(jni::String::Param aCategory, jni::String::Param aData) - { - MOZ_ASSERT(NS_IsMainThread()); - - nsCString category(aCategory->ToCString()); - - NS_CreateServicesFromCategory( - category.get(), - nullptr, // aOrigin - category.get(), - aData ? aData->ToString().get() : nullptr); - } - - static int64_t RunUiThreadCallback() - { - if (!AndroidBridge::Bridge()) { - return -1; - } - - return AndroidBridge::Bridge()->RunDelayedUiThreadTasks(); - } -}; - -int32_t GeckoThreadSupport::sPauseCount; - - -class GeckoAppShellSupport final - : public java::GeckoAppShell::Natives<GeckoAppShellSupport> -{ -public: - static void ReportJavaCrash(const jni::Class::LocalRef& aCls, - jni::Throwable::Param aException, - jni::String::Param aStack) - { - if (!jni::ReportException(aCls.Env(), aException.Get(), aStack.Get())) { - // Only crash below if crash reporter is initialized and annotation - // succeeded. Otherwise try other means of reporting the crash in - // Java. - return; - } - - MOZ_CRASH("Uncaught Java exception"); - } - - static void SyncNotifyObservers(jni::String::Param aTopic, - jni::String::Param aData) - { - MOZ_RELEASE_ASSERT(NS_IsMainThread()); - NotifyObservers(aTopic, aData); - } - - static void NotifyObservers(jni::String::Param aTopic, - jni::String::Param aData) - { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aTopic); - - nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService(); - if (!obsServ) { - return; - } - - obsServ->NotifyObservers(nullptr, aTopic->ToCString().get(), - aData ? aData->ToString().get() : nullptr); - } - - static void OnSensorChanged(int32_t aType, float aX, float aY, float aZ, - float aW, int32_t aAccuracy, int64_t aTime) - { - AutoTArray<float, 4> values; - - switch (aType) { - // Bug 938035, transfer HAL data for orientation sensor to meet w3c - // spec, ex: HAL report alpha=90 means East but alpha=90 means West - // in w3c spec - case hal::SENSOR_ORIENTATION: - values.AppendElement(360.0f - aX); - values.AppendElement(-aY); - values.AppendElement(-aZ); - break; - - case hal::SENSOR_LINEAR_ACCELERATION: - case hal::SENSOR_ACCELERATION: - case hal::SENSOR_GYROSCOPE: - case hal::SENSOR_PROXIMITY: - values.AppendElement(aX); - values.AppendElement(aY); - values.AppendElement(aZ); - break; - - case hal::SENSOR_LIGHT: - values.AppendElement(aX); - break; - - case hal::SENSOR_ROTATION_VECTOR: - case hal::SENSOR_GAME_ROTATION_VECTOR: - values.AppendElement(aX); - values.AppendElement(aY); - values.AppendElement(aZ); - values.AppendElement(aW); - break; - - default: - __android_log_print(ANDROID_LOG_ERROR, "Gecko", - "Unknown sensor type %d", aType); - } - - hal::SensorData sdata(hal::SensorType(aType), aTime, values, - hal::SensorAccuracyType(aAccuracy)); - hal::NotifySensorChange(sdata); - } - - static void OnLocationChanged(double aLatitude, double aLongitude, - double aAltitude, float aAccuracy, - float aBearing, float aSpeed, int64_t aTime) - { - if (!gLocationCallback) { - return; - } - - RefPtr<nsIDOMGeoPosition> geoPosition( - new nsGeoPosition(aLatitude, aLongitude, aAltitude, aAccuracy, - aAccuracy, aBearing, aSpeed, aTime)); - gLocationCallback->Update(geoPosition); - } - - static void NotifyUriVisited(jni::String::Param aUri) - { -#ifdef MOZ_ANDROID_HISTORY - nsCOMPtr<IHistory> history = services::GetHistoryService(); - nsCOMPtr<nsIURI> visitedURI; - if (history && - NS_SUCCEEDED(NS_NewURI(getter_AddRefs(visitedURI), - aUri->ToString()))) { - history->NotifyVisited(visitedURI); - } -#endif - } - - static void NotifyAlertListener(jni::String::Param aName, - jni::String::Param aTopic, - jni::String::Param aCookie) - { - if (!aName || !aTopic || !aCookie) { - return; - } - - AndroidAlerts::NotifyListener( - aName->ToString(), aTopic->ToCString().get(), - aCookie->ToString().get()); - } - - static void OnFullScreenPluginHidden(jni::Object::Param aView) - { - nsPluginInstanceOwner::ExitFullScreen(aView.Get()); - } -}; - -nsAppShell::nsAppShell() - : mSyncRunFinished(*(sAppShellLock = new Mutex("nsAppShell")), - "nsAppShell.SyncRun") - , mSyncRunQuit(false) -{ - { - MutexAutoLock lock(*sAppShellLock); - sAppShell = this; - } - - if (!XRE_IsParentProcess()) { - return; - } - - if (jni::IsAvailable()) { - // Initialize JNI and Set the corresponding state in GeckoThread. - AndroidBridge::ConstructBridge(); - GeckoAppShellSupport::Init(); - GeckoThreadSupport::Init(); - mozilla::GeckoBatteryManager::Init(); - mozilla::GeckoNetworkManager::Init(); - mozilla::GeckoScreenOrientation::Init(); - mozilla::PrefsHelper::Init(); - nsWindow::InitNatives(); - - if (jni::IsFennec()) { - mozilla::ANRReporter::Init(); - mozilla::MemoryMonitor::Init(); - mozilla::widget::Telemetry::Init(); - mozilla::ThumbnailHelper::Init(); - } - - java::GeckoThread::SetState(java::GeckoThread::State::JNI_READY()); - } - - sPowerManagerService = do_GetService(POWERMANAGERSERVICE_CONTRACTID); - - if (sPowerManagerService) { - sWakeLockListener = new WakeLockListener(); - } else { - NS_WARNING("Failed to retrieve PowerManagerService, wakelocks will be broken!"); - } -} - -nsAppShell::~nsAppShell() -{ - { - MutexAutoLock lock(*sAppShellLock); - sAppShell = nullptr; - } - - while (mEventQueue.Pop(/* mayWait */ false)) { - NS_WARNING("Discarded event on shutdown"); - } - - if (sPowerManagerService) { - sPowerManagerService->RemoveWakeLockListener(sWakeLockListener); - - sPowerManagerService = nullptr; - sWakeLockListener = nullptr; - } - - if (jni::IsAvailable()) { - AndroidBridge::DeconstructBridge(); - } -} - -void -nsAppShell::NotifyNativeEvent() -{ - mEventQueue.Signal(); -} - -#define PREFNAME_COALESCE_TOUCHES "dom.event.touch.coalescing.enabled" -static const char* kObservedPrefs[] = { - PREFNAME_COALESCE_TOUCHES, - nullptr -}; - -nsresult -nsAppShell::Init() -{ - nsresult rv = nsBaseAppShell::Init(); - nsCOMPtr<nsIObserverService> obsServ = - mozilla::services::GetObserverService(); - if (obsServ) { - obsServ->AddObserver(this, "browser-delayed-startup-finished", false); - obsServ->AddObserver(this, "profile-after-change", false); - obsServ->AddObserver(this, "chrome-document-loaded", false); - obsServ->AddObserver(this, "quit-application-granted", false); - obsServ->AddObserver(this, "xpcom-shutdown", false); - } - - if (sPowerManagerService) - sPowerManagerService->AddWakeLockListener(sWakeLockListener); - - Preferences::AddStrongObservers(this, kObservedPrefs); - mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true); - return rv; -} - -NS_IMETHODIMP -nsAppShell::Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aData) -{ - bool removeObserver = false; - - if (!strcmp(aTopic, "xpcom-shutdown")) { - { - // Release any thread waiting for a sync call to finish. - mozilla::MutexAutoLock shellLock(*sAppShellLock); - mSyncRunQuit = true; - mSyncRunFinished.NotifyAll(); - } - // We need to ensure no observers stick around after XPCOM shuts down - // or we'll see crashes, as the app shell outlives XPConnect. - mObserversHash.Clear(); - return nsBaseAppShell::Observe(aSubject, aTopic, aData); - - } else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && - aData && - nsDependentString(aData).Equals(NS_LITERAL_STRING(PREFNAME_COALESCE_TOUCHES))) { - mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true); - return NS_OK; - - } else if (!strcmp(aTopic, "browser-delayed-startup-finished")) { - NS_CreateServicesFromCategory("browser-delayed-startup-finished", nullptr, - "browser-delayed-startup-finished"); - - } else if (!strcmp(aTopic, "profile-after-change")) { - if (jni::IsAvailable()) { - // See if we want to force 16-bit color before doing anything - if (Preferences::GetBool("gfx.android.rgb16.force", false)) { - java::GeckoAppShell::SetScreenDepthOverride(16); - } - - java::GeckoThread::SetState( - java::GeckoThread::State::PROFILE_READY()); - - // Gecko on Android follows the Android app model where it never - // stops until it is killed by the system or told explicitly to - // quit. Therefore, we should *not* exit Gecko when there is no - // window or the last window is closed. nsIAppStartup::Quit will - // still force Gecko to exit. - nsCOMPtr<nsIAppStartup> appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); - if (appStartup) { - appStartup->EnterLastWindowClosingSurvivalArea(); - } - } - removeObserver = true; - - } else if (!strcmp(aTopic, "chrome-document-loaded")) { - if (jni::IsAvailable()) { - // Our first window has loaded, assume any JS initialization has run. - java::GeckoThread::CheckAndSetState( - java::GeckoThread::State::PROFILE_READY(), - java::GeckoThread::State::RUNNING()); - } - removeObserver = true; - - } else if (!strcmp(aTopic, "quit-application-granted")) { - if (jni::IsAvailable()) { - java::GeckoThread::SetState( - java::GeckoThread::State::EXITING()); - - // We are told explicitly to quit, perhaps due to - // nsIAppStartup::Quit being called. We should release our hold on - // nsIAppStartup and let it continue to quit. - nsCOMPtr<nsIAppStartup> appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); - if (appStartup) { - appStartup->ExitLastWindowClosingSurvivalArea(); - } - } - removeObserver = true; - - } else if (!strcmp(aTopic, "nsPref:changed")) { - if (jni::IsAvailable()) { - mozilla::PrefsHelper::OnPrefChange(aData); - } - } - - if (removeObserver) { - nsCOMPtr<nsIObserverService> obsServ = - mozilla::services::GetObserverService(); - if (obsServ) { - obsServ->RemoveObserver(this, aTopic); - } - } - return NS_OK; -} - -bool -nsAppShell::ProcessNextNativeEvent(bool mayWait) -{ - EVLOG("nsAppShell::ProcessNextNativeEvent %d", mayWait); - - PROFILER_LABEL("nsAppShell", "ProcessNextNativeEvent", - js::ProfileEntry::Category::EVENTS); - - mozilla::UniquePtr<Event> curEvent; - - { - curEvent = mEventQueue.Pop(/* mayWait */ false); - - if (!curEvent && mayWait) { - // This processes messages in the Android Looper. Note that we only - // get here if the normal Gecko event loop has been awoken - // (bug 750713). Looper messages effectively have the lowest - // priority because we only process them before we're about to - // wait for new events. - if (jni::IsAvailable() && - AndroidBridge::Bridge()->PumpMessageLoop()) { - return true; - } - - PROFILER_LABEL("nsAppShell", "ProcessNextNativeEvent::Wait", - js::ProfileEntry::Category::EVENTS); - mozilla::HangMonitor::Suspend(); - - curEvent = mEventQueue.Pop(/* mayWait */ true); - } - } - - if (!curEvent) - return false; - - mozilla::HangMonitor::NotifyActivity(curEvent->ActivityType()); - - curEvent->Run(); - return true; -} - -void -nsAppShell::SyncRunEvent(Event&& event, - UniquePtr<Event>(*eventFactory)(UniquePtr<Event>&&)) -{ - // Perform the call on the Gecko thread in a separate lambda, and wait - // on the monitor on the current thread. - MOZ_ASSERT(!NS_IsMainThread()); - - // This is the lock to check that app shell is still alive, - // and to wait on for the sync call to complete. - mozilla::MutexAutoLock shellLock(*sAppShellLock); - nsAppShell* const appShell = sAppShell; - - if (MOZ_UNLIKELY(!appShell)) { - // Post-shutdown. - return; - } - - bool finished = false; - auto runAndNotify = [&event, &finished] { - mozilla::MutexAutoLock shellLock(*sAppShellLock); - nsAppShell* const appShell = sAppShell; - if (MOZ_UNLIKELY(!appShell || appShell->mSyncRunQuit)) { - return; - } - event.Run(); - finished = true; - appShell->mSyncRunFinished.NotifyAll(); - }; - - UniquePtr<Event> runAndNotifyEvent = mozilla::MakeUnique< - LambdaEvent<decltype(runAndNotify)>>(mozilla::Move(runAndNotify)); - - if (eventFactory) { - runAndNotifyEvent = (*eventFactory)(mozilla::Move(runAndNotifyEvent)); - } - - appShell->mEventQueue.Post(mozilla::Move(runAndNotifyEvent)); - - while (!finished && MOZ_LIKELY(sAppShell && !sAppShell->mSyncRunQuit)) { - appShell->mSyncRunFinished.Wait(); - } -} - -already_AddRefed<nsIURI> -nsAppShell::ResolveURI(const nsCString& aUriStr) -{ - nsCOMPtr<nsIIOService> ioServ = do_GetIOService(); - nsCOMPtr<nsIURI> uri; - - if (NS_SUCCEEDED(ioServ->NewURI(aUriStr, nullptr, - nullptr, getter_AddRefs(uri)))) { - return uri.forget(); - } - - nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID); - if (fixup && NS_SUCCEEDED( - fixup->CreateFixupURI(aUriStr, 0, nullptr, getter_AddRefs(uri)))) { - return uri.forget(); - } - return nullptr; -} - -nsresult -nsAppShell::AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver) -{ - NS_ASSERTION(aObserver != nullptr, "nsAppShell::AddObserver: aObserver is null!"); - mObserversHash.Put(aObserverKey, aObserver); - return NS_OK; -} - -// Used by IPC code -namespace mozilla { - -bool ProcessNextEvent() -{ - nsAppShell* const appShell = nsAppShell::Get(); - if (!appShell) { - return false; - } - - return appShell->ProcessNextNativeEvent(true) ? true : false; -} - -void NotifyEvent() -{ - nsAppShell* const appShell = nsAppShell::Get(); - if (!appShell) { - return; - } - appShell->NotifyNativeEvent(); -} - -} diff --git a/widget/android/nsAppShell.h b/widget/android/nsAppShell.h deleted file mode 100644 index 42453999d..000000000 --- a/widget/android/nsAppShell.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsAppShell_h__ -#define nsAppShell_h__ - -#include "mozilla/HangMonitor.h" -#include "mozilla/LinkedList.h" -#include "mozilla/Monitor.h" -#include "mozilla/Move.h" -#include "mozilla/StaticPtr.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/Unused.h" -#include "mozilla/jni/Natives.h" -#include "nsBaseAppShell.h" -#include "nsCOMPtr.h" -#include "nsTArray.h" -#include "nsInterfaceHashtable.h" -#include "nsIAndroidBridge.h" - -namespace mozilla { -bool ProcessNextEvent(); -void NotifyEvent(); -} - -class nsWindow; - -class nsAppShell : - public nsBaseAppShell -{ -public: - struct Event : mozilla::LinkedListElement<Event> - { - typedef mozilla::HangMonitor::ActivityType Type; - - bool HasSameTypeAs(const Event* other) const - { - // Compare vtable addresses to determine same type. - return *reinterpret_cast<const uintptr_t*>(this) - == *reinterpret_cast<const uintptr_t*>(other); - } - - virtual ~Event() {} - virtual void Run() = 0; - - virtual void PostTo(mozilla::LinkedList<Event>& queue) - { - queue.insertBack(this); - } - - virtual Type ActivityType() const - { - return Type::kGeneralActivity; - } - }; - - template<typename T> - class LambdaEvent : public Event - { - protected: - T lambda; - - public: - LambdaEvent(T&& l) : lambda(mozilla::Move(l)) {} - void Run() override { return lambda(); } - }; - - class ProxyEvent : public Event - { - protected: - mozilla::UniquePtr<Event> baseEvent; - - public: - ProxyEvent(mozilla::UniquePtr<Event>&& event) - : baseEvent(mozilla::Move(event)) - {} - - void PostTo(mozilla::LinkedList<Event>& queue) override - { - baseEvent->PostTo(queue); - } - - void Run() override - { - baseEvent->Run(); - } - }; - - static nsAppShell* Get() - { - MOZ_ASSERT(NS_IsMainThread()); - return sAppShell; - } - - nsAppShell(); - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIOBSERVER - - nsresult Init(); - - void NotifyNativeEvent(); - bool ProcessNextNativeEvent(bool mayWait) override; - - // Post a subclass of Event. - // e.g. PostEvent(mozilla::MakeUnique<MyEvent>()); - template<typename T, typename D> - static void PostEvent(mozilla::UniquePtr<T, D>&& event) - { - mozilla::MutexAutoLock lock(*sAppShellLock); - if (!sAppShell) { - return; - } - sAppShell->mEventQueue.Post(mozilla::Move(event)); - } - - // Post a event that will call a lambda - // e.g. PostEvent([=] { /* do something */ }); - template<typename T> - static void PostEvent(T&& lambda) - { - mozilla::MutexAutoLock lock(*sAppShellLock); - if (!sAppShell) { - return; - } - sAppShell->mEventQueue.Post(mozilla::MakeUnique<LambdaEvent<T>>( - mozilla::Move(lambda))); - } - - // Post a event and wait for it to finish running on the Gecko thread. - static void SyncRunEvent(Event&& event, - mozilla::UniquePtr<Event>(*eventFactory)( - mozilla::UniquePtr<Event>&&) = nullptr); - - static already_AddRefed<nsIURI> ResolveURI(const nsCString& aUriStr); - - void SetBrowserApp(nsIAndroidBrowserApp* aBrowserApp) { - mBrowserApp = aBrowserApp; - } - - nsIAndroidBrowserApp* GetBrowserApp() { - return mBrowserApp; - } - -protected: - static nsAppShell* sAppShell; - static mozilla::StaticAutoPtr<mozilla::Mutex> sAppShellLock; - - virtual ~nsAppShell(); - - nsresult AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver); - - class NativeCallbackEvent : public Event - { - // Capturing the nsAppShell instance is safe because if the app - // shell is detroyed, this lambda will not be called either. - nsAppShell* const appShell; - - public: - NativeCallbackEvent(nsAppShell* as) : appShell(as) {} - void Run() override { appShell->NativeEventCallback(); } - }; - - void ScheduleNativeEventCallback() override - { - mEventQueue.Post(mozilla::MakeUnique<NativeCallbackEvent>(this)); - } - - class Queue - { - private: - mozilla::Monitor mMonitor; - mozilla::LinkedList<Event> mQueue; - - public: - Queue() : mMonitor("nsAppShell.Queue") - {} - - void Signal() - { - mozilla::MonitorAutoLock lock(mMonitor); - lock.NotifyAll(); - } - - void Post(mozilla::UniquePtr<Event>&& event) - { - MOZ_ASSERT(event && !event->isInList()); - - mozilla::MonitorAutoLock lock(mMonitor); - event->PostTo(mQueue); - if (event->isInList()) { - // Ownership of event object transfers to the queue. - mozilla::Unused << event.release(); - } - lock.NotifyAll(); - } - - mozilla::UniquePtr<Event> Pop(bool mayWait) - { - mozilla::MonitorAutoLock lock(mMonitor); - - if (mayWait && mQueue.isEmpty()) { - lock.Wait(); - } - // Ownership of event object transfers to the return value. - return mozilla::UniquePtr<Event>(mQueue.popFirst()); - } - - } mEventQueue; - - mozilla::CondVar mSyncRunFinished; - bool mSyncRunQuit; - - bool mAllowCoalescingTouches; - - nsCOMPtr<nsIAndroidBrowserApp> mBrowserApp; - nsInterfaceHashtable<nsStringHashKey, nsIObserver> mObserversHash; -}; - -#endif // nsAppShell_h__ - diff --git a/widget/android/nsClipboard.cpp b/widget/android/nsClipboard.cpp deleted file mode 100644 index 5d70ae16b..000000000 --- a/widget/android/nsClipboard.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/ContentChild.h" -#include "nsClipboard.h" -#include "nsISupportsPrimitives.h" -#include "AndroidBridge.h" -#include "nsCOMPtr.h" -#include "nsComponentManagerUtils.h" -#include "nsXULAppAPI.h" - -using namespace mozilla; -using mozilla::dom::ContentChild; - -NS_IMPL_ISUPPORTS(nsClipboard, nsIClipboard) - -/* The Android clipboard only supports text and doesn't support mime types - * so we assume all clipboard data is text/unicode for now. Documentation - * indicates that support for other data types is planned for future - * releases. - */ - -nsClipboard::nsClipboard() -{ -} - -NS_IMETHODIMP -nsClipboard::SetData(nsITransferable *aTransferable, - nsIClipboardOwner *anOwner, int32_t aWhichClipboard) -{ - if (aWhichClipboard != kGlobalClipboard) - return NS_ERROR_NOT_IMPLEMENTED; - - nsCOMPtr<nsISupports> tmp; - uint32_t len; - nsresult rv = aTransferable->GetTransferData(kUnicodeMime, getter_AddRefs(tmp), - &len); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr<nsISupportsString> supportsString = do_QueryInterface(tmp); - // No support for non-text data - NS_ENSURE_TRUE(supportsString, NS_ERROR_NOT_IMPLEMENTED); - nsAutoString buffer; - supportsString->GetData(buffer); - - java::Clipboard::SetText(buffer); - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard) -{ - if (aWhichClipboard != kGlobalClipboard) - return NS_ERROR_NOT_IMPLEMENTED; - - nsAutoString buffer; - if (!AndroidBridge::Bridge()) - return NS_ERROR_NOT_IMPLEMENTED; - if (!AndroidBridge::Bridge()->GetClipboardText(buffer)) - return NS_ERROR_UNEXPECTED; - - nsresult rv; - nsCOMPtr<nsISupportsString> dataWrapper = - do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = dataWrapper->SetData(buffer); - NS_ENSURE_SUCCESS(rv, rv); - - // If our data flavor has already been added, this will fail. But we don't care - aTransferable->AddDataFlavor(kUnicodeMime); - - nsCOMPtr<nsISupports> nsisupportsDataWrapper = - do_QueryInterface(dataWrapper); - rv = aTransferable->SetTransferData(kUnicodeMime, nsisupportsDataWrapper, - buffer.Length() * sizeof(char16_t)); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::EmptyClipboard(int32_t aWhichClipboard) -{ - if (aWhichClipboard != kGlobalClipboard) - return NS_ERROR_NOT_IMPLEMENTED; - java::Clipboard::ClearText(); - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::HasDataMatchingFlavors(const char **aFlavorList, - uint32_t aLength, int32_t aWhichClipboard, - bool *aHasText) -{ - *aHasText = false; - if (aWhichClipboard != kGlobalClipboard) - return NS_ERROR_NOT_IMPLEMENTED; - - for (uint32_t k = 0; k < aLength; k++) { - if (strcmp(aFlavorList[k], kUnicodeMime) == 0) { - *aHasText = java::Clipboard::HasText(); - break; - } - } - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::SupportsSelectionClipboard(bool *aIsSupported) -{ - *aIsSupported = false; - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::SupportsFindClipboard(bool* _retval) -{ - *_retval = false; - return NS_OK; -} diff --git a/widget/android/nsClipboard.h b/widget/android/nsClipboard.h deleted file mode 100644 index 657a8dea8..000000000 --- a/widget/android/nsClipboard.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NS_CLIPBOARD_H -#define NS_CLIPBOARD_H - -#include "nsIClipboard.h" - -class nsClipboard final : public nsIClipboard -{ -private: - ~nsClipboard() {} - -public: - NS_DECL_ISUPPORTS - NS_DECL_NSICLIPBOARD - - nsClipboard(); -}; - -#endif diff --git a/widget/android/nsDeviceContextAndroid.cpp b/widget/android/nsDeviceContextAndroid.cpp deleted file mode 100644 index 4c952957e..000000000 --- a/widget/android/nsDeviceContextAndroid.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsDeviceContextAndroid.h" - -#include "mozilla/gfx/PrintTargetPDF.h" -#include "mozilla/RefPtr.h" -#include "nsString.h" -#include "nsIFile.h" -#include "nsIFileStreams.h" -#include "nsIPrintSettings.h" -#include "nsDirectoryServiceDefs.h" - -using namespace mozilla; -using namespace mozilla::gfx; - -NS_IMPL_ISUPPORTS(nsDeviceContextSpecAndroid, nsIDeviceContextSpec) - -already_AddRefed<PrintTarget> -nsDeviceContextSpecAndroid::MakePrintTarget() -{ - nsresult rv = - NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mTempFile)); - NS_ENSURE_SUCCESS(rv, nullptr); - - nsAutoCString filename("tmp-printing.pdf"); - mTempFile->AppendNative(filename); - rv = mTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0660); - NS_ENSURE_SUCCESS(rv, nullptr); - - nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1"); - rv = stream->Init(mTempFile, -1, -1, 0); - NS_ENSURE_SUCCESS(rv, nullptr); - - // XXX: what should we do here for size? screen size? - IntSize size(480, 800); - - return PrintTargetPDF::CreateOrNull(stream, size); -} - -NS_IMETHODIMP -nsDeviceContextSpecAndroid::Init(nsIWidget* aWidget, - nsIPrintSettings* aPS, - bool aIsPrintPreview) -{ - mPrintSettings = aPS; - return NS_OK; -} - -NS_IMETHODIMP -nsDeviceContextSpecAndroid::BeginDocument(const nsAString& aTitle, - const nsAString& aPrintToFileName, - int32_t aStartPage, - int32_t aEndPage) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsDeviceContextSpecAndroid::EndDocument() -{ - nsXPIDLString targetPath; - nsCOMPtr<nsIFile> destFile; - mPrintSettings->GetToFileName(getter_Copies(targetPath)); - - nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(targetPath), - false, getter_AddRefs(destFile)); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoString destLeafName; - rv = destFile->GetLeafName(destLeafName); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsIFile> destDir; - rv = destFile->GetParent(getter_AddRefs(destDir)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mTempFile->MoveTo(destDir, destLeafName); - NS_ENSURE_SUCCESS(rv, rv); - - destFile->SetPermissions(0666); - return NS_OK; -} diff --git a/widget/android/nsDeviceContextAndroid.h b/widget/android/nsDeviceContextAndroid.h deleted file mode 100644 index 7abe38ca4..000000000 --- a/widget/android/nsDeviceContextAndroid.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsIDeviceContextSpec.h" -#include "nsCOMPtr.h" - -class nsDeviceContextSpecAndroid final : public nsIDeviceContextSpec -{ -private: - ~nsDeviceContextSpecAndroid() {} - -public: - NS_DECL_ISUPPORTS - - virtual already_AddRefed<PrintTarget> MakePrintTarget() final; - - NS_IMETHOD Init(nsIWidget* aWidget, - nsIPrintSettings* aPS, - bool aIsPrintPreview) override; - NS_IMETHOD BeginDocument(const nsAString& aTitle, - const nsAString& aPrintToFileName, - int32_t aStartPage, - int32_t aEndPage) override; - NS_IMETHOD EndDocument() override; - NS_IMETHOD BeginPage() override { return NS_OK; } - NS_IMETHOD EndPage() override { return NS_OK; } - -private: - nsCOMPtr<nsIPrintSettings> mPrintSettings; - nsCOMPtr<nsIFile> mTempFile; -}; diff --git a/widget/android/nsIAndroidBridge.idl b/widget/android/nsIAndroidBridge.idl deleted file mode 100644 index 91b1a3d52..000000000 --- a/widget/android/nsIAndroidBridge.idl +++ /dev/null @@ -1,42 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface mozIDOMWindowProxy; - -[scriptable, uuid(e8420a7b-659b-4325-968b-a114a6a067aa)] -interface nsIBrowserTab : nsISupports { - readonly attribute mozIDOMWindowProxy window; - readonly attribute float scale; -}; - -[scriptable, uuid(08426a73-e70b-4680-9282-630932e2b2bb)] -interface nsIUITelemetryObserver : nsISupports { - void startSession(in wstring name, - in long long timestamp); - void stopSession(in wstring name, - in wstring reason, - in long long timestamp); - void addEvent(in wstring action, - in wstring method, - in long long timestamp, - in wstring extras); -}; - -[scriptable, uuid(0370450f-2e9c-4d16-b333-8ca6ce31a5ff)] -interface nsIAndroidBrowserApp : nsISupports { - readonly attribute nsIBrowserTab selectedTab; - nsIBrowserTab getBrowserTab(in int32_t tabId); - nsIUITelemetryObserver getUITelemetryObserver(); -}; - -[scriptable, uuid(1beb70d3-70f3-4742-98cc-a3d301b26c0c)] -interface nsIAndroidBridge : nsISupports -{ - [implicit_jscontext] void handleGeckoMessage(in jsval message); - attribute nsIAndroidBrowserApp browserApp; - void contentDocumentChanged(in mozIDOMWindowProxy window); - boolean isContentDocumentDisplayed(in mozIDOMWindowProxy window); -}; diff --git a/widget/android/nsIdleServiceAndroid.cpp b/widget/android/nsIdleServiceAndroid.cpp deleted file mode 100644 index 1992d8043..000000000 --- a/widget/android/nsIdleServiceAndroid.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIdleServiceAndroid.h" -#include "nsIServiceManager.h" - -NS_IMPL_ISUPPORTS_INHERITED0(nsIdleServiceAndroid, nsIdleService) - -bool -nsIdleServiceAndroid::PollIdleTime(uint32_t *aIdleTime) -{ - return false; -} - -bool -nsIdleServiceAndroid::UsePollMode() -{ - return false; -} diff --git a/widget/android/nsIdleServiceAndroid.h b/widget/android/nsIdleServiceAndroid.h deleted file mode 100644 index 28bca0553..000000000 --- a/widget/android/nsIdleServiceAndroid.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsIdleServiceAndroid_h__ -#define nsIdleServiceAndroid_h__ - -#include "nsIdleService.h" - -class nsIdleServiceAndroid : public nsIdleService -{ -public: - NS_DECL_ISUPPORTS_INHERITED - - bool PollIdleTime(uint32_t* aIdleTime) override; - - static already_AddRefed<nsIdleServiceAndroid> GetInstance() - { - RefPtr<nsIdleService> idleService = nsIdleService::GetInstance(); - if (!idleService) { - idleService = new nsIdleServiceAndroid(); - } - - return idleService.forget().downcast<nsIdleServiceAndroid>(); - } - -protected: - nsIdleServiceAndroid() { } - virtual ~nsIdleServiceAndroid() { } - bool UsePollMode() override; -}; - -#endif // nsIdleServiceAndroid_h__ diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp deleted file mode 100644 index 770b52a24..000000000 --- a/widget/android/nsLookAndFeel.cpp +++ /dev/null @@ -1,500 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/ContentChild.h" -#include "nsStyleConsts.h" -#include "nsXULAppAPI.h" -#include "nsLookAndFeel.h" -#include "gfxFont.h" -#include "gfxFontConstants.h" -#include "mozilla/gfx/2D.h" - -using namespace mozilla; -using mozilla::dom::ContentChild; - -bool nsLookAndFeel::mInitializedSystemColors = false; -AndroidSystemColors nsLookAndFeel::mSystemColors; - -bool nsLookAndFeel::mInitializedShowPassword = false; -bool nsLookAndFeel::mShowPassword = true; - -static const char16_t UNICODE_BULLET = 0x2022; - -nsLookAndFeel::nsLookAndFeel() - : nsXPLookAndFeel() -{ -} - -nsLookAndFeel::~nsLookAndFeel() -{ -} - -#define BG_PRELIGHT_COLOR NS_RGB(0xee,0xee,0xee) -#define FG_PRELIGHT_COLOR NS_RGB(0x77,0x77,0x77) -#define BLACK_COLOR NS_RGB(0x00,0x00,0x00) -#define DARK_GRAY_COLOR NS_RGB(0x40,0x40,0x40) -#define GRAY_COLOR NS_RGB(0x80,0x80,0x80) -#define LIGHT_GRAY_COLOR NS_RGB(0xa0,0xa0,0xa0) -#define RED_COLOR NS_RGB(0xff,0x00,0x00) - -nsresult -nsLookAndFeel::GetSystemColors() -{ - if (mInitializedSystemColors) - return NS_OK; - - if (!AndroidBridge::Bridge()) - return NS_ERROR_FAILURE; - - AndroidBridge::Bridge()->GetSystemColors(&mSystemColors); - - mInitializedSystemColors = true; - - return NS_OK; -} - -nsresult -nsLookAndFeel::CallRemoteGetSystemColors() -{ - // An array has to be used to get data from remote process - InfallibleTArray<uint32_t> colors; - uint32_t colorsCount = sizeof(AndroidSystemColors) / sizeof(nscolor); - - if (!ContentChild::GetSingleton()->SendGetSystemColors(colorsCount, &colors)) - return NS_ERROR_FAILURE; - - NS_ASSERTION(colors.Length() == colorsCount, "System colors array is incomplete"); - if (colors.Length() == 0) - return NS_ERROR_FAILURE; - - if (colors.Length() < colorsCount) - colorsCount = colors.Length(); - - // Array elements correspond to the members of mSystemColors structure, - // so just copy the memory block - memcpy(&mSystemColors, colors.Elements(), sizeof(nscolor) * colorsCount); - - mInitializedSystemColors = true; - - return NS_OK; -} - -nsresult -nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) -{ - nsresult rv = NS_OK; - - if (!mInitializedSystemColors) { - if (XRE_IsParentProcess()) - rv = GetSystemColors(); - else - rv = CallRemoteGetSystemColors(); - NS_ENSURE_SUCCESS(rv, rv); - } - - // XXX we'll want to use context.obtainStyledAttributes on the java side to - // get all of these; see TextView.java for a good exmaple. - - switch (aID) { - // These colors don't seem to be used for anything anymore in Mozilla - // (except here at least TextSelectBackground and TextSelectForeground) - // The CSS2 colors below are used. - case eColorID_WindowBackground: - aColor = NS_RGB(0xFF, 0xFF, 0xFF); - break; - case eColorID_WindowForeground: - aColor = mSystemColors.textColorPrimary; - break; - case eColorID_WidgetBackground: - aColor = mSystemColors.colorBackground; - break; - case eColorID_WidgetForeground: - aColor = mSystemColors.colorForeground; - break; - case eColorID_WidgetSelectBackground: - aColor = mSystemColors.textColorHighlight; - break; - case eColorID_WidgetSelectForeground: - aColor = mSystemColors.textColorPrimaryInverse; - break; - case eColorID_Widget3DHighlight: - aColor = LIGHT_GRAY_COLOR; - break; - case eColorID_Widget3DShadow: - aColor = DARK_GRAY_COLOR; - break; - case eColorID_TextBackground: - // not used? - aColor = mSystemColors.colorBackground; - break; - case eColorID_TextForeground: - // not used? - aColor = mSystemColors.textColorPrimary; - break; - case eColorID_TextSelectBackground: - case eColorID_IMESelectedRawTextBackground: - case eColorID_IMESelectedConvertedTextBackground: - // still used - aColor = mSystemColors.textColorHighlight; - break; - case eColorID_TextSelectForeground: - case eColorID_IMESelectedRawTextForeground: - case eColorID_IMESelectedConvertedTextForeground: - // still used - aColor = mSystemColors.textColorPrimaryInverse; - break; - case eColorID_IMERawInputBackground: - case eColorID_IMEConvertedTextBackground: - aColor = NS_TRANSPARENT; - break; - case eColorID_IMERawInputForeground: - case eColorID_IMEConvertedTextForeground: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID_IMERawInputUnderline: - case eColorID_IMEConvertedTextUnderline: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID_IMESelectedRawTextUnderline: - case eColorID_IMESelectedConvertedTextUnderline: - aColor = NS_TRANSPARENT; - break; - case eColorID_SpellCheckerUnderline: - aColor = RED_COLOR; - break; - - // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors - case eColorID_activeborder: - // active window border - aColor = mSystemColors.colorBackground; - break; - case eColorID_activecaption: - // active window caption background - aColor = mSystemColors.colorBackground; - break; - case eColorID_appworkspace: - // MDI background color - aColor = mSystemColors.colorBackground; - break; - case eColorID_background: - // desktop background - aColor = mSystemColors.colorBackground; - break; - case eColorID_captiontext: - // text in active window caption, size box, and scrollbar arrow box (!) - aColor = mSystemColors.colorForeground; - break; - case eColorID_graytext: - // disabled text in windows, menus, etc. - aColor = mSystemColors.textColorTertiary; - break; - case eColorID_highlight: - // background of selected item - aColor = mSystemColors.textColorHighlight; - break; - case eColorID_highlighttext: - // text of selected item - aColor = mSystemColors.textColorPrimaryInverse; - break; - case eColorID_inactiveborder: - // inactive window border - aColor = mSystemColors.colorBackground; - break; - case eColorID_inactivecaption: - // inactive window caption - aColor = mSystemColors.colorBackground; - break; - case eColorID_inactivecaptiontext: - // text in inactive window caption - aColor = mSystemColors.textColorTertiary; - break; - case eColorID_infobackground: - // tooltip background color - aColor = mSystemColors.colorBackground; - break; - case eColorID_infotext: - // tooltip text color - aColor = mSystemColors.colorForeground; - break; - case eColorID_menu: - // menu background - aColor = mSystemColors.colorBackground; - break; - case eColorID_menutext: - // menu text - aColor = mSystemColors.colorForeground; - break; - case eColorID_scrollbar: - // scrollbar gray area - aColor = mSystemColors.colorBackground; - break; - - case eColorID_threedface: - case eColorID_buttonface: - // 3-D face color - aColor = mSystemColors.colorBackground; - break; - - case eColorID_buttontext: - // text on push buttons - aColor = mSystemColors.colorForeground; - break; - - case eColorID_buttonhighlight: - // 3-D highlighted edge color - case eColorID_threedhighlight: - // 3-D highlighted outer edge color - aColor = LIGHT_GRAY_COLOR; - break; - - case eColorID_threedlightshadow: - // 3-D highlighted inner edge color - aColor = mSystemColors.colorBackground; - break; - - case eColorID_buttonshadow: - // 3-D shadow edge color - case eColorID_threedshadow: - // 3-D shadow inner edge color - aColor = GRAY_COLOR; - break; - - case eColorID_threeddarkshadow: - // 3-D shadow outer edge color - aColor = BLACK_COLOR; - break; - - case eColorID_window: - case eColorID_windowframe: - aColor = mSystemColors.colorBackground; - break; - - case eColorID_windowtext: - aColor = mSystemColors.textColorPrimary; - break; - - case eColorID__moz_eventreerow: - case eColorID__moz_field: - aColor = mSystemColors.colorBackground; - break; - case eColorID__moz_fieldtext: - aColor = mSystemColors.textColorPrimary; - break; - case eColorID__moz_dialog: - aColor = mSystemColors.colorBackground; - break; - case eColorID__moz_dialogtext: - aColor = mSystemColors.colorForeground; - break; - case eColorID__moz_dragtargetzone: - aColor = mSystemColors.textColorHighlight; - break; - case eColorID__moz_buttondefault: - // default button border color - aColor = BLACK_COLOR; - break; - case eColorID__moz_buttonhoverface: - aColor = BG_PRELIGHT_COLOR; - break; - case eColorID__moz_buttonhovertext: - aColor = FG_PRELIGHT_COLOR; - break; - case eColorID__moz_cellhighlight: - case eColorID__moz_html_cellhighlight: - aColor = mSystemColors.textColorHighlight; - break; - case eColorID__moz_cellhighlighttext: - case eColorID__moz_html_cellhighlighttext: - aColor = mSystemColors.textColorPrimaryInverse; - break; - case eColorID__moz_menuhover: - aColor = BG_PRELIGHT_COLOR; - break; - case eColorID__moz_menuhovertext: - aColor = FG_PRELIGHT_COLOR; - break; - case eColorID__moz_oddtreerow: - aColor = NS_TRANSPARENT; - break; - case eColorID__moz_nativehyperlinktext: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID__moz_comboboxtext: - aColor = mSystemColors.colorForeground; - break; - case eColorID__moz_combobox: - aColor = mSystemColors.colorBackground; - break; - case eColorID__moz_menubartext: - aColor = mSystemColors.colorForeground; - break; - case eColorID__moz_menubarhovertext: - aColor = FG_PRELIGHT_COLOR; - break; - default: - /* default color is BLACK */ - aColor = 0; - rv = NS_ERROR_FAILURE; - break; - } - - return rv; -} - - -nsresult -nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) -{ - nsresult rv = nsXPLookAndFeel::GetIntImpl(aID, aResult); - if (NS_SUCCEEDED(rv)) - return rv; - - rv = NS_OK; - - switch (aID) { - case eIntID_CaretBlinkTime: - aResult = 500; - break; - - case eIntID_CaretWidth: - aResult = 1; - break; - - case eIntID_ShowCaretDuringSelection: - aResult = 0; - break; - - case eIntID_SelectTextfieldsOnKeyFocus: - // Select textfield content when focused by kbd - // used by EventStateManager::sTextfieldSelectModel - aResult = 1; - break; - - case eIntID_SubmenuDelay: - aResult = 200; - break; - - case eIntID_TooltipDelay: - aResult = 500; - break; - - case eIntID_MenusCanOverlapOSBar: - // we want XUL popups to be able to overlap the task bar. - aResult = 1; - break; - - case eIntID_ScrollArrowStyle: - aResult = eScrollArrowStyle_Single; - break; - - case eIntID_ScrollSliderStyle: - aResult = eScrollThumbStyle_Proportional; - break; - - case eIntID_TouchEnabled: - aResult = 1; - break; - - case eIntID_ColorPickerAvailable: - aResult = 1; - break; - - case eIntID_WindowsDefaultTheme: - case eIntID_WindowsThemeIdentifier: - case eIntID_OperatingSystemVersionIdentifier: - aResult = 0; - rv = NS_ERROR_NOT_IMPLEMENTED; - break; - - case eIntID_SpellCheckerUnderlineStyle: - aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; - break; - - case eIntID_ScrollbarButtonAutoRepeatBehavior: - aResult = 0; - break; - - case eIntID_ContextMenuOffsetVertical: - case eIntID_ContextMenuOffsetHorizontal: - aResult = 2; - break; - - default: - aResult = 0; - rv = NS_ERROR_FAILURE; - } - - return rv; -} - -nsresult -nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult) -{ - nsresult rv = nsXPLookAndFeel::GetFloatImpl(aID, aResult); - if (NS_SUCCEEDED(rv)) - return rv; - rv = NS_OK; - - switch (aID) { - case eFloatID_IMEUnderlineRelativeSize: - aResult = 1.0f; - break; - - case eFloatID_SpellCheckerUnderlineRelativeSize: - aResult = 1.0f; - break; - - default: - aResult = -1.0; - rv = NS_ERROR_FAILURE; - break; - } - return rv; -} - -/*virtual*/ -bool -nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, - gfxFontStyle& aFontStyle, - float aDevPixPerCSSPixel) -{ - aFontName.AssignLiteral("\"Droid Sans\""); - aFontStyle.style = NS_FONT_STYLE_NORMAL; - aFontStyle.weight = NS_FONT_WEIGHT_NORMAL; - aFontStyle.stretch = NS_FONT_STRETCH_NORMAL; - aFontStyle.size = 9.0 * 96.0f / 72.0f * aDevPixPerCSSPixel; - aFontStyle.systemFont = true; - return true; -} - -/*virtual*/ -bool -nsLookAndFeel::GetEchoPasswordImpl() -{ - if (!mInitializedShowPassword) { - if (XRE_IsParentProcess()) { - mShowPassword = java::GeckoAppShell::GetShowPasswordSetting(); - } else { - ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword); - } - mInitializedShowPassword = true; - } - return mShowPassword; -} - -uint32_t -nsLookAndFeel::GetPasswordMaskDelayImpl() -{ - // This value is hard-coded in Android OS's PasswordTransformationMethod.java - return 1500; -} - -/* virtual */ -char16_t -nsLookAndFeel::GetPasswordCharacterImpl() -{ - // This value is hard-coded in Android OS's PasswordTransformationMethod.java - return UNICODE_BULLET; -} diff --git a/widget/android/nsLookAndFeel.h b/widget/android/nsLookAndFeel.h deleted file mode 100644 index 9b33279a8..000000000 --- a/widget/android/nsLookAndFeel.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef __nsLookAndFeel -#define __nsLookAndFeel - -#include "nsXPLookAndFeel.h" -#include "AndroidBridge.h" - -class nsLookAndFeel: public nsXPLookAndFeel -{ -public: - nsLookAndFeel(); - virtual ~nsLookAndFeel(); - - virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult); - virtual nsresult GetIntImpl(IntID aID, int32_t &aResult); - virtual nsresult GetFloatImpl(FloatID aID, float &aResult); - virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle, - float aDevPixPerCSSPixel); - virtual bool GetEchoPasswordImpl(); - virtual uint32_t GetPasswordMaskDelayImpl(); - virtual char16_t GetPasswordCharacterImpl(); - -protected: - static bool mInitializedSystemColors; - static mozilla::AndroidSystemColors mSystemColors; - static bool mInitializedShowPassword; - static bool mShowPassword; - - nsresult GetSystemColors(); - nsresult CallRemoteGetSystemColors(); -}; - -#endif diff --git a/widget/android/nsPrintOptionsAndroid.cpp b/widget/android/nsPrintOptionsAndroid.cpp deleted file mode 100644 index 03afba827..000000000 --- a/widget/android/nsPrintOptionsAndroid.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsPrintOptionsAndroid.h" - -#include "nsPrintSettingsImpl.h" - -class nsPrintSettingsAndroid : public nsPrintSettings { -public: - nsPrintSettingsAndroid() - { - // The aim here is to set up the objects enough that silent printing works - SetOutputFormat(nsIPrintSettings::kOutputFormatPDF); - SetPrinterName(u"PDF printer"); - - } -}; - -nsPrintOptionsAndroid::nsPrintOptionsAndroid() -{ -} - -nsPrintOptionsAndroid::~nsPrintOptionsAndroid() -{ -} - -nsresult -nsPrintOptionsAndroid::_CreatePrintSettings(nsIPrintSettings** _retval) -{ - nsPrintSettings * printSettings = new nsPrintSettingsAndroid(); - NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY); - NS_ADDREF(*_retval = printSettings); - (void)InitPrintSettingsFromPrefs(*_retval, false, - nsIPrintSettings::kInitSaveAll); - return NS_OK; -} diff --git a/widget/android/nsPrintOptionsAndroid.h b/widget/android/nsPrintOptionsAndroid.h deleted file mode 100644 index 27c4cce83..000000000 --- a/widget/android/nsPrintOptionsAndroid.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsPrintOptionsAndroid_h__ -#define nsPrintOptionsAndroid_h__ - -#include "nsPrintOptionsImpl.h" -#include "nsIPrintSettings.h" - -//***************************************************************************** -//*** nsPrintOptions -//***************************************************************************** -class nsPrintOptionsAndroid : public nsPrintOptions -{ -public: - nsPrintOptionsAndroid(); - virtual ~nsPrintOptionsAndroid(); - - nsresult _CreatePrintSettings(nsIPrintSettings** _retval) override; -}; - -#endif /* nsPrintOptionsAndroid_h__ */ diff --git a/widget/android/nsScreenManagerAndroid.cpp b/widget/android/nsScreenManagerAndroid.cpp deleted file mode 100644 index 4a79b9dab..000000000 --- a/widget/android/nsScreenManagerAndroid.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set sw=4 ts=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY - -#include "mozilla/SyncRunnable.h" -#include "nsScreenManagerAndroid.h" -#include "nsServiceManagerUtils.h" -#include "AndroidRect.h" -#include "FennecJNINatives.h" -#include "nsAppShell.h" -#include "nsThreadUtils.h" - -#include <android/log.h> -#include <mozilla/jni/Refs.h> - -#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "nsScreenManagerAndroid", ## args) - -using namespace mozilla; -using namespace mozilla::java; - -static uint32_t sScreenId = 0; -const uint32_t PRIMARY_SCREEN_ID = 0; - -nsScreenAndroid::nsScreenAndroid(DisplayType aDisplayType, nsIntRect aRect) - : mId(sScreenId++) - , mDisplayType(aDisplayType) - , mRect(aRect) - , mDensity(0.0) -{ - // ensure that the ID of the primary screen would be PRIMARY_SCREEN_ID. - if (mDisplayType == DisplayType::DISPLAY_PRIMARY) { - mId = PRIMARY_SCREEN_ID; - } -} - -nsScreenAndroid::~nsScreenAndroid() -{ -} - -float -nsScreenAndroid::GetDensity() { - if (mDensity != 0.0) { - return mDensity; - } - if (mDisplayType == DisplayType::DISPLAY_PRIMARY) { - mDensity = mozilla::jni::IsAvailable() ? GeckoAppShell::GetDensity() - : 1.0; // xpcshell most likely - return mDensity; - } - return 1.0; -} - -NS_IMETHODIMP -nsScreenAndroid::GetId(uint32_t *outId) -{ - *outId = mId; - return NS_OK; -} - -NS_IMETHODIMP -nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) -{ - if (mDisplayType != DisplayType::DISPLAY_PRIMARY) { - *outLeft = mRect.x; - *outTop = mRect.y; - *outWidth = mRect.width; - *outHeight = mRect.height; - - return NS_OK; - } - - if (!mozilla::jni::IsAvailable()) { - // xpcshell most likely - *outLeft = *outTop = *outWidth = *outHeight = 0; - return NS_ERROR_FAILURE; - } - - java::sdk::Rect::LocalRef rect = java::GeckoAppShell::GetScreenSize(); - rect->Left(outLeft); - rect->Top(outTop); - rect->Width(outWidth); - rect->Height(outHeight); - - return NS_OK; -} - - -NS_IMETHODIMP -nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) -{ - return GetRect(outLeft, outTop, outWidth, outHeight); -} - - - -NS_IMETHODIMP -nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth) -{ - if (!mozilla::jni::IsAvailable()) { - // xpcshell most likely - *aPixelDepth = 16; - return NS_ERROR_FAILURE; - } - - *aPixelDepth = java::GeckoAppShell::GetScreenDepth(); - return NS_OK; -} - - -NS_IMETHODIMP -nsScreenAndroid::GetColorDepth(int32_t *aColorDepth) -{ - return GetPixelDepth(aColorDepth); -} - - -void -nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness) -{ - if (mDisplayType == DisplayType::DISPLAY_PRIMARY && - mozilla::jni::IsAvailable()) { - java::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL); - } -} - -class nsScreenManagerAndroid::ScreenManagerHelperSupport final - : public ScreenManagerHelper::Natives<ScreenManagerHelperSupport> -{ -public: - typedef ScreenManagerHelper::Natives<ScreenManagerHelperSupport> Base; - - static int32_t AddDisplay(int32_t aDisplayType, int32_t aWidth, int32_t aHeight, float aDensity) { - int32_t screenId = -1; // return value - nsCOMPtr<nsIThread> mainThread = do_GetMainThread(); - SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction( - [&aDisplayType, &aWidth, &aHeight, &aDensity, &screenId] { - MOZ_ASSERT(NS_IsMainThread()); - nsCOMPtr<nsIScreenManager> screenMgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager"); - - RefPtr<nsScreenManagerAndroid> screenMgrAndroid = - (nsScreenManagerAndroid*) screenMgr.get(); - RefPtr<nsScreenAndroid> screen = - screenMgrAndroid->AddScreen(static_cast<DisplayType>(aDisplayType), - nsIntRect(0, 0, aWidth, aHeight)); - MOZ_ASSERT(screen); - screen->SetDensity(aDensity); - screenId = static_cast<int32_t>(screen->GetId()); - }).take()); - return screenId; - } - - static void RemoveDisplay(int32_t aScreenId) { - nsCOMPtr<nsIThread> mainThread = do_GetMainThread(); - SyncRunnable::DispatchToThread(mainThread, NS_NewRunnableFunction( - [&aScreenId] { - MOZ_ASSERT(NS_IsMainThread()); - nsCOMPtr<nsIScreenManager> screenMgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager"); - - RefPtr<nsScreenManagerAndroid> screenMgrAndroid = - (nsScreenManagerAndroid*) screenMgr.get(); - screenMgrAndroid->RemoveScreen(aScreenId); - }).take()); - } -}; - -NS_IMPL_ISUPPORTS(nsScreenManagerAndroid, nsIScreenManager) - -nsScreenManagerAndroid::nsScreenManagerAndroid() -{ - if (mozilla::jni::IsAvailable()) { - ScreenManagerHelperSupport::Base::Init(); - } - nsCOMPtr<nsIScreen> screen = AddScreen(DisplayType::DISPLAY_PRIMARY); - MOZ_ASSERT(screen); -} - -nsScreenManagerAndroid::~nsScreenManagerAndroid() -{ -} - -NS_IMETHODIMP -nsScreenManagerAndroid::GetPrimaryScreen(nsIScreen **outScreen) -{ - ScreenForId(PRIMARY_SCREEN_ID, outScreen); - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerAndroid::ScreenForId(uint32_t aId, - nsIScreen **outScreen) -{ - for (size_t i = 0; i < mScreens.Length(); ++i) { - if (aId == mScreens[i]->GetId()) { - nsCOMPtr<nsIScreen> screen = (nsIScreen*) mScreens[i]; - screen.forget(outScreen); - return NS_OK; - } - } - - *outScreen = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerAndroid::ScreenForRect(int32_t inLeft, - int32_t inTop, - int32_t inWidth, - int32_t inHeight, - nsIScreen **outScreen) -{ - // Not support to query non-primary screen with rect. - return GetPrimaryScreen(outScreen); -} - -NS_IMETHODIMP -nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen) -{ - // Not support to query non-primary screen with native widget. - return GetPrimaryScreen(outScreen); -} - -NS_IMETHODIMP -nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens) -{ - *aNumberOfScreens = mScreens.Length(); - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale) -{ - *aDefaultScale = 1.0f; - return NS_OK; -} - -already_AddRefed<nsScreenAndroid> -nsScreenManagerAndroid::AddScreen(DisplayType aDisplayType, nsIntRect aRect) -{ - ALOG("nsScreenManagerAndroid: add %s screen", - (aDisplayType == DisplayType::DISPLAY_PRIMARY ? "PRIMARY" : - (aDisplayType == DisplayType::DISPLAY_EXTERNAL ? "EXTERNAL" : - "VIRTUAL"))); - RefPtr<nsScreenAndroid> screen = new nsScreenAndroid(aDisplayType, aRect); - mScreens.AppendElement(screen); - return screen.forget(); -} - -void -nsScreenManagerAndroid::RemoveScreen(uint32_t aScreenId) -{ - for (size_t i = 0; i < mScreens.Length(); i++) { - if (aScreenId == mScreens[i]->GetId()) { - mScreens.RemoveElementAt(i); - } - } -} diff --git a/widget/android/nsScreenManagerAndroid.h b/widget/android/nsScreenManagerAndroid.h deleted file mode 100644 index cf8bfb245..000000000 --- a/widget/android/nsScreenManagerAndroid.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: ts=4 sw=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsScreenManagerAndroid_h___ -#define nsScreenManagerAndroid_h___ - -#include "nsCOMPtr.h" - -#include "nsBaseScreen.h" -#include "nsIScreenManager.h" -#include "nsRect.h" -#include "mozilla/WidgetUtils.h" - -class nsScreenAndroid final : public nsBaseScreen -{ -public: - nsScreenAndroid(DisplayType aDisplayType, nsIntRect aRect); - ~nsScreenAndroid(); - - NS_IMETHOD GetId(uint32_t* aId) override; - NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override; - NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override; - NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override; - NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override; - - uint32_t GetId() const { return mId; }; - DisplayType GetDisplayType() const { return mDisplayType; } - - void SetDensity(double aDensity) { mDensity = aDensity; } - float GetDensity(); - -protected: - virtual void ApplyMinimumBrightness(uint32_t aBrightness) override; - -private: - uint32_t mId; - DisplayType mDisplayType; - nsIntRect mRect; - float mDensity; -}; - -class nsScreenManagerAndroid final : public nsIScreenManager -{ -private: - ~nsScreenManagerAndroid(); - -public: - class ScreenManagerHelperSupport; - - nsScreenManagerAndroid(); - - NS_DECL_ISUPPORTS - NS_DECL_NSISCREENMANAGER - - already_AddRefed<nsScreenAndroid> AddScreen(DisplayType aDisplayType, - nsIntRect aRect = nsIntRect()); - void RemoveScreen(uint32_t aScreenId); - -protected: - nsTArray<RefPtr<nsScreenAndroid>> mScreens; -}; - -#endif /* nsScreenManagerAndroid_h___ */ diff --git a/widget/android/nsWidgetFactory.cpp b/widget/android/nsWidgetFactory.cpp deleted file mode 100644 index bd930e4a4..000000000 --- a/widget/android/nsWidgetFactory.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "mozilla/WidgetUtils.h" - -#include "nsCOMPtr.h" -#include "nsWidgetsCID.h" -#include "nsAppShell.h" -#include "AndroidBridge.h" - -#include "nsWindow.h" -#include "nsLookAndFeel.h" -#include "nsAppShellSingleton.h" -#include "nsScreenManagerAndroid.h" - -#include "nsIdleServiceAndroid.h" -#include "nsClipboard.h" -#include "nsClipboardHelper.h" -#include "nsTransferable.h" -#include "nsPrintOptionsAndroid.h" -#include "nsPrintSession.h" -#include "nsDeviceContextAndroid.h" -#include "nsHTMLFormatConverter.h" -#include "nsXULAppAPI.h" -#include "nsAndroidProtocolHandler.h" - -#include "nsToolkitCompsCID.h" -#include "AndroidAlerts.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerAndroid) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceAndroid, nsIdleServiceAndroid::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsAndroid, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecAndroid) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidBridge) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidProtocolHandler) - -#include "GfxInfo.h" -namespace mozilla { -namespace widget { -// This constructor should really be shared with all platforms. -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(AndroidAlerts) -} -} - -NS_DEFINE_NAMED_CID(NS_APPSHELL_CID); -NS_DEFINE_NAMED_CID(NS_WINDOW_CID); -NS_DEFINE_NAMED_CID(NS_CHILD_CID); -NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); -NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID); -NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID); -NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); -NS_DEFINE_NAMED_CID(NS_ANDROIDBRIDGE_CID); -NS_DEFINE_NAMED_CID(NS_ANDROIDPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID); - -static const mozilla::Module::CIDEntry kWidgetCIDs[] = { - { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor }, - { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor }, - { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor }, - { &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerAndroidConstructor }, - { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceAndroidConstructor }, - { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor }, - { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor }, - { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor }, - { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsAndroidConstructor }, - { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor }, - { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecAndroidConstructor }, - { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, - { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, - { &kNS_ANDROIDBRIDGE_CID, false, nullptr, nsAndroidBridgeConstructor }, - { &kNS_ANDROIDPROTOCOLHANDLER_CID, false, nullptr, nsAndroidProtocolHandlerConstructor }, - { &kNS_SYSTEMALERTSSERVICE_CID, false, nullptr, mozilla::widget::AndroidAlertsConstructor }, - { nullptr } -}; - -static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { - { "@mozilla.org/widgets/window/android;1", &kNS_WINDOW_CID }, - { "@mozilla.org/widgets/child_window/android;1", &kNS_CHILD_CID }, - { "@mozilla.org/widget/appshell/android;1", &kNS_APPSHELL_CID }, - { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID }, - { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, - { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID }, - { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID }, - { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID }, - { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID }, - { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID }, - { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID }, - { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, - { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, - { "@mozilla.org/android/bridge;1", &kNS_ANDROIDBRIDGE_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "android", &kNS_ANDROIDPROTOCOLHANDLER_CID }, - { NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID }, - { nullptr } -}; - -static void -nsWidgetAndroidModuleDtor() -{ - // Shutdown all XP level widget classes. - mozilla::widget::WidgetUtils::Shutdown(); - - nsLookAndFeel::Shutdown(); - nsAppShellShutdown(); -} - -static const mozilla::Module kWidgetModule = { - mozilla::Module::kVersion, - kWidgetCIDs, - kWidgetContracts, - nullptr, - nullptr, - nsAppShellInit, - nsWidgetAndroidModuleDtor -}; - -NSMODULE_DEFN(nsWidgetAndroidModule) = &kWidgetModule; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp deleted file mode 100644 index 9423a4a26..000000000 --- a/widget/android/nsWindow.cpp +++ /dev/null @@ -1,3638 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- - * vim: set sw=4 ts=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include <android/log.h> -#include <android/native_window.h> -#include <android/native_window_jni.h> -#include <math.h> -#include <unistd.h> - -#include "mozilla/IMEStateManager.h" -#include "mozilla/MiscEvents.h" -#include "mozilla/MouseEvents.h" -#include "mozilla/TextComposition.h" -#include "mozilla/TextEvents.h" -#include "mozilla/TouchEvents.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/WeakPtr.h" - -#include "mozilla/dom/ContentParent.h" -#include "mozilla/dom/ContentChild.h" -#include "mozilla/Unused.h" -#include "mozilla/Preferences.h" -#include "mozilla/layers/RenderTrace.h" -#include <algorithm> - -using mozilla::dom::ContentParent; -using mozilla::dom::ContentChild; -using mozilla::Unused; - -#include "nsWindow.h" - -#include "nsIBaseWindow.h" -#include "nsIDOMChromeWindow.h" -#include "nsIObserverService.h" -#include "nsISelection.h" -#include "nsISupportsPrimitives.h" -#include "nsIWidgetListener.h" -#include "nsIWindowWatcher.h" -#include "nsIXULWindow.h" - -#include "nsAppShell.h" -#include "nsFocusManager.h" -#include "nsIdleService.h" -#include "nsLayoutUtils.h" -#include "nsViewManager.h" - -#include "WidgetUtils.h" - -#include "nsIDOMSimpleGestureEvent.h" - -#include "nsGkAtoms.h" -#include "nsWidgetsCID.h" -#include "nsGfxCIID.h" - -#include "gfxContext.h" - -#include "Layers.h" -#include "mozilla/layers/LayerManagerComposite.h" -#include "mozilla/layers/AsyncCompositionManager.h" -#include "mozilla/layers/APZEventState.h" -#include "mozilla/layers/APZThreadUtils.h" -#include "mozilla/layers/IAPZCTreeManager.h" -#include "GLContext.h" -#include "GLContextProvider.h" -#include "ScopedGLHelpers.h" -#include "mozilla/layers/CompositorOGL.h" -#include "AndroidContentController.h" - -#include "nsTArray.h" - -#include "AndroidBridge.h" -#include "AndroidBridgeUtilities.h" -#include "android_npapi.h" -#include "FennecJNINatives.h" -#include "GeneratedJNINatives.h" -#include "KeyEvent.h" -#include "MotionEvent.h" - -#include "imgIEncoder.h" - -#include "nsString.h" -#include "GeckoProfiler.h" // For PROFILER_LABEL -#include "nsIXULRuntime.h" -#include "nsPrintfCString.h" - -using namespace mozilla; -using namespace mozilla::dom; -using namespace mozilla::layers; -using namespace mozilla::java; -using namespace mozilla::widget; - -NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget) - -#include "mozilla/layers/CompositorBridgeChild.h" -#include "mozilla/layers/CompositorBridgeParent.h" -#include "mozilla/layers/CompositorSession.h" -#include "mozilla/layers/LayerTransactionParent.h" -#include "mozilla/Services.h" -#include "nsThreadUtils.h" - -// All the toplevel windows that have been created; these are in -// stacking order, so the window at gTopLevelWindows[0] is the topmost -// one. -static nsTArray<nsWindow*> gTopLevelWindows; - -static bool sFailedToCreateGLContext = false; - -// Multitouch swipe thresholds in inches -static const double SWIPE_MAX_PINCH_DELTA_INCHES = 0.4; -static const double SWIPE_MIN_DISTANCE_INCHES = 0.6; - -// Sync with GeckoEditableView class -static const int IME_MONITOR_CURSOR_ONE_SHOT = 1; -static const int IME_MONITOR_CURSOR_START_MONITOR = 2; -static const int IME_MONITOR_CURSOR_END_MONITOR = 3; - -static Modifiers GetModifiers(int32_t metaState); - -template<typename Lambda, bool IsStatic, typename InstanceType, class Impl> -class nsWindow::WindowEvent : public nsAppShell::LambdaEvent<Lambda> -{ - typedef nsAppShell::Event Event; - typedef nsAppShell::LambdaEvent<Lambda> Base; - - bool IsStaleCall() - { - if (IsStatic) { - // Static calls are never stale. - return false; - } - - JNIEnv* const env = mozilla::jni::GetEnvForThread(); - - const auto natives = reinterpret_cast<mozilla::WeakPtr<Impl>*>( - jni::GetNativeHandle(env, mInstance.Get())); - MOZ_CATCH_JNI_EXCEPTION(env); - - // The call is stale if the nsWindow has been destroyed on the - // Gecko side, but the Java object is still attached to it through - // a weak pointer. Stale calls should be discarded. Note that it's - // an error if natives is nullptr here; we return false but the - // native call will throw an error. - return natives && !natives->get(); - } - - const InstanceType mInstance; - const Event::Type mEventType; - -public: - WindowEvent(Lambda&& aLambda, - InstanceType&& aInstance, - Event::Type aEventType = Event::Type::kGeneralActivity) - : Base(mozilla::Move(aLambda)) - , mInstance(mozilla::Move(aInstance)) - , mEventType(aEventType) - {} - - WindowEvent(Lambda&& aLambda, - Event::Type aEventType = Event::Type::kGeneralActivity) - : Base(mozilla::Move(aLambda)) - , mInstance(Base::lambda.GetThisArg()) - , mEventType(aEventType) - {} - - void Run() override - { - if (!IsStaleCall()) { - return Base::Run(); - } - } - - Event::Type ActivityType() const override - { - return mEventType; - } -}; - -template<class Impl> -template<class Instance, typename... Args> void -nsWindow::NativePtr<Impl>::Attach(Instance aInstance, nsWindow* aWindow, - Args&&... aArgs) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!mPtr && !mImpl); - - auto impl = mozilla::MakeUnique<Impl>( - this, aWindow, mozilla::Forward<Args>(aArgs)...); - mImpl = impl.get(); - - Impl::AttachNative(aInstance, mozilla::Move(impl)); -} - -template<class Impl> void -nsWindow::NativePtr<Impl>::Detach() -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mPtr && mImpl); - - mImpl->OnDetach(); - { - Locked implLock(*this); - mImpl = nullptr; - } - - typename WindowPtr<Impl>::Locked lock(*mPtr); - mPtr->mWindow = nullptr; - mPtr->mPtr = nullptr; - mPtr = nullptr; -} - -template<class Impl> -class nsWindow::NativePtr<Impl>::Locked final : private MutexAutoLock -{ - Impl* const mImpl; - -public: - Locked(NativePtr<Impl>& aPtr) - : MutexAutoLock(aPtr.mImplLock) - , mImpl(aPtr.mImpl) - {} - - operator Impl*() const { return mImpl; } - Impl* operator->() const { return mImpl; } -}; - -template<class Impl> -class nsWindow::WindowPtr final -{ - friend NativePtr<Impl>; - - NativePtr<Impl>* mPtr; - nsWindow* mWindow; - Mutex mWindowLock; - -public: - class Locked final : private MutexAutoLock - { - nsWindow* const mWindow; - - public: - Locked(WindowPtr<Impl>& aPtr) - : MutexAutoLock(aPtr.mWindowLock) - , mWindow(aPtr.mWindow) - {} - - operator nsWindow*() const { return mWindow; } - nsWindow* operator->() const { return mWindow; } - }; - - WindowPtr(NativePtr<Impl>* aPtr, nsWindow* aWindow) - : mPtr(aPtr) - , mWindow(aWindow) - , mWindowLock(NativePtr<Impl>::sName) - { - MOZ_ASSERT(NS_IsMainThread()); - mPtr->mPtr = this; - } - - ~WindowPtr() - { - MOZ_ASSERT(NS_IsMainThread()); - if (!mPtr) { - return; - } - mPtr->mPtr = nullptr; - mPtr->mImpl = nullptr; - } - - operator nsWindow*() const - { - MOZ_ASSERT(NS_IsMainThread()); - return mWindow; - } - - nsWindow* operator->() const { return operator nsWindow*(); } -}; - - -class nsWindow::GeckoViewSupport final - : public GeckoView::Window::Natives<GeckoViewSupport> - , public GeckoEditable::Natives<GeckoViewSupport> - , public SupportsWeakPtr<GeckoViewSupport> -{ - nsWindow& window; - -public: - typedef GeckoView::Window::Natives<GeckoViewSupport> Base; - typedef GeckoEditable::Natives<GeckoViewSupport> EditableBase; - - MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GeckoViewSupport); - - template<typename Functor> - static void OnNativeCall(Functor&& aCall) - { - if (aCall.IsTarget(&Open) && NS_IsMainThread()) { - // Gecko state probably just switched to PROFILE_READY, and the - // event loop is not running yet. Skip the event loop here so we - // can get a head start on opening our window. - return aCall(); - } - - const nsAppShell::Event::Type eventType = - aCall.IsTarget(&GeckoViewSupport::OnKeyEvent) || - aCall.IsTarget(&GeckoViewSupport::OnImeReplaceText) || - aCall.IsTarget(&GeckoViewSupport::OnImeUpdateComposition) ? - nsAppShell::Event::Type::kUIActivity : - nsAppShell::Event::Type::kGeneralActivity; - - nsAppShell::PostEvent(mozilla::MakeUnique<WindowEvent<Functor>>( - mozilla::Move(aCall), eventType)); - } - - GeckoViewSupport(nsWindow* aWindow, - const GeckoView::Window::LocalRef& aInstance, - GeckoView::Param aView) - : window(*aWindow) - , mEditable(GeckoEditable::New(aView)) - , mIMERanges(new TextRangeArray()) - , mIMEMaskEventsCount(1) // Mask IME events since there's no focus yet - , mIMEUpdatingContext(false) - , mIMESelectionChanged(false) - , mIMETextChangedDuringFlush(false) - , mIMEMonitorCursor(false) - { - Base::AttachNative(aInstance, this); - EditableBase::AttachNative(mEditable, this); - } - - ~GeckoViewSupport(); - - using Base::DisposeNative; - using EditableBase::DisposeNative; - - /** - * GeckoView methods - */ -private: - nsCOMPtr<nsPIDOMWindowOuter> mDOMWindow; - -public: - // Create and attach a window. - static void Open(const jni::Class::LocalRef& aCls, - GeckoView::Window::Param aWindow, - GeckoView::Param aView, jni::Object::Param aCompositor, - jni::String::Param aChromeURI, - int32_t screenId); - - // Close and destroy the nsWindow. - void Close(); - - // Reattach this nsWindow to a new GeckoView. - void Reattach(const GeckoView::Window::LocalRef& inst, - GeckoView::Param aView, jni::Object::Param aCompositor); - - void LoadUri(jni::String::Param aUri, int32_t aFlags); - - /** - * GeckoEditable methods - */ -private: - /* - Rules for managing IME between Gecko and Java: - - * Gecko controls the text content, and Java shadows the Gecko text - through text updates - * Gecko and Java maintain separate selections, and synchronize when - needed through selection updates and set-selection events - * Java controls the composition, and Gecko shadows the Java - composition through update composition events - */ - - struct IMETextChange final { - int32_t mStart, mOldEnd, mNewEnd; - - IMETextChange() : - mStart(-1), mOldEnd(-1), mNewEnd(-1) {} - - IMETextChange(const IMENotification& aIMENotification) - : mStart(aIMENotification.mTextChangeData.mStartOffset) - , mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset) - , mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset) - { - MOZ_ASSERT(aIMENotification.mMessage == NOTIFY_IME_OF_TEXT_CHANGE, - "IMETextChange initialized with wrong notification"); - MOZ_ASSERT(aIMENotification.mTextChangeData.IsValid(), - "The text change notification isn't initialized"); - MOZ_ASSERT(aIMENotification.mTextChangeData.IsInInt32Range(), - "The text change notification is out of range"); - } - - bool IsEmpty() const { return mStart < 0; } - }; - - // GeckoEditable instance used by this nsWindow; - java::GeckoEditable::GlobalRef mEditable; - AutoTArray<mozilla::UniquePtr<mozilla::WidgetEvent>, 8> mIMEKeyEvents; - AutoTArray<IMETextChange, 4> mIMETextChanges; - InputContext mInputContext; - RefPtr<mozilla::TextRangeArray> mIMERanges; - int32_t mIMEMaskEventsCount; // Mask events when > 0. - bool mIMEUpdatingContext; - bool mIMESelectionChanged; - bool mIMETextChangedDuringFlush; - bool mIMEMonitorCursor; - - void SendIMEDummyKeyEvents(); - void AddIMETextChange(const IMETextChange& aChange); - - enum FlushChangesFlag { - // Not retrying. - FLUSH_FLAG_NONE, - // Retrying due to IME text changes during flush. - FLUSH_FLAG_RETRY, - // Retrying due to IME sync exceptions during flush. - FLUSH_FLAG_RECOVER - }; - void PostFlushIMEChanges(); - void FlushIMEChanges(FlushChangesFlag aFlags = FLUSH_FLAG_NONE); - void FlushIMEText(FlushChangesFlag aFlags = FLUSH_FLAG_NONE); - void AsyncNotifyIME(int32_t aNotification); - void UpdateCompositionRects(); - -public: - bool NotifyIME(const IMENotification& aIMENotification); - void SetInputContext(const InputContext& aContext, - const InputContextAction& aAction); - InputContext GetInputContext(); - - // RAII helper class that automatically sends an event reply through - // OnImeSynchronize, as required by events like OnImeReplaceText. - class AutoIMESynchronize { - GeckoViewSupport* const mGVS; - public: - AutoIMESynchronize(GeckoViewSupport* gvs) : mGVS(gvs) {} - ~AutoIMESynchronize() { mGVS->OnImeSynchronize(); } - }; - - // Handle an Android KeyEvent. - void OnKeyEvent(int32_t aAction, int32_t aKeyCode, int32_t aScanCode, - int32_t aMetaState, int64_t aTime, int32_t aUnicodeChar, - int32_t aBaseUnicodeChar, int32_t aDomPrintableKeyValue, - int32_t aRepeatCount, int32_t aFlags, - bool aIsSynthesizedImeKey, jni::Object::Param originalEvent); - - // Synchronize Gecko thread with the InputConnection thread. - void OnImeSynchronize(); - - // Replace a range of text with new text. - void OnImeReplaceText(int32_t aStart, int32_t aEnd, - jni::String::Param aText); - - // Add styling for a range within the active composition. - void OnImeAddCompositionRange(int32_t aStart, int32_t aEnd, - int32_t aRangeType, int32_t aRangeStyle, int32_t aRangeLineStyle, - bool aRangeBoldLine, int32_t aRangeForeColor, - int32_t aRangeBackColor, int32_t aRangeLineColor); - - // Update styling for the active composition using previous-added ranges. - void OnImeUpdateComposition(int32_t aStart, int32_t aEnd); - - // Set cursor mode whether IME requests - void OnImeRequestCursorUpdates(int aRequestMode); -}; - -/** - * NativePanZoomController handles its native calls on the UI thread, so make - * it separate from GeckoViewSupport. - */ -class nsWindow::NPZCSupport final - : public NativePanZoomController::Natives<NPZCSupport> -{ - using LockedWindowPtr = WindowPtr<NPZCSupport>::Locked; - - WindowPtr<NPZCSupport> mWindow; - NativePanZoomController::GlobalRef mNPZC; - int mPreviousButtons; - -public: - typedef NativePanZoomController::Natives<NPZCSupport> Base; - - NPZCSupport(NativePtr<NPZCSupport>* aPtr, nsWindow* aWindow, - const NativePanZoomController::LocalRef& aNPZC) - : mWindow(aPtr, aWindow) - , mNPZC(aNPZC) - , mPreviousButtons(0) - {} - - ~NPZCSupport() - {} - - using Base::AttachNative; - using Base::DisposeNative; - - void OnDetach() - { - // There are several considerations when shutting down NPZC. 1) The - // Gecko thread may destroy NPZC at any time when nsWindow closes. 2) - // There may be pending events on the Gecko thread when NPZC is - // destroyed. 3) mWindow may not be available when the pending event - // runs. 4) The UI thread may destroy NPZC at any time when GeckoView - // is destroyed. 5) The UI thread may destroy NPZC at the same time as - // Gecko thread trying to destroy NPZC. 6) There may be pending calls - // on the UI thread when NPZC is destroyed. 7) mWindow may have been - // cleared on the Gecko thread when the pending call happens on the UI - // thread. - // - // 1) happens through OnDetach, which first notifies the UI - // thread through Destroy; Destroy then calls DisposeNative, which - // finally disposes the native instance back on the Gecko thread. Using - // Destroy to indirectly call DisposeNative here also solves 5), by - // making everything go through the UI thread, avoiding contention. - // - // 2) and 3) are solved by clearing mWindow, which signals to the - // pending event that we had shut down. In that case the event bails - // and does not touch mWindow. - // - // 4) happens through DisposeNative directly. OnDetach is not - // called. - // - // 6) is solved by keeping a destroyed flag in the Java NPZC instance, - // and only make a pending call if the destroyed flag is not set. - // - // 7) is solved by taking a lock whenever mWindow is modified on the - // Gecko thread or accessed on the UI thread. That way, we don't - // release mWindow until the UI thread is done using it, thus avoiding - // the race condition. - - typedef NativePanZoomController::GlobalRef NPZCRef; - auto callDestroy = [] (const NPZCRef& npzc) { - npzc->Destroy(); - }; - - NativePanZoomController::GlobalRef npzc = mNPZC; - AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableFunction( - static_cast<void(*)(const NPZCRef&)>(callDestroy), - mozilla::Move(npzc)), 0); - } - -public: - void AdjustScrollForSurfaceShift(float aX, float aY) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (controller) { - controller->AdjustScrollForSurfaceShift( - ScreenPoint(aX, aY)); - } - } - - void SetIsLongpressEnabled(bool aIsLongpressEnabled) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (controller) { - controller->SetLongTapEnabled(aIsLongpressEnabled); - } - } - - bool HandleScrollEvent(int64_t aTime, int32_t aMetaState, - float aX, float aY, - float aHScroll, float aVScroll) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (!controller) { - return false; - } - - ScreenPoint origin = ScreenPoint(aX, aY); - - ScrollWheelInput input(aTime, TimeStamp::Now(), GetModifiers(aMetaState), - ScrollWheelInput::SCROLLMODE_SMOOTH, - ScrollWheelInput::SCROLLDELTA_PIXEL, - origin, - aHScroll, aVScroll, - false); - - ScrollableLayerGuid guid; - uint64_t blockId; - nsEventStatus status = controller->ReceiveInputEvent(input, &guid, &blockId); - - if (status == nsEventStatus_eConsumeNoDefault) { - return true; - } - - NativePanZoomController::GlobalRef npzc = mNPZC; - nsAppShell::PostEvent([npzc, input, guid, blockId, status] { - MOZ_ASSERT(NS_IsMainThread()); - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - NPZCSupport* npzcSupport = GetNative( - NativePanZoomController::LocalRef(env, npzc)); - - if (!npzcSupport || !npzcSupport->mWindow) { - // We already shut down. - env->ExceptionClear(); - return; - } - - nsWindow* const window = npzcSupport->mWindow; - window->UserActivity(); - WidgetWheelEvent wheelEvent = input.ToWidgetWheelEvent(window); - window->ProcessUntransformedAPZEvent(&wheelEvent, guid, - blockId, status); - }); - - return true; - } - -private: - static MouseInput::ButtonType GetButtonType(int button) - { - MouseInput::ButtonType result = MouseInput::NONE; - - switch (button) { - case java::sdk::MotionEvent::BUTTON_PRIMARY: - result = MouseInput::LEFT_BUTTON; - break; - case java::sdk::MotionEvent::BUTTON_SECONDARY: - result = MouseInput::RIGHT_BUTTON; - break; - case java::sdk::MotionEvent::BUTTON_TERTIARY: - result = MouseInput::MIDDLE_BUTTON; - break; - default: - break; - } - - return result; - } - - static int16_t ConvertButtons(int buttons) { - int16_t result = 0; - - if (buttons & java::sdk::MotionEvent::BUTTON_PRIMARY) { - result |= WidgetMouseEventBase::eLeftButtonFlag; - } - if (buttons & java::sdk::MotionEvent::BUTTON_SECONDARY) { - result |= WidgetMouseEventBase::eRightButtonFlag; - } - if (buttons & java::sdk::MotionEvent::BUTTON_TERTIARY) { - result |= WidgetMouseEventBase::eMiddleButtonFlag; - } - if (buttons & java::sdk::MotionEvent::BUTTON_BACK) { - result |= WidgetMouseEventBase::e4thButtonFlag; - } - if (buttons & java::sdk::MotionEvent::BUTTON_FORWARD) { - result |= WidgetMouseEventBase::e5thButtonFlag; - } - - return result; - } - -public: - bool HandleMouseEvent(int32_t aAction, int64_t aTime, int32_t aMetaState, - float aX, float aY, int buttons) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (!controller) { - return false; - } - - MouseInput::MouseType mouseType = MouseInput::MOUSE_NONE; - MouseInput::ButtonType buttonType = MouseInput::NONE; - switch (aAction) { - case AndroidMotionEvent::ACTION_DOWN: - mouseType = MouseInput::MOUSE_DOWN; - buttonType = GetButtonType(buttons ^ mPreviousButtons); - mPreviousButtons = buttons; - break; - case AndroidMotionEvent::ACTION_UP: - mouseType = MouseInput::MOUSE_UP; - buttonType = GetButtonType(buttons ^ mPreviousButtons); - mPreviousButtons = buttons; - break; - case AndroidMotionEvent::ACTION_MOVE: - mouseType = MouseInput::MOUSE_MOVE; - break; - case AndroidMotionEvent::ACTION_HOVER_MOVE: - mouseType = MouseInput::MOUSE_MOVE; - break; - case AndroidMotionEvent::ACTION_HOVER_ENTER: - mouseType = MouseInput::MOUSE_WIDGET_ENTER; - break; - case AndroidMotionEvent::ACTION_HOVER_EXIT: - mouseType = MouseInput::MOUSE_WIDGET_EXIT; - break; - default: - break; - } - - if (mouseType == MouseInput::MOUSE_NONE) { - return false; - } - - ScreenPoint origin = ScreenPoint(aX, aY); - - MouseInput input(mouseType, buttonType, nsIDOMMouseEvent::MOZ_SOURCE_MOUSE, ConvertButtons(buttons), origin, aTime, TimeStamp(), GetModifiers(aMetaState)); - - ScrollableLayerGuid guid; - uint64_t blockId; - nsEventStatus status = controller->ReceiveInputEvent(input, &guid, &blockId); - - if (status == nsEventStatus_eConsumeNoDefault) { - return true; - } - - NativePanZoomController::GlobalRef npzc = mNPZC; - nsAppShell::PostEvent([npzc, input, guid, blockId, status] { - MOZ_ASSERT(NS_IsMainThread()); - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - NPZCSupport* npzcSupport = GetNative( - NativePanZoomController::LocalRef(env, npzc)); - - if (!npzcSupport || !npzcSupport->mWindow) { - // We already shut down. - env->ExceptionClear(); - return; - } - - nsWindow* const window = npzcSupport->mWindow; - window->UserActivity(); - WidgetMouseEvent mouseEvent = input.ToWidgetMouseEvent(window); - window->ProcessUntransformedAPZEvent(&mouseEvent, guid, - blockId, status); - }); - - return true; - } - - bool HandleMotionEvent(const NativePanZoomController::LocalRef& aInstance, - int32_t aAction, int32_t aActionIndex, - int64_t aTime, int32_t aMetaState, - jni::IntArray::Param aPointerId, - jni::FloatArray::Param aX, - jni::FloatArray::Param aY, - jni::FloatArray::Param aOrientation, - jni::FloatArray::Param aPressure, - jni::FloatArray::Param aToolMajor, - jni::FloatArray::Param aToolMinor) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (!controller) { - return false; - } - - nsTArray<int32_t> pointerId(aPointerId->GetElements()); - MultiTouchInput::MultiTouchType type; - size_t startIndex = 0; - size_t endIndex = pointerId.Length(); - - switch (aAction) { - case sdk::MotionEvent::ACTION_DOWN: - case sdk::MotionEvent::ACTION_POINTER_DOWN: - type = MultiTouchInput::MULTITOUCH_START; - break; - case sdk::MotionEvent::ACTION_MOVE: - type = MultiTouchInput::MULTITOUCH_MOVE; - break; - case sdk::MotionEvent::ACTION_UP: - case sdk::MotionEvent::ACTION_POINTER_UP: - // for pointer-up events we only want the data from - // the one pointer that went up - type = MultiTouchInput::MULTITOUCH_END; - startIndex = aActionIndex; - endIndex = aActionIndex + 1; - break; - case sdk::MotionEvent::ACTION_OUTSIDE: - case sdk::MotionEvent::ACTION_CANCEL: - type = MultiTouchInput::MULTITOUCH_CANCEL; - break; - default: - return false; - } - - MultiTouchInput input(type, aTime, TimeStamp(), 0); - input.modifiers = GetModifiers(aMetaState); - input.mTouches.SetCapacity(endIndex - startIndex); - - nsTArray<float> x(aX->GetElements()); - nsTArray<float> y(aY->GetElements()); - nsTArray<float> orientation(aOrientation->GetElements()); - nsTArray<float> pressure(aPressure->GetElements()); - nsTArray<float> toolMajor(aToolMajor->GetElements()); - nsTArray<float> toolMinor(aToolMinor->GetElements()); - - MOZ_ASSERT(pointerId.Length() == x.Length()); - MOZ_ASSERT(pointerId.Length() == y.Length()); - MOZ_ASSERT(pointerId.Length() == orientation.Length()); - MOZ_ASSERT(pointerId.Length() == pressure.Length()); - MOZ_ASSERT(pointerId.Length() == toolMajor.Length()); - MOZ_ASSERT(pointerId.Length() == toolMinor.Length()); - - for (size_t i = startIndex; i < endIndex; i++) { - - float orien = orientation[i] * 180.0f / M_PI; - // w3c touchevents spec does not allow orientations == 90 - // this shifts it to -90, which will be shifted to zero below - if (orien >= 90.0) { - orien -= 180.0f; - } - - nsIntPoint point = nsIntPoint(int32_t(floorf(x[i])), - int32_t(floorf(y[i]))); - - // w3c touchevent radii are given with an orientation between 0 and - // 90. The radii are found by removing the orientation and - // measuring the x and y radii of the resulting ellipse. For - // Android orientations >= 0 and < 90, use the y radius as the - // major radius, and x as the minor radius. However, for an - // orientation < 0, we have to shift the orientation by adding 90, - // and reverse which radius is major and minor. - gfx::Size radius; - if (orien < 0.0f) { - orien += 90.0f; - radius = gfx::Size(int32_t(toolMajor[i] / 2.0f), - int32_t(toolMinor[i] / 2.0f)); - } else { - radius = gfx::Size(int32_t(toolMinor[i] / 2.0f), - int32_t(toolMajor[i] / 2.0f)); - } - - input.mTouches.AppendElement(SingleTouchData( - pointerId[i], ScreenIntPoint::FromUnknownPoint(point), - ScreenSize::FromUnknownSize(radius), orien, pressure[i])); - } - - ScrollableLayerGuid guid; - uint64_t blockId; - nsEventStatus status = - controller->ReceiveInputEvent(input, &guid, &blockId); - - if (status == nsEventStatus_eConsumeNoDefault) { - return true; - } - - // Dispatch APZ input event on Gecko thread. - NativePanZoomController::GlobalRef npzc = mNPZC; - nsAppShell::PostEvent([npzc, input, guid, blockId, status] { - MOZ_ASSERT(NS_IsMainThread()); - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - NPZCSupport* npzcSupport = GetNative( - NativePanZoomController::LocalRef(env, npzc)); - - if (!npzcSupport || !npzcSupport->mWindow) { - // We already shut down. - env->ExceptionClear(); - return; - } - - nsWindow* const window = npzcSupport->mWindow; - window->UserActivity(); - WidgetTouchEvent touchEvent = input.ToWidgetTouchEvent(window); - window->ProcessUntransformedAPZEvent(&touchEvent, guid, - blockId, status); - window->DispatchHitTest(touchEvent); - }); - return true; - } - - void HandleMotionEventVelocity(int64_t aTime, float aSpeedY) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<IAPZCTreeManager> controller; - - if (LockedWindowPtr window{mWindow}) { - controller = window->mAPZC; - } - - if (controller) { - controller->ProcessTouchVelocity((uint32_t)aTime, aSpeedY); - } - } - - void UpdateOverscrollVelocity(const float x, const float y) - { - mNPZC->UpdateOverscrollVelocity(x, y); - } - - void UpdateOverscrollOffset(const float x, const float y) - { - mNPZC->UpdateOverscrollOffset(x, y); - } - - void SetScrollingRootContent(const bool isRootContent) - { - mNPZC->SetScrollingRootContent(isRootContent); - } - - void SetSelectionDragState(const bool aState) - { - mNPZC->OnSelectionDragState(aState); - } -}; - -template<> const char -nsWindow::NativePtr<nsWindow::NPZCSupport>::sName[] = "NPZCSupport"; - -/** - * Compositor has some unique requirements for its native calls, so make it - * separate from GeckoViewSupport. - */ -class nsWindow::LayerViewSupport final - : public LayerView::Compositor::Natives<LayerViewSupport> -{ - using LockedWindowPtr = WindowPtr<LayerViewSupport>::Locked; - - WindowPtr<LayerViewSupport> mWindow; - LayerView::Compositor::GlobalRef mCompositor; - GeckoLayerClient::GlobalRef mLayerClient; - Atomic<bool, ReleaseAcquire> mCompositorPaused; - jni::Object::GlobalRef mSurface; - - // In order to use Event::HasSameTypeAs in PostTo(), we cannot make - // LayerViewEvent a template because each template instantiation is - // a different type. So implement LayerViewEvent as a ProxyEvent. - class LayerViewEvent final : public nsAppShell::ProxyEvent - { - using Event = nsAppShell::Event; - - public: - static UniquePtr<Event> MakeEvent(UniquePtr<Event>&& event) - { - return MakeUnique<LayerViewEvent>(mozilla::Move(event)); - } - - LayerViewEvent(UniquePtr<Event>&& event) - : nsAppShell::ProxyEvent(mozilla::Move(event)) - {} - - void PostTo(LinkedList<Event>& queue) override - { - // Give priority to compositor events, but keep in order with - // existing compositor events. - nsAppShell::Event* event = queue.getFirst(); - while (event && event->HasSameTypeAs(this)) { - event = event->getNext(); - } - if (event) { - event->setPrevious(this); - } else { - queue.insertBack(this); - } - } - }; - -public: - typedef LayerView::Compositor::Natives<LayerViewSupport> Base; - - template<class Functor> - static void OnNativeCall(Functor&& aCall) - { - if (aCall.IsTarget(&LayerViewSupport::CreateCompositor)) { - // This call is blocking. - nsAppShell::SyncRunEvent(nsAppShell::LambdaEvent<Functor>( - mozilla::Move(aCall)), &LayerViewEvent::MakeEvent); - return; - } - } - - static LayerViewSupport* - FromNative(const LayerView::Compositor::LocalRef& instance) - { - return GetNative(instance); - } - - LayerViewSupport(NativePtr<LayerViewSupport>* aPtr, nsWindow* aWindow, - const LayerView::Compositor::LocalRef& aInstance) - : mWindow(aPtr, aWindow) - , mCompositor(aInstance) - , mCompositorPaused(true) - {} - - ~LayerViewSupport() - {} - - using Base::AttachNative; - using Base::DisposeNative; - - void OnDetach() - { - mCompositor->Destroy(); - } - - const GeckoLayerClient::Ref& GetLayerClient() const - { - return mLayerClient; - } - - bool CompositorPaused() const - { - return mCompositorPaused; - } - - jni::Object::Param GetSurface() - { - return mSurface; - } - -private: - void OnResumedCompositor() - { - MOZ_ASSERT(NS_IsMainThread()); - - // When we receive this, the compositor has already been told to - // resume. (It turns out that waiting till we reach here to tell - // the compositor to resume takes too long, resulting in a black - // flash.) This means it's now safe for layer updates to occur. - // Since we might have prevented one or more draw events from - // occurring while the compositor was paused, we need to schedule - // a draw event now. - if (!mCompositorPaused) { - mWindow->RedrawAll(); - } - } - - /** - * Compositor methods - */ -public: - void AttachToJava(jni::Object::Param aClient, jni::Object::Param aNPZC) - { - MOZ_ASSERT(NS_IsMainThread()); - if (!mWindow) { - return; // Already shut down. - } - - const auto& layerClient = GeckoLayerClient::Ref::From(aClient); - - // If resetting is true, Android destroyed our GeckoApp activity and we - // had to recreate it, but all the Gecko-side things were not - // destroyed. We therefore need to link up the new java objects to - // Gecko, and that's what we do here. - const bool resetting = !!mLayerClient; - mLayerClient = layerClient; - - MOZ_ASSERT(aNPZC); - auto npzc = NativePanZoomController::LocalRef( - jni::GetGeckoThreadEnv(), - NativePanZoomController::Ref::From(aNPZC)); - mWindow->mNPZCSupport.Attach(npzc, mWindow, npzc); - - layerClient->OnGeckoReady(); - - if (resetting) { - // Since we are re-linking the new java objects to Gecko, we need - // to get the viewport from the compositor (since the Java copy was - // thrown away) and we do that by setting the first-paint flag. - if (RefPtr<CompositorBridgeParent> bridge = mWindow->GetCompositorBridgeParent()) { - bridge->ForceIsFirstPaint(); - } - } - } - - void OnSizeChanged(int32_t aWindowWidth, int32_t aWindowHeight, - int32_t aScreenWidth, int32_t aScreenHeight) - { - MOZ_ASSERT(NS_IsMainThread()); - if (!mWindow) { - return; // Already shut down. - } - - if (aWindowWidth != mWindow->mBounds.width || - aWindowHeight != mWindow->mBounds.height) { - - mWindow->Resize(aWindowWidth, aWindowHeight, /* repaint */ false); - } - } - - void CreateCompositor(int32_t aWidth, int32_t aHeight, - jni::Object::Param aSurface) - { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mWindow); - - mSurface = aSurface; - mWindow->CreateLayerManager(aWidth, aHeight); - - mCompositorPaused = false; - OnResumedCompositor(); - } - - void SyncPauseCompositor() - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<CompositorBridgeParent> bridge; - - if (LockedWindowPtr window{mWindow}) { - bridge = window->GetCompositorBridgeParent(); - } - - if (bridge) { - mCompositorPaused = true; - bridge->SchedulePauseOnCompositorThread(); - } - } - - void SyncResumeCompositor() - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<CompositorBridgeParent> bridge; - - if (LockedWindowPtr window{mWindow}) { - bridge = window->GetCompositorBridgeParent(); - } - - if (bridge && bridge->ScheduleResumeOnCompositorThread()) { - mCompositorPaused = false; - } - } - - void SyncResumeResizeCompositor(const LayerView::Compositor::LocalRef& aObj, - int32_t aWidth, int32_t aHeight, - jni::Object::Param aSurface) - { - MOZ_ASSERT(AndroidBridge::IsJavaUiThread()); - - RefPtr<CompositorBridgeParent> bridge; - - if (LockedWindowPtr window{mWindow}) { - bridge = window->GetCompositorBridgeParent(); - } - - mSurface = aSurface; - - if (!bridge || !bridge->ScheduleResumeOnCompositorThread(aWidth, - aHeight)) { - return; - } - - mCompositorPaused = false; - - class OnResumedEvent : public nsAppShell::Event - { - LayerView::Compositor::GlobalRef mCompositor; - - public: - OnResumedEvent(LayerView::Compositor::GlobalRef&& aCompositor) - : mCompositor(mozilla::Move(aCompositor)) - {} - - void Run() override - { - MOZ_ASSERT(NS_IsMainThread()); - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - LayerViewSupport* const lvs = GetNative( - LayerView::Compositor::LocalRef(env, mCompositor)); - MOZ_CATCH_JNI_EXCEPTION(env); - - lvs->OnResumedCompositor(); - } - }; - - nsAppShell::PostEvent(MakeUnique<LayerViewEvent>( - MakeUnique<OnResumedEvent>(aObj))); - } - - void SyncInvalidateAndScheduleComposite() - { - RefPtr<CompositorBridgeParent> bridge; - - if (LockedWindowPtr window{mWindow}) { - bridge = window->GetCompositorBridgeParent(); - } - - if (bridge) { - bridge->InvalidateOnCompositorThread(); - bridge->ScheduleRenderOnCompositorThread(); - } - } -}; - -template<> const char -nsWindow::NativePtr<nsWindow::LayerViewSupport>::sName[] = "LayerViewSupport"; - -/* PresentationMediaPlayerManager native calls access inner nsWindow functionality so PMPMSupport is a child class of nsWindow */ -class nsWindow::PMPMSupport final - : public PresentationMediaPlayerManager::Natives<PMPMSupport> -{ - PMPMSupport() = delete; - - static LayerViewSupport* GetLayerViewSupport(jni::Object::Param aView) - { - const auto& layerView = LayerView::Ref::From(aView); - - LayerView::Compositor::LocalRef compositor = layerView->GetCompositor(); - if (!layerView->CompositorCreated() || !compositor) { - return nullptr; - } - - LayerViewSupport* const lvs = LayerViewSupport::FromNative(compositor); - if (!lvs) { - // There is a pending exception whenever FromNative returns nullptr. - compositor.Env()->ExceptionClear(); - } - return lvs; - } - -public: - static ANativeWindow* sWindow; - static EGLSurface sSurface; - - static void InvalidateAndScheduleComposite(jni::Object::Param aView) - { - LayerViewSupport* const lvs = GetLayerViewSupport(aView); - if (lvs) { - lvs->SyncInvalidateAndScheduleComposite(); - } - } - - static void AddPresentationSurface(const jni::Class::LocalRef& aCls, - jni::Object::Param aView, - jni::Object::Param aSurface) - { - RemovePresentationSurface(); - - LayerViewSupport* const lvs = GetLayerViewSupport(aView); - if (!lvs) { - return; - } - - ANativeWindow* const window = ANativeWindow_fromSurface( - aCls.Env(), aSurface.Get()); - if (!window) { - return; - } - - sWindow = window; - - const bool wasAlreadyPaused = lvs->CompositorPaused(); - if (!wasAlreadyPaused) { - lvs->SyncPauseCompositor(); - } - - if (sSurface) { - // Destroy the EGL surface! The compositor is paused so it should - // be okay to destroy the surface here. - mozilla::gl::GLContextProvider::DestroyEGLSurface(sSurface); - sSurface = nullptr; - } - - if (!wasAlreadyPaused) { - lvs->SyncResumeCompositor(); - } - - lvs->SyncInvalidateAndScheduleComposite(); - } - - static void RemovePresentationSurface() - { - if (sWindow) { - ANativeWindow_release(sWindow); - sWindow = nullptr; - } - } -}; - -ANativeWindow* nsWindow::PMPMSupport::sWindow; -EGLSurface nsWindow::PMPMSupport::sSurface; - - -nsWindow::GeckoViewSupport::~GeckoViewSupport() -{ - // Disassociate our GeckoEditable instance with our native object. - // OnDestroy will call disposeNative after any pending native calls have - // been made. - MOZ_ASSERT(mEditable); - mEditable->OnViewChange(nullptr); - - if (window.mNPZCSupport) { - window.mNPZCSupport.Detach(); - } - - if (window.mLayerViewSupport) { - window.mLayerViewSupport.Detach(); - } -} - -/* static */ void -nsWindow::GeckoViewSupport::Open(const jni::Class::LocalRef& aCls, - GeckoView::Window::Param aWindow, - GeckoView::Param aView, - jni::Object::Param aCompositor, - jni::String::Param aChromeURI, - int32_t aScreenId) -{ - MOZ_ASSERT(NS_IsMainThread()); - - PROFILER_LABEL("nsWindow", "GeckoViewSupport::Open", - js::ProfileEntry::Category::OTHER); - - nsCOMPtr<nsIWindowWatcher> ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID); - MOZ_RELEASE_ASSERT(ww); - - nsAdoptingCString url; - if (aChromeURI) { - url = aChromeURI->ToCString(); - } else { - url = Preferences::GetCString("toolkit.defaultChromeURI"); - if (!url) { - url = NS_LITERAL_CSTRING("chrome://browser/content/browser.xul"); - } - } - - nsCOMPtr<mozIDOMWindowProxy> domWindow; - ww->OpenWindow(nullptr, url, nullptr, "chrome,dialog=0,resizable,scrollbars=yes", - nullptr, getter_AddRefs(domWindow)); - MOZ_RELEASE_ASSERT(domWindow); - - nsCOMPtr<nsPIDOMWindowOuter> pdomWindow = - nsPIDOMWindowOuter::From(domWindow); - nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(pdomWindow); - MOZ_ASSERT(widget); - - const auto window = static_cast<nsWindow*>(widget.get()); - window->SetScreenId(aScreenId); - - // Attach a new GeckoView support object to the new window. - window->mGeckoViewSupport = mozilla::MakeUnique<GeckoViewSupport>( - window, GeckoView::Window::LocalRef(aCls.Env(), aWindow), aView); - - window->mGeckoViewSupport->mDOMWindow = pdomWindow; - - // Attach the Compositor to the new window. - auto compositor = LayerView::Compositor::LocalRef( - aCls.Env(), LayerView::Compositor::Ref::From(aCompositor)); - window->mLayerViewSupport.Attach(compositor, window, compositor); - - if (window->mWidgetListener) { - nsCOMPtr<nsIXULWindow> xulWindow( - window->mWidgetListener->GetXULWindow()); - if (xulWindow) { - // Our window is not intrinsically sized, so tell nsXULWindow to - // not set a size for us. - xulWindow->SetIntrinsicallySized(false); - } - } -} - -void -nsWindow::GeckoViewSupport::Close() -{ - if (!mDOMWindow) { - return; - } - - mDOMWindow->ForceClose(); - mDOMWindow = nullptr; -} - -void -nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst, - GeckoView::Param aView, - jni::Object::Param aCompositor) -{ - // Associate our previous GeckoEditable with the new GeckoView. - mEditable->OnViewChange(aView); - - // mNPZCSupport might have already been detached through the Java side calling - // NativePanZoomController.destroy(). - if (window.mNPZCSupport) { - window.mNPZCSupport.Detach(); - } - - MOZ_ASSERT(window.mLayerViewSupport); - window.mLayerViewSupport.Detach(); - - auto compositor = LayerView::Compositor::LocalRef( - inst.Env(), LayerView::Compositor::Ref::From(aCompositor)); - window.mLayerViewSupport.Attach(compositor, &window, compositor); - compositor->Reattach(); -} - -void -nsWindow::GeckoViewSupport::LoadUri(jni::String::Param aUri, int32_t aFlags) -{ - if (!mDOMWindow) { - return; - } - - nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUri->ToCString()); - if (NS_WARN_IF(!uri)) { - return; - } - - nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(mDOMWindow); - nsCOMPtr<nsIBrowserDOMWindow> browserWin; - - if (NS_WARN_IF(!chromeWin) || NS_WARN_IF(NS_FAILED( - chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserWin))))) { - return; - } - - const int flags = aFlags == GeckoView::LOAD_NEW_TAB ? - nsIBrowserDOMWindow::OPEN_NEWTAB : - aFlags == GeckoView::LOAD_SWITCH_TAB ? - nsIBrowserDOMWindow::OPEN_SWITCHTAB : - nsIBrowserDOMWindow::OPEN_CURRENTWINDOW; - nsCOMPtr<mozIDOMWindowProxy> newWin; - - if (NS_FAILED(browserWin->OpenURI( - uri, nullptr, flags, nsIBrowserDOMWindow::OPEN_EXTERNAL, - getter_AddRefs(newWin)))) { - NS_WARNING("Failed to open URI"); - } -} - -void -nsWindow::InitNatives() -{ - nsWindow::GeckoViewSupport::Base::Init(); - nsWindow::GeckoViewSupport::EditableBase::Init(); - nsWindow::LayerViewSupport::Init(); - nsWindow::NPZCSupport::Init(); - if (jni::IsFennec()) { - nsWindow::PMPMSupport::Init(); - } -} - -nsWindow* -nsWindow::TopWindow() -{ - if (!gTopLevelWindows.IsEmpty()) - return gTopLevelWindows[0]; - return nullptr; -} - -void -nsWindow::LogWindow(nsWindow *win, int index, int indent) -{ -#if defined(DEBUG) || defined(FORCE_ALOG) - char spaces[] = " "; - spaces[indent < 20 ? indent : 20] = 0; - ALOG("%s [% 2d] 0x%08x [parent 0x%08x] [% 3d,% 3dx% 3d,% 3d] vis %d type %d", - spaces, index, (intptr_t)win, (intptr_t)win->mParent, - win->mBounds.x, win->mBounds.y, - win->mBounds.width, win->mBounds.height, - win->mIsVisible, win->mWindowType); -#endif -} - -void -nsWindow::DumpWindows() -{ - DumpWindows(gTopLevelWindows); -} - -void -nsWindow::DumpWindows(const nsTArray<nsWindow*>& wins, int indent) -{ - for (uint32_t i = 0; i < wins.Length(); ++i) { - nsWindow *w = wins[i]; - LogWindow(w, i, indent); - DumpWindows(w->mChildren, indent+1); - } -} - -nsWindow::nsWindow() : - mScreenId(0), // Use 0 (primary screen) as the default value. - mIsVisible(false), - mParent(nullptr), - mAwaitingFullScreen(false), - mIsFullScreen(false) -{ -} - -nsWindow::~nsWindow() -{ - gTopLevelWindows.RemoveElement(this); - ALOG("nsWindow %p destructor", (void*)this); -} - -bool -nsWindow::IsTopLevel() -{ - return mWindowType == eWindowType_toplevel || - mWindowType == eWindowType_dialog || - mWindowType == eWindowType_invisible; -} - -nsresult -nsWindow::Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const LayoutDeviceIntRect& aRect, - nsWidgetInitData* aInitData) -{ - ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, - aRect.x, aRect.y, aRect.width, aRect.height); - - nsWindow *parent = (nsWindow*) aParent; - if (aNativeParent) { - if (parent) { - ALOG("Ignoring native parent on Android window [%p], " - "since parent was specified (%p %p)", (void*)this, - (void*)aNativeParent, (void*)aParent); - } else { - parent = (nsWindow*) aNativeParent; - } - } - - mBounds = aRect; - - BaseCreate(nullptr, aInitData); - - NS_ASSERTION(IsTopLevel() || parent, - "non-top-level window doesn't have a parent!"); - - if (IsTopLevel()) { - gTopLevelWindows.AppendElement(this); - - } else if (parent) { - parent->mChildren.AppendElement(this); - mParent = parent; - } - -#ifdef DEBUG_ANDROID_WIDGET - DumpWindows(); -#endif - - return NS_OK; -} - -void -nsWindow::Destroy() -{ - nsBaseWidget::mOnDestroyCalled = true; - - if (mGeckoViewSupport) { - // Disassociate our native object with GeckoView. - mGeckoViewSupport = nullptr; - } - - // Stuff below may release the last ref to this - nsCOMPtr<nsIWidget> kungFuDeathGrip(this); - - while (mChildren.Length()) { - // why do we still have children? - ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[0]); - mChildren[0]->SetParent(nullptr); - } - - nsBaseWidget::Destroy(); - - if (IsTopLevel()) - gTopLevelWindows.RemoveElement(this); - - SetParent(nullptr); - - nsBaseWidget::OnDestroy(); - -#ifdef DEBUG_ANDROID_WIDGET - DumpWindows(); -#endif -} - -NS_IMETHODIMP -nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>& config) -{ - for (uint32_t i = 0; i < config.Length(); ++i) { - nsWindow *childWin = (nsWindow*) config[i].mChild.get(); - childWin->Resize(config[i].mBounds.x, - config[i].mBounds.y, - config[i].mBounds.width, - config[i].mBounds.height, - false); - } - - return NS_OK; -} - -void -nsWindow::RedrawAll() -{ - if (mAttachedWidgetListener) { - mAttachedWidgetListener->RequestRepaint(); - } else if (mWidgetListener) { - mWidgetListener->RequestRepaint(); - } -} - -NS_IMETHODIMP -nsWindow::SetParent(nsIWidget *aNewParent) -{ - if ((nsIWidget*)mParent == aNewParent) - return NS_OK; - - // If we had a parent before, remove ourselves from its list of - // children. - if (mParent) - mParent->mChildren.RemoveElement(this); - - mParent = (nsWindow*)aNewParent; - - if (mParent) - mParent->mChildren.AppendElement(this); - - // if we are now in the toplevel window's hierarchy, schedule a redraw - if (FindTopLevel() == nsWindow::TopWindow()) - RedrawAll(); - - return NS_OK; -} - -nsIWidget* -nsWindow::GetParent() -{ - return mParent; -} - -float -nsWindow::GetDPI() -{ - if (AndroidBridge::Bridge()) - return AndroidBridge::Bridge()->GetDPI(); - return 160.0f; -} - -double -nsWindow::GetDefaultScaleInternal() -{ - - nsCOMPtr<nsIScreen> screen = GetWidgetScreen(); - MOZ_ASSERT(screen); - RefPtr<nsScreenAndroid> screenAndroid = (nsScreenAndroid*) screen.get(); - return screenAndroid->GetDensity(); -} - -NS_IMETHODIMP -nsWindow::Show(bool aState) -{ - ALOG("nsWindow[%p]::Show %d", (void*)this, aState); - - if (mWindowType == eWindowType_invisible) { - ALOG("trying to show invisible window! ignoring.."); - return NS_ERROR_FAILURE; - } - - if (aState == mIsVisible) - return NS_OK; - - mIsVisible = aState; - - if (IsTopLevel()) { - // XXX should we bring this to the front when it's shown, - // if it's a toplevel widget? - - // XXX we should synthesize a eMouseExitFromWidget (for old top - // window)/eMouseEnterIntoWidget (for new top window) since we need - // to pretend that the top window always has focus. Not sure - // if Show() is the right place to do this, though. - - if (aState) { - // It just became visible, so bring it to the front. - BringToFront(); - - } else if (nsWindow::TopWindow() == this) { - // find the next visible window to show - unsigned int i; - for (i = 1; i < gTopLevelWindows.Length(); i++) { - nsWindow *win = gTopLevelWindows[i]; - if (!win->mIsVisible) - continue; - - win->BringToFront(); - break; - } - } - } else if (FindTopLevel() == nsWindow::TopWindow()) { - RedrawAll(); - } - -#ifdef DEBUG_ANDROID_WIDGET - DumpWindows(); -#endif - - return NS_OK; -} - -bool -nsWindow::IsVisible() const -{ - return mIsVisible; -} - -void -nsWindow::ConstrainPosition(bool aAllowSlop, - int32_t *aX, - int32_t *aY) -{ - ALOG("nsWindow[%p]::ConstrainPosition %d [%d %d]", (void*)this, aAllowSlop, *aX, *aY); - - // constrain toplevel windows; children we don't care about - if (IsTopLevel()) { - *aX = 0; - *aY = 0; - } -} - -NS_IMETHODIMP -nsWindow::Move(double aX, - double aY) -{ - if (IsTopLevel()) - return NS_OK; - - return Resize(aX, - aY, - mBounds.width, - mBounds.height, - true); -} - -NS_IMETHODIMP -nsWindow::Resize(double aWidth, - double aHeight, - bool aRepaint) -{ - return Resize(mBounds.x, - mBounds.y, - aWidth, - aHeight, - aRepaint); -} - -NS_IMETHODIMP -nsWindow::Resize(double aX, - double aY, - double aWidth, - double aHeight, - bool aRepaint) -{ - ALOG("nsWindow[%p]::Resize [%f %f %f %f] (repaint %d)", (void*)this, aX, aY, aWidth, aHeight, aRepaint); - - bool needSizeDispatch = aWidth != mBounds.width || aHeight != mBounds.height; - - mBounds.x = NSToIntRound(aX); - mBounds.y = NSToIntRound(aY); - mBounds.width = NSToIntRound(aWidth); - mBounds.height = NSToIntRound(aHeight); - - if (needSizeDispatch) { - OnSizeChanged(gfx::IntSize::Truncate(aWidth, aHeight)); - } - - // Should we skip honoring aRepaint here? - if (aRepaint && FindTopLevel() == nsWindow::TopWindow()) - RedrawAll(); - - nsIWidgetListener* listener = GetWidgetListener(); - if (mAwaitingFullScreen && listener) { - listener->FullscreenChanged(mIsFullScreen); - mAwaitingFullScreen = false; - } - - return NS_OK; -} - -void -nsWindow::SetZIndex(int32_t aZIndex) -{ - ALOG("nsWindow[%p]::SetZIndex %d ignored", (void*)this, aZIndex); -} - -void -nsWindow::SetSizeMode(nsSizeMode aMode) -{ - switch (aMode) { - case nsSizeMode_Minimized: - GeckoAppShell::MoveTaskToBack(); - break; - case nsSizeMode_Fullscreen: - MakeFullScreen(true); - break; - default: - break; - } -} - -NS_IMETHODIMP -nsWindow::Enable(bool aState) -{ - ALOG("nsWindow[%p]::Enable %d ignored", (void*)this, aState); - return NS_OK; -} - -bool -nsWindow::IsEnabled() const -{ - return true; -} - -NS_IMETHODIMP -nsWindow::Invalidate(const LayoutDeviceIntRect& aRect) -{ - return NS_OK; -} - -nsWindow* -nsWindow::FindTopLevel() -{ - nsWindow *toplevel = this; - while (toplevel) { - if (toplevel->IsTopLevel()) - return toplevel; - - toplevel = toplevel->mParent; - } - - ALOG("nsWindow::FindTopLevel(): couldn't find a toplevel or dialog window in this [%p] widget's hierarchy!", (void*)this); - return this; -} - -NS_IMETHODIMP -nsWindow::SetFocus(bool aRaise) -{ - nsWindow *top = FindTopLevel(); - top->BringToFront(); - - return NS_OK; -} - -void -nsWindow::BringToFront() -{ - // If the window to be raised is the same as the currently raised one, - // do nothing. We need to check the focus manager as well, as the first - // window that is created will be first in the window list but won't yet - // be focused. - nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID); - nsCOMPtr<mozIDOMWindowProxy> existingTopWindow; - fm->GetActiveWindow(getter_AddRefs(existingTopWindow)); - if (existingTopWindow && FindTopLevel() == nsWindow::TopWindow()) - return; - - if (!IsTopLevel()) { - FindTopLevel()->BringToFront(); - return; - } - - RefPtr<nsWindow> kungFuDeathGrip(this); - - nsWindow *oldTop = nullptr; - if (!gTopLevelWindows.IsEmpty()) { - oldTop = gTopLevelWindows[0]; - } - - gTopLevelWindows.RemoveElement(this); - gTopLevelWindows.InsertElementAt(0, this); - - if (oldTop) { - nsIWidgetListener* listener = oldTop->GetWidgetListener(); - if (listener) { - listener->WindowDeactivated(); - } - } - - if (mWidgetListener) { - mWidgetListener->WindowActivated(); - } - - RedrawAll(); -} - -LayoutDeviceIntRect -nsWindow::GetScreenBounds() -{ - return LayoutDeviceIntRect(WidgetToScreenOffset(), mBounds.Size()); -} - -LayoutDeviceIntPoint -nsWindow::WidgetToScreenOffset() -{ - LayoutDeviceIntPoint p(0, 0); - nsWindow *w = this; - - while (w && !w->IsTopLevel()) { - p.x += w->mBounds.x; - p.y += w->mBounds.y; - - w = w->mParent; - } - - return p; -} - -NS_IMETHODIMP -nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) -{ - aStatus = DispatchEvent(aEvent); - return NS_OK; -} - -nsEventStatus -nsWindow::DispatchEvent(WidgetGUIEvent* aEvent) -{ - if (mAttachedWidgetListener) { - return mAttachedWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } else if (mWidgetListener) { - return mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } - return nsEventStatus_eIgnore; -} - -nsresult -nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*) -{ - mIsFullScreen = aFullScreen; - mAwaitingFullScreen = true; - GeckoAppShell::SetFullScreen(aFullScreen); - return NS_OK; -} - -mozilla::layers::LayerManager* -nsWindow::GetLayerManager(PLayerTransactionChild*, LayersBackend, LayerManagerPersistence) -{ - if (mLayerManager) { - return mLayerManager; - } - return nullptr; -} - -void -nsWindow::CreateLayerManager(int aCompositorWidth, int aCompositorHeight) -{ - if (mLayerManager) { - return; - } - - nsWindow *topLevelWindow = FindTopLevel(); - if (!topLevelWindow || topLevelWindow->mWindowType == eWindowType_invisible) { - // don't create a layer manager for an invisible top-level window - return; - } - - // Ensure that gfxPlatform is initialized first. - gfxPlatform::GetPlatform(); - - if (ShouldUseOffMainThreadCompositing()) { - CreateCompositor(aCompositorWidth, aCompositorHeight); - if (mLayerManager) { - return; - } - - // If we get here, then off main thread compositing failed to initialize. - sFailedToCreateGLContext = true; - } - - if (!ComputeShouldAccelerate() || sFailedToCreateGLContext) { - printf_stderr(" -- creating basic, not accelerated\n"); - mLayerManager = CreateBasicLayerManager(); - } -} - -void -nsWindow::OnSizeChanged(const gfx::IntSize& aSize) -{ - ALOG("nsWindow: %p OnSizeChanged [%d %d]", (void*)this, aSize.width, aSize.height); - - mBounds.width = aSize.width; - mBounds.height = aSize.height; - - if (mWidgetListener) { - mWidgetListener->WindowResized(this, aSize.width, aSize.height); - } - - if (mAttachedWidgetListener) { - mAttachedWidgetListener->WindowResized(this, aSize.width, aSize.height); - } -} - -void -nsWindow::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint) -{ - if (aPoint) { - event.mRefPoint = *aPoint; - } else { - event.mRefPoint = LayoutDeviceIntPoint(0, 0); - } - - event.mTime = PR_Now() / 1000; -} - -void -nsWindow::UpdateOverscrollVelocity(const float aX, const float aY) -{ - if (NativePtr<NPZCSupport>::Locked npzcs{mNPZCSupport}) { - npzcs->UpdateOverscrollVelocity(aX, aY); - } -} - -void -nsWindow::UpdateOverscrollOffset(const float aX, const float aY) -{ - if (NativePtr<NPZCSupport>::Locked npzcs{mNPZCSupport}) { - npzcs->UpdateOverscrollOffset(aX, aY); - } -} - -void -nsWindow::SetScrollingRootContent(const bool isRootContent) -{ - // On Android, the Controller thread and UI thread are the same. - MOZ_ASSERT(APZThreadUtils::IsControllerThread(), "nsWindow::SetScrollingRootContent must be called from the controller thread"); - - if (NativePtr<NPZCSupport>::Locked npzcs{mNPZCSupport}) { - npzcs->SetScrollingRootContent(isRootContent); - } -} - -void -nsWindow::SetSelectionDragState(bool aState) -{ - if (NativePtr<NPZCSupport>::Locked npzcs{mNPZCSupport}) { - npzcs->SetSelectionDragState(aState); - } -} - -void * -nsWindow::GetNativeData(uint32_t aDataType) -{ - switch (aDataType) { - // used by GLContextProviderEGL, nullptr is EGL_DEFAULT_DISPLAY - case NS_NATIVE_DISPLAY: - return nullptr; - - case NS_NATIVE_WIDGET: - return (void *) this; - - case NS_RAW_NATIVE_IME_CONTEXT: { - void* pseudoIMEContext = GetPseudoIMEContext(); - if (pseudoIMEContext) { - return pseudoIMEContext; - } - // We assume that there is only one context per process on Android - return NS_ONLY_ONE_NATIVE_IME_CONTEXT; - } - - case NS_JAVA_SURFACE: - if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) { - return lvs->GetSurface().Get(); - } - return nullptr; - - case NS_PRESENTATION_WINDOW: - return PMPMSupport::sWindow; - - case NS_PRESENTATION_SURFACE: - return PMPMSupport::sSurface; - } - - return nullptr; -} - -void -nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal) -{ - switch (aDataType) { - case NS_PRESENTATION_SURFACE: - PMPMSupport::sSurface = reinterpret_cast<EGLSurface>(aVal); - break; - } -} - -void -nsWindow::DispatchHitTest(const WidgetTouchEvent& aEvent) -{ - if (aEvent.mMessage == eTouchStart && aEvent.mTouches.Length() == 1) { - // Since touch events don't get retargeted by PositionedEventTargeting.cpp - // code on Fennec, we dispatch a dummy mouse event that *does* get - // retargeted. The Fennec browser.js code can use this to activate the - // highlight element in case the this touchstart is the start of a tap. - WidgetMouseEvent hittest(true, eMouseHitTest, this, - WidgetMouseEvent::eReal); - hittest.mRefPoint = aEvent.mTouches[0]->mRefPoint; - hittest.mIgnoreRootScrollFrame = true; - hittest.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; - nsEventStatus status; - DispatchEvent(&hittest, status); - - if (mAPZEventState && hittest.hitCluster) { - mAPZEventState->ProcessClusterHit(); - } - } -} - -static unsigned int ConvertAndroidKeyCodeToDOMKeyCode(int androidKeyCode) -{ - // Special-case alphanumeric keycodes because they are most common. - if (androidKeyCode >= AKEYCODE_A && - androidKeyCode <= AKEYCODE_Z) { - return androidKeyCode - AKEYCODE_A + NS_VK_A; - } - - if (androidKeyCode >= AKEYCODE_0 && - androidKeyCode <= AKEYCODE_9) { - return androidKeyCode - AKEYCODE_0 + NS_VK_0; - } - - switch (androidKeyCode) { - // KEYCODE_UNKNOWN (0) ... KEYCODE_HOME (3) - case AKEYCODE_BACK: return NS_VK_ESCAPE; - // KEYCODE_CALL (5) ... KEYCODE_POUND (18) - case AKEYCODE_DPAD_UP: return NS_VK_UP; - case AKEYCODE_DPAD_DOWN: return NS_VK_DOWN; - case AKEYCODE_DPAD_LEFT: return NS_VK_LEFT; - case AKEYCODE_DPAD_RIGHT: return NS_VK_RIGHT; - case AKEYCODE_DPAD_CENTER: return NS_VK_RETURN; - case AKEYCODE_VOLUME_UP: return NS_VK_VOLUME_UP; - case AKEYCODE_VOLUME_DOWN: return NS_VK_VOLUME_DOWN; - // KEYCODE_VOLUME_POWER (26) ... KEYCODE_Z (54) - case AKEYCODE_COMMA: return NS_VK_COMMA; - case AKEYCODE_PERIOD: return NS_VK_PERIOD; - case AKEYCODE_ALT_LEFT: return NS_VK_ALT; - case AKEYCODE_ALT_RIGHT: return NS_VK_ALT; - case AKEYCODE_SHIFT_LEFT: return NS_VK_SHIFT; - case AKEYCODE_SHIFT_RIGHT: return NS_VK_SHIFT; - case AKEYCODE_TAB: return NS_VK_TAB; - case AKEYCODE_SPACE: return NS_VK_SPACE; - // KEYCODE_SYM (63) ... KEYCODE_ENVELOPE (65) - case AKEYCODE_ENTER: return NS_VK_RETURN; - case AKEYCODE_DEL: return NS_VK_BACK; // Backspace - case AKEYCODE_GRAVE: return NS_VK_BACK_QUOTE; - // KEYCODE_MINUS (69) - case AKEYCODE_EQUALS: return NS_VK_EQUALS; - case AKEYCODE_LEFT_BRACKET: return NS_VK_OPEN_BRACKET; - case AKEYCODE_RIGHT_BRACKET: return NS_VK_CLOSE_BRACKET; - case AKEYCODE_BACKSLASH: return NS_VK_BACK_SLASH; - case AKEYCODE_SEMICOLON: return NS_VK_SEMICOLON; - // KEYCODE_APOSTROPHE (75) - case AKEYCODE_SLASH: return NS_VK_SLASH; - // KEYCODE_AT (77) ... KEYCODE_MEDIA_FAST_FORWARD (90) - case AKEYCODE_MUTE: return NS_VK_VOLUME_MUTE; - case AKEYCODE_PAGE_UP: return NS_VK_PAGE_UP; - case AKEYCODE_PAGE_DOWN: return NS_VK_PAGE_DOWN; - // KEYCODE_PICTSYMBOLS (94) ... KEYCODE_BUTTON_MODE (110) - case AKEYCODE_ESCAPE: return NS_VK_ESCAPE; - case AKEYCODE_FORWARD_DEL: return NS_VK_DELETE; - case AKEYCODE_CTRL_LEFT: return NS_VK_CONTROL; - case AKEYCODE_CTRL_RIGHT: return NS_VK_CONTROL; - case AKEYCODE_CAPS_LOCK: return NS_VK_CAPS_LOCK; - case AKEYCODE_SCROLL_LOCK: return NS_VK_SCROLL_LOCK; - // KEYCODE_META_LEFT (117) ... KEYCODE_FUNCTION (119) - case AKEYCODE_SYSRQ: return NS_VK_PRINTSCREEN; - case AKEYCODE_BREAK: return NS_VK_PAUSE; - case AKEYCODE_MOVE_HOME: return NS_VK_HOME; - case AKEYCODE_MOVE_END: return NS_VK_END; - case AKEYCODE_INSERT: return NS_VK_INSERT; - // KEYCODE_FORWARD (125) ... KEYCODE_MEDIA_RECORD (130) - case AKEYCODE_F1: return NS_VK_F1; - case AKEYCODE_F2: return NS_VK_F2; - case AKEYCODE_F3: return NS_VK_F3; - case AKEYCODE_F4: return NS_VK_F4; - case AKEYCODE_F5: return NS_VK_F5; - case AKEYCODE_F6: return NS_VK_F6; - case AKEYCODE_F7: return NS_VK_F7; - case AKEYCODE_F8: return NS_VK_F8; - case AKEYCODE_F9: return NS_VK_F9; - case AKEYCODE_F10: return NS_VK_F10; - case AKEYCODE_F11: return NS_VK_F11; - case AKEYCODE_F12: return NS_VK_F12; - case AKEYCODE_NUM_LOCK: return NS_VK_NUM_LOCK; - case AKEYCODE_NUMPAD_0: return NS_VK_NUMPAD0; - case AKEYCODE_NUMPAD_1: return NS_VK_NUMPAD1; - case AKEYCODE_NUMPAD_2: return NS_VK_NUMPAD2; - case AKEYCODE_NUMPAD_3: return NS_VK_NUMPAD3; - case AKEYCODE_NUMPAD_4: return NS_VK_NUMPAD4; - case AKEYCODE_NUMPAD_5: return NS_VK_NUMPAD5; - case AKEYCODE_NUMPAD_6: return NS_VK_NUMPAD6; - case AKEYCODE_NUMPAD_7: return NS_VK_NUMPAD7; - case AKEYCODE_NUMPAD_8: return NS_VK_NUMPAD8; - case AKEYCODE_NUMPAD_9: return NS_VK_NUMPAD9; - case AKEYCODE_NUMPAD_DIVIDE: return NS_VK_DIVIDE; - case AKEYCODE_NUMPAD_MULTIPLY: return NS_VK_MULTIPLY; - case AKEYCODE_NUMPAD_SUBTRACT: return NS_VK_SUBTRACT; - case AKEYCODE_NUMPAD_ADD: return NS_VK_ADD; - case AKEYCODE_NUMPAD_DOT: return NS_VK_DECIMAL; - case AKEYCODE_NUMPAD_COMMA: return NS_VK_SEPARATOR; - case AKEYCODE_NUMPAD_ENTER: return NS_VK_RETURN; - case AKEYCODE_NUMPAD_EQUALS: return NS_VK_EQUALS; - // KEYCODE_NUMPAD_LEFT_PAREN (162) ... KEYCODE_CALCULATOR (210) - - // Needs to confirm the behavior. If the key switches the open state - // of Japanese IME (or switches input character between Hiragana and - // Roman numeric characters), then, it might be better to use - // NS_VK_KANJI which is used for Alt+Zenkaku/Hankaku key on Windows. - case AKEYCODE_ZENKAKU_HANKAKU: return 0; - case AKEYCODE_EISU: return NS_VK_EISU; - case AKEYCODE_MUHENKAN: return NS_VK_NONCONVERT; - case AKEYCODE_HENKAN: return NS_VK_CONVERT; - case AKEYCODE_KATAKANA_HIRAGANA: return 0; - case AKEYCODE_YEN: return NS_VK_BACK_SLASH; // Same as other platforms. - case AKEYCODE_RO: return NS_VK_BACK_SLASH; // Same as other platforms. - case AKEYCODE_KANA: return NS_VK_KANA; - case AKEYCODE_ASSIST: return NS_VK_HELP; - - // the A key is the action key for gamepad devices. - case AKEYCODE_BUTTON_A: return NS_VK_RETURN; - - default: - ALOG("ConvertAndroidKeyCodeToDOMKeyCode: " - "No DOM keycode for Android keycode %d", androidKeyCode); - return 0; - } -} - -static KeyNameIndex -ConvertAndroidKeyCodeToKeyNameIndex(int keyCode, int action, - int domPrintableKeyValue) -{ - // Special-case alphanumeric keycodes because they are most common. - if (keyCode >= AKEYCODE_A && keyCode <= AKEYCODE_Z) { - return KEY_NAME_INDEX_USE_STRING; - } - - if (keyCode >= AKEYCODE_0 && keyCode <= AKEYCODE_9) { - return KEY_NAME_INDEX_USE_STRING; - } - - switch (keyCode) { - -#define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex) \ - case aNativeKey: return aKeyNameIndex; - -#include "NativeKeyToDOMKeyName.h" - -#undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX - - // KEYCODE_0 (7) ... KEYCODE_9 (16) - case AKEYCODE_STAR: // '*' key - case AKEYCODE_POUND: // '#' key - - // KEYCODE_A (29) ... KEYCODE_Z (54) - - case AKEYCODE_COMMA: // ',' key - case AKEYCODE_PERIOD: // '.' key - case AKEYCODE_SPACE: - case AKEYCODE_GRAVE: // '`' key - case AKEYCODE_MINUS: // '-' key - case AKEYCODE_EQUALS: // '=' key - case AKEYCODE_LEFT_BRACKET: // '[' key - case AKEYCODE_RIGHT_BRACKET: // ']' key - case AKEYCODE_BACKSLASH: // '\' key - case AKEYCODE_SEMICOLON: // ';' key - case AKEYCODE_APOSTROPHE: // ''' key - case AKEYCODE_SLASH: // '/' key - case AKEYCODE_AT: // '@' key - case AKEYCODE_PLUS: // '+' key - - case AKEYCODE_NUMPAD_0: - case AKEYCODE_NUMPAD_1: - case AKEYCODE_NUMPAD_2: - case AKEYCODE_NUMPAD_3: - case AKEYCODE_NUMPAD_4: - case AKEYCODE_NUMPAD_5: - case AKEYCODE_NUMPAD_6: - case AKEYCODE_NUMPAD_7: - case AKEYCODE_NUMPAD_8: - case AKEYCODE_NUMPAD_9: - case AKEYCODE_NUMPAD_DIVIDE: - case AKEYCODE_NUMPAD_MULTIPLY: - case AKEYCODE_NUMPAD_SUBTRACT: - case AKEYCODE_NUMPAD_ADD: - case AKEYCODE_NUMPAD_DOT: - case AKEYCODE_NUMPAD_COMMA: - case AKEYCODE_NUMPAD_EQUALS: - case AKEYCODE_NUMPAD_LEFT_PAREN: - case AKEYCODE_NUMPAD_RIGHT_PAREN: - - case AKEYCODE_YEN: // yen sign key - case AKEYCODE_RO: // Japanese Ro key - return KEY_NAME_INDEX_USE_STRING; - - case AKEYCODE_ENDCALL: - case AKEYCODE_NUM: // XXX Not sure - case AKEYCODE_HEADSETHOOK: - case AKEYCODE_NOTIFICATION: // XXX Not sure - case AKEYCODE_PICTSYMBOLS: - - case AKEYCODE_BUTTON_A: - case AKEYCODE_BUTTON_B: - case AKEYCODE_BUTTON_C: - case AKEYCODE_BUTTON_X: - case AKEYCODE_BUTTON_Y: - case AKEYCODE_BUTTON_Z: - case AKEYCODE_BUTTON_L1: - case AKEYCODE_BUTTON_R1: - case AKEYCODE_BUTTON_L2: - case AKEYCODE_BUTTON_R2: - case AKEYCODE_BUTTON_THUMBL: - case AKEYCODE_BUTTON_THUMBR: - case AKEYCODE_BUTTON_START: - case AKEYCODE_BUTTON_SELECT: - case AKEYCODE_BUTTON_MODE: - - case AKEYCODE_MUTE: // mutes the microphone - case AKEYCODE_MEDIA_CLOSE: - - case AKEYCODE_DVR: - - case AKEYCODE_BUTTON_1: - case AKEYCODE_BUTTON_2: - case AKEYCODE_BUTTON_3: - case AKEYCODE_BUTTON_4: - case AKEYCODE_BUTTON_5: - case AKEYCODE_BUTTON_6: - case AKEYCODE_BUTTON_7: - case AKEYCODE_BUTTON_8: - case AKEYCODE_BUTTON_9: - case AKEYCODE_BUTTON_10: - case AKEYCODE_BUTTON_11: - case AKEYCODE_BUTTON_12: - case AKEYCODE_BUTTON_13: - case AKEYCODE_BUTTON_14: - case AKEYCODE_BUTTON_15: - case AKEYCODE_BUTTON_16: - - case AKEYCODE_MANNER_MODE: - case AKEYCODE_3D_MODE: - case AKEYCODE_CONTACTS: - return KEY_NAME_INDEX_Unidentified; - - case AKEYCODE_UNKNOWN: - MOZ_ASSERT( - action != AKEY_EVENT_ACTION_MULTIPLE, - "Don't call this when action is AKEY_EVENT_ACTION_MULTIPLE!"); - // It's actually an unknown key if the action isn't ACTION_MULTIPLE. - // However, it might cause text input. So, let's check the value. - return domPrintableKeyValue ? - KEY_NAME_INDEX_USE_STRING : KEY_NAME_INDEX_Unidentified; - - default: - ALOG("ConvertAndroidKeyCodeToKeyNameIndex: " - "No DOM key name index for Android keycode %d", keyCode); - return KEY_NAME_INDEX_Unidentified; - } -} - -static CodeNameIndex -ConvertAndroidScanCodeToCodeNameIndex(int scanCode) -{ - switch (scanCode) { - -#define NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, aCodeNameIndex) \ - case aNativeKey: return aCodeNameIndex; - -#include "NativeKeyToDOMCodeName.h" - -#undef NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX - - default: - return CODE_NAME_INDEX_UNKNOWN; - } -} - -static bool -IsModifierKey(int32_t keyCode) -{ - using mozilla::java::sdk::KeyEvent; - return keyCode == KeyEvent::KEYCODE_ALT_LEFT || - keyCode == KeyEvent::KEYCODE_ALT_RIGHT || - keyCode == KeyEvent::KEYCODE_SHIFT_LEFT || - keyCode == KeyEvent::KEYCODE_SHIFT_RIGHT || - keyCode == KeyEvent::KEYCODE_CTRL_LEFT || - keyCode == KeyEvent::KEYCODE_CTRL_RIGHT || - keyCode == KeyEvent::KEYCODE_META_LEFT || - keyCode == KeyEvent::KEYCODE_META_RIGHT; -} - -static Modifiers -GetModifiers(int32_t metaState) -{ - using mozilla::java::sdk::KeyEvent; - return (metaState & KeyEvent::META_ALT_MASK ? MODIFIER_ALT : 0) - | (metaState & KeyEvent::META_SHIFT_MASK ? MODIFIER_SHIFT : 0) - | (metaState & KeyEvent::META_CTRL_MASK ? MODIFIER_CONTROL : 0) - | (metaState & KeyEvent::META_META_MASK ? MODIFIER_META : 0) - | (metaState & KeyEvent::META_FUNCTION_ON ? MODIFIER_FN : 0) - | (metaState & KeyEvent::META_CAPS_LOCK_ON ? MODIFIER_CAPSLOCK : 0) - | (metaState & KeyEvent::META_NUM_LOCK_ON ? MODIFIER_NUMLOCK : 0) - | (metaState & KeyEvent::META_SCROLL_LOCK_ON ? MODIFIER_SCROLLLOCK : 0); -} - -static void -InitKeyEvent(WidgetKeyboardEvent& event, - int32_t action, int32_t keyCode, int32_t scanCode, - int32_t metaState, int64_t time, int32_t unicodeChar, - int32_t baseUnicodeChar, int32_t domPrintableKeyValue, - int32_t repeatCount, int32_t flags) -{ - const uint32_t domKeyCode = ConvertAndroidKeyCodeToDOMKeyCode(keyCode); - const int32_t charCode = unicodeChar ? unicodeChar : baseUnicodeChar; - - event.mModifiers = GetModifiers(metaState); - - if (event.mMessage == eKeyPress) { - // Android gives us \n, so filter out some control characters. - event.mIsChar = (charCode >= ' '); - event.mCharCode = event.mIsChar ? charCode : 0; - event.mKeyCode = event.mIsChar ? 0 : domKeyCode; - event.mPluginEvent.Clear(); - - // For keypress, if the unicode char already has modifiers applied, we - // don't specify extra modifiers. If UnicodeChar() != BaseUnicodeChar() - // it means UnicodeChar() already has modifiers applied. - // Note that on Android 4.x, Alt modifier isn't set when the key input - // causes text input even while right Alt key is pressed. However, - // this is necessary for Android 2.3 compatibility. - if (unicodeChar && unicodeChar != baseUnicodeChar) { - event.mModifiers &= ~(MODIFIER_ALT | MODIFIER_CONTROL - | MODIFIER_META); - } - - } else { - event.mIsChar = false; - event.mCharCode = 0; - event.mKeyCode = domKeyCode; - - ANPEvent pluginEvent; - pluginEvent.inSize = sizeof(pluginEvent); - pluginEvent.eventType = kKey_ANPEventType; - pluginEvent.data.key.action = event.mMessage == eKeyDown - ? kDown_ANPKeyAction : kUp_ANPKeyAction; - pluginEvent.data.key.nativeCode = keyCode; - pluginEvent.data.key.virtualCode = domKeyCode; - pluginEvent.data.key.unichar = charCode; - pluginEvent.data.key.modifiers = - (metaState & sdk::KeyEvent::META_SHIFT_MASK - ? kShift_ANPKeyModifier : 0) | - (metaState & sdk::KeyEvent::META_ALT_MASK - ? kAlt_ANPKeyModifier : 0); - pluginEvent.data.key.repeatCount = repeatCount; - event.mPluginEvent.Copy(pluginEvent); - } - - event.mIsRepeat = - (event.mMessage == eKeyDown || event.mMessage == eKeyPress) && - ((flags & sdk::KeyEvent::FLAG_LONG_PRESS) || repeatCount); - - event.mKeyNameIndex = ConvertAndroidKeyCodeToKeyNameIndex( - keyCode, action, domPrintableKeyValue); - event.mCodeNameIndex = ConvertAndroidScanCodeToCodeNameIndex(scanCode); - - if (event.mKeyNameIndex == KEY_NAME_INDEX_USE_STRING && - domPrintableKeyValue) { - event.mKeyValue = char16_t(domPrintableKeyValue); - } - - event.mLocation = - WidgetKeyboardEvent::ComputeLocationFromCodeValue(event.mCodeNameIndex); - event.mTime = time; -} - -void -nsWindow::GeckoViewSupport::OnKeyEvent(int32_t aAction, int32_t aKeyCode, - int32_t aScanCode, int32_t aMetaState, int64_t aTime, - int32_t aUnicodeChar, int32_t aBaseUnicodeChar, - int32_t aDomPrintableKeyValue, int32_t aRepeatCount, int32_t aFlags, - bool aIsSynthesizedImeKey, jni::Object::Param originalEvent) -{ - RefPtr<nsWindow> kungFuDeathGrip(&window); - if (!aIsSynthesizedImeKey) { - window.UserActivity(); - window.RemoveIMEComposition(); - } - - EventMessage msg; - if (aAction == sdk::KeyEvent::ACTION_DOWN) { - msg = eKeyDown; - } else if (aAction == sdk::KeyEvent::ACTION_UP) { - msg = eKeyUp; - } else if (aAction == sdk::KeyEvent::ACTION_MULTIPLE) { - // Keys with multiple action are handled in Java, - // and we should never see one here - MOZ_CRASH("Cannot handle key with multiple action"); - } else { - ALOG("Unknown key action event!"); - return; - } - - nsEventStatus status = nsEventStatus_eIgnore; - WidgetKeyboardEvent event(true, msg, &window); - window.InitEvent(event, nullptr); - InitKeyEvent(event, aAction, aKeyCode, aScanCode, aMetaState, aTime, - aUnicodeChar, aBaseUnicodeChar, aDomPrintableKeyValue, - aRepeatCount, aFlags); - - if (aIsSynthesizedImeKey) { - // Keys synthesized by Java IME code are saved in the mIMEKeyEvents - // array until the next IME_REPLACE_TEXT event, at which point - // these keys are dispatched in sequence. - mIMEKeyEvents.AppendElement( - mozilla::UniquePtr<WidgetEvent>(event.Duplicate())); - - } else { - window.DispatchEvent(&event, status); - - if (window.Destroyed() || status == nsEventStatus_eConsumeNoDefault) { - // Skip default processing. - return; - } - - mEditable->OnDefaultKeyEvent(originalEvent); - } - - if (msg != eKeyDown || IsModifierKey(aKeyCode)) { - // Skip sending key press event. - return; - } - - WidgetKeyboardEvent pressEvent(true, eKeyPress, &window); - window.InitEvent(pressEvent, nullptr); - InitKeyEvent(pressEvent, aAction, aKeyCode, aScanCode, aMetaState, aTime, - aUnicodeChar, aBaseUnicodeChar, aDomPrintableKeyValue, - aRepeatCount, aFlags); - - if (aIsSynthesizedImeKey) { - mIMEKeyEvents.AppendElement( - mozilla::UniquePtr<WidgetEvent>(pressEvent.Duplicate())); - } else { - window.DispatchEvent(&pressEvent, status); - } -} - -#ifdef DEBUG_ANDROID_IME -#define ALOGIME(args...) ALOG(args) -#else -#define ALOGIME(args...) ((void)0) -#endif - -static nscolor -ConvertAndroidColor(uint32_t aArgb) -{ - return NS_RGBA((aArgb & 0x00ff0000) >> 16, - (aArgb & 0x0000ff00) >> 8, - (aArgb & 0x000000ff), - (aArgb & 0xff000000) >> 24); -} - -/* - * Get the current composition object, if any. - */ -RefPtr<mozilla::TextComposition> -nsWindow::GetIMEComposition() -{ - MOZ_ASSERT(this == FindTopLevel()); - return mozilla::IMEStateManager::GetTextCompositionFor(this); -} - -/* - Remove the composition but leave the text content as-is -*/ -void -nsWindow::RemoveIMEComposition(RemoveIMECompositionFlag aFlag) -{ - // Remove composition on Gecko side - const RefPtr<mozilla::TextComposition> composition(GetIMEComposition()); - if (!composition) { - return; - } - - RefPtr<nsWindow> kungFuDeathGrip(this); - - WidgetCompositionEvent compositionCommitEvent( - true, eCompositionCommit, this); - if (aFlag == COMMIT_IME_COMPOSITION) { - compositionCommitEvent.mMessage = eCompositionCommitAsIs; - } - InitEvent(compositionCommitEvent, nullptr); - DispatchEvent(&compositionCommitEvent); -} - -/* - * Send dummy key events for pages that are unaware of input events, - * to provide web compatibility for pages that depend on key events. - * Our dummy key events have 0 as the keycode. - */ -void -nsWindow::GeckoViewSupport::SendIMEDummyKeyEvents() -{ - WidgetKeyboardEvent downEvent(true, eKeyDown, &window); - window.InitEvent(downEvent, nullptr); - MOZ_ASSERT(downEvent.mKeyCode == 0); - window.DispatchEvent(&downEvent); - - WidgetKeyboardEvent upEvent(true, eKeyUp, &window); - window.InitEvent(upEvent, nullptr); - MOZ_ASSERT(upEvent.mKeyCode == 0); - window.DispatchEvent(&upEvent); -} - -void -nsWindow::GeckoViewSupport::AddIMETextChange(const IMETextChange& aChange) -{ - mIMETextChanges.AppendElement(aChange); - - // We may not be in the middle of flushing, - // in which case this flag is meaningless. - mIMETextChangedDuringFlush = true; - - // Now that we added a new range we need to go back and - // update all the ranges before that. - // Ranges that have offsets which follow this new range - // need to be updated to reflect new offsets - const int32_t delta = aChange.mNewEnd - aChange.mOldEnd; - for (int32_t i = mIMETextChanges.Length() - 2; i >= 0; i--) { - IMETextChange& previousChange = mIMETextChanges[i]; - if (previousChange.mStart > aChange.mOldEnd) { - previousChange.mStart += delta; - previousChange.mOldEnd += delta; - previousChange.mNewEnd += delta; - } - } - - // Now go through all ranges to merge any ranges that are connected - // srcIndex is the index of the range to merge from - // dstIndex is the index of the range to potentially merge into - int32_t srcIndex = mIMETextChanges.Length() - 1; - int32_t dstIndex = srcIndex; - - while (--dstIndex >= 0) { - IMETextChange& src = mIMETextChanges[srcIndex]; - IMETextChange& dst = mIMETextChanges[dstIndex]; - // When merging a more recent change into an older - // change, we need to compare recent change's (start, oldEnd) - // range to the older change's (start, newEnd) - if (src.mOldEnd < dst.mStart || dst.mNewEnd < src.mStart) { - // No overlap between ranges - continue; - } - // When merging two ranges, there are generally four posibilities: - // [----(----]----), (----[----]----), - // [----(----)----], (----[----)----] - // where [----] is the first range and (----) is the second range - // As seen above, the start of the merged range is always the lesser - // of the two start offsets. OldEnd and NewEnd then need to be - // adjusted separately depending on the case. In any case, the change - // in text length of the merged range should be the sum of text length - // changes of the two original ranges, i.e., - // newNewEnd - newOldEnd == newEnd1 - oldEnd1 + newEnd2 - oldEnd2 - dst.mStart = std::min(dst.mStart, src.mStart); - if (src.mOldEnd < dst.mNewEnd) { - // New range overlaps or is within previous range; merge - dst.mNewEnd += src.mNewEnd - src.mOldEnd; - } else { // src.mOldEnd >= dst.mNewEnd - // New range overlaps previous range; merge - dst.mOldEnd += src.mOldEnd - dst.mNewEnd; - dst.mNewEnd = src.mNewEnd; - } - // src merged to dst; delete src. - mIMETextChanges.RemoveElementAt(srcIndex); - // Any ranges that we skip over between src and dst are not mergeable - // so we can safely continue the merge starting at dst - srcIndex = dstIndex; - } -} - -void -nsWindow::GeckoViewSupport::PostFlushIMEChanges() -{ - if (!mIMETextChanges.IsEmpty() || mIMESelectionChanged) { - // Already posted - return; - } - - // Keep a strong reference to the window to keep 'this' alive. - RefPtr<nsWindow> window(&this->window); - - nsAppShell::PostEvent([this, window] { - if (!window->Destroyed()) { - FlushIMEChanges(); - } - }); -} - -void -nsWindow::GeckoViewSupport::FlushIMEChanges(FlushChangesFlag aFlags) -{ - // Only send change notifications if we are *not* masking events, - // i.e. if we have a focused editor, - NS_ENSURE_TRUE_VOID(!mIMEMaskEventsCount); - - nsCOMPtr<nsISelection> imeSelection; - nsCOMPtr<nsIContent> imeRoot; - - // If we are receiving notifications, we must have selection/root content. - MOZ_ALWAYS_SUCCEEDS(IMEStateManager::GetFocusSelectionAndRoot( - getter_AddRefs(imeSelection), getter_AddRefs(imeRoot))); - - // Make sure we still have a valid selection/root. We can potentially get - // a stale selection/root if the editor becomes hidden, for example. - NS_ENSURE_TRUE_VOID(imeRoot->IsInComposedDoc()); - - RefPtr<nsWindow> kungFuDeathGrip(&window); - window.UserActivity(); - - struct TextRecord { - nsString text; - int32_t start; - int32_t oldEnd; - int32_t newEnd; - }; - AutoTArray<TextRecord, 4> textTransaction; - if (mIMETextChanges.Length() > textTransaction.Capacity()) { - textTransaction.SetCapacity(mIMETextChanges.Length()); - } - - mIMETextChangedDuringFlush = false; - - auto shouldAbort = [=] () -> bool { - if (!mIMETextChangedDuringFlush) { - return false; - } - // A query event could have triggered more text changes to come in, as - // indicated by our flag. If that happens, try flushing IME changes - // again. - if (aFlags == FLUSH_FLAG_NONE) { - FlushIMEChanges(FLUSH_FLAG_RETRY); - } else { - // Don't retry if already retrying, to avoid infinite loops. - __android_log_print(ANDROID_LOG_WARN, "GeckoViewSupport", - "Already retrying IME flush"); - } - return true; - }; - - for (const IMETextChange &change : mIMETextChanges) { - if (change.mStart == change.mOldEnd && - change.mStart == change.mNewEnd) { - continue; - } - - WidgetQueryContentEvent event(true, eQueryTextContent, &window); - - if (change.mNewEnd != change.mStart) { - window.InitEvent(event, nullptr); - event.InitForQueryTextContent(change.mStart, - change.mNewEnd - change.mStart); - window.DispatchEvent(&event); - NS_ENSURE_TRUE_VOID(event.mSucceeded); - NS_ENSURE_TRUE_VOID(event.mReply.mContentsRoot == imeRoot.get()); - } - - if (shouldAbort()) { - return; - } - - textTransaction.AppendElement( - TextRecord{event.mReply.mString, change.mStart, - change.mOldEnd, change.mNewEnd}); - } - - int32_t selStart = -1; - int32_t selEnd = -1; - - if (mIMESelectionChanged) { - WidgetQueryContentEvent event(true, eQuerySelectedText, &window); - window.InitEvent(event, nullptr); - window.DispatchEvent(&event); - - NS_ENSURE_TRUE_VOID(event.mSucceeded); - NS_ENSURE_TRUE_VOID(event.mReply.mContentsRoot == imeRoot.get()); - - if (shouldAbort()) { - return; - } - - selStart = int32_t(event.GetSelectionStart()); - selEnd = int32_t(event.GetSelectionEnd()); - } - - JNIEnv* const env = jni::GetGeckoThreadEnv(); - auto flushOnException = [=] () -> bool { - if (!env->ExceptionCheck()) { - return false; - } - if (aFlags != FLUSH_FLAG_RECOVER) { - // First time seeing an exception; try flushing text. - env->ExceptionClear(); - __android_log_print(ANDROID_LOG_WARN, "GeckoViewSupport", - "Recovering from IME exception"); - FlushIMEText(FLUSH_FLAG_RECOVER); - } else { - // Give up because we've already tried. - MOZ_CATCH_JNI_EXCEPTION(env); - } - return true; - }; - - // Commit the text change and selection change transaction. - mIMETextChanges.Clear(); - - for (const TextRecord& record : textTransaction) { - mEditable->OnTextChange(record.text, record.start, - record.oldEnd, record.newEnd); - if (flushOnException()) { - return; - } - } - - if (mIMESelectionChanged) { - mIMESelectionChanged = false; - mEditable->OnSelectionChange(selStart, selEnd); - flushOnException(); - } -} - -void -nsWindow::GeckoViewSupport::FlushIMEText(FlushChangesFlag aFlags) -{ - // Notify Java of the newly focused content - mIMETextChanges.Clear(); - mIMESelectionChanged = true; - - // Use 'INT32_MAX / 2' here because subsequent text changes might combine - // with this text change, and overflow might occur if we just use - // INT32_MAX. - IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE); - notification.mTextChangeData.mStartOffset = 0; - notification.mTextChangeData.mRemovedEndOffset = INT32_MAX / 2; - notification.mTextChangeData.mAddedEndOffset = INT32_MAX / 2; - NotifyIME(notification); - - FlushIMEChanges(aFlags); -} - -static jni::ObjectArray::LocalRef -ConvertRectArrayToJavaRectFArray(JNIEnv* aJNIEnv, const nsTArray<LayoutDeviceIntRect>& aRects, const LayoutDeviceIntPoint& aOffset, const CSSToLayoutDeviceScale aScale) -{ - size_t length = aRects.Length(); - jobjectArray rects = aJNIEnv->NewObjectArray(length, sdk::RectF::Context().ClassRef(), nullptr); - auto rectsRef = jni::ObjectArray::LocalRef::Adopt(aJNIEnv, rects); - for (size_t i = 0; i < length; i++) { - sdk::RectF::LocalRef rect(aJNIEnv); - LayoutDeviceIntRect tmp = aRects[i] + aOffset; - sdk::RectF::New(tmp.x / aScale.scale, tmp.y / aScale.scale, - (tmp.x + tmp.width) / aScale.scale, - (tmp.y + tmp.height) / aScale.scale, - &rect); - rectsRef->SetElement(i, rect); - } - return rectsRef; -} - -void -nsWindow::GeckoViewSupport::UpdateCompositionRects() -{ - const auto composition(window.GetIMEComposition()); - if (NS_WARN_IF(!composition)) { - return; - } - - uint32_t offset = composition->NativeOffsetOfStartComposition(); - WidgetQueryContentEvent textRects(true, eQueryTextRectArray, &window); - textRects.InitForQueryTextRectArray(offset, composition->String().Length()); - window.DispatchEvent(&textRects); - - auto rects = - ConvertRectArrayToJavaRectFArray(jni::GetGeckoThreadEnv(), - textRects.mReply.mRectArray, - window.WidgetToScreenOffset(), - window.GetDefaultScale()); - - mEditable->UpdateCompositionRects(rects); -} - -void -nsWindow::GeckoViewSupport::AsyncNotifyIME(int32_t aNotification) -{ - // Keep a strong reference to the window to keep 'this' alive. - RefPtr<nsWindow> window(&this->window); - - nsAppShell::PostEvent([this, window, aNotification] { - if (mIMEMaskEventsCount) { - return; - } - - mEditable->NotifyIME(aNotification); - }); -} - -bool -nsWindow::GeckoViewSupport::NotifyIME(const IMENotification& aIMENotification) -{ - MOZ_ASSERT(mEditable); - - switch (aIMENotification.mMessage) { - case REQUEST_TO_COMMIT_COMPOSITION: { - ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION"); - - window.RemoveIMEComposition(); - - AsyncNotifyIME(GeckoEditableListener:: - NOTIFY_IME_TO_COMMIT_COMPOSITION); - return true; - } - - case REQUEST_TO_CANCEL_COMPOSITION: { - ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION"); - - window.RemoveIMEComposition(CANCEL_IME_COMPOSITION); - - AsyncNotifyIME(GeckoEditableListener:: - NOTIFY_IME_TO_CANCEL_COMPOSITION); - return true; - } - - case NOTIFY_IME_OF_FOCUS: { - ALOGIME("IME: NOTIFY_IME_OF_FOCUS"); - // Keep a strong reference to the window to keep 'this' alive. - RefPtr<nsWindow> window(&this->window); - - // Post an event because we have to flush the text before sending a - // focus event, and we may not be able to flush text during the - // NotifyIME call. - nsAppShell::PostEvent([this, window] { - --mIMEMaskEventsCount; - if (mIMEMaskEventsCount || window->Destroyed()) { - return; - } - - FlushIMEText(); - - // IME will call requestCursorUpdates after getting context. - // So reset cursor update mode before getting context. - mIMEMonitorCursor = false; - - MOZ_ASSERT(mEditable); - mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_OF_FOCUS); - }); - return true; - } - - case NOTIFY_IME_OF_BLUR: { - ALOGIME("IME: NOTIFY_IME_OF_BLUR"); - - if (!mIMEMaskEventsCount) { - mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_OF_BLUR); - } - - // Mask events because we lost focus. Unmask on the next focus. - mIMEMaskEventsCount++; - return true; - } - - case NOTIFY_IME_OF_SELECTION_CHANGE: { - ALOGIME("IME: NOTIFY_IME_OF_SELECTION_CHANGE"); - - PostFlushIMEChanges(); - mIMESelectionChanged = true; - return true; - } - - case NOTIFY_IME_OF_TEXT_CHANGE: { - ALOGIME("IME: NotifyIMEOfTextChange: s=%d, oe=%d, ne=%d", - aIMENotification.mTextChangeData.mStartOffset, - aIMENotification.mTextChangeData.mRemovedEndOffset, - aIMENotification.mTextChangeData.mAddedEndOffset); - - /* Make sure Java's selection is up-to-date */ - PostFlushIMEChanges(); - mIMESelectionChanged = true; - AddIMETextChange(IMETextChange(aIMENotification)); - return true; - } - - case NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED: { - ALOGIME("IME: NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED"); - - // Hardware keyboard support requires each string rect. - if (AndroidBridge::Bridge() && AndroidBridge::Bridge()->GetAPIVersion() >= 21 && mIMEMonitorCursor) { - UpdateCompositionRects(); - } - return true; - } - - default: - return false; - } -} - -void -nsWindow::GeckoViewSupport::SetInputContext(const InputContext& aContext, - const InputContextAction& aAction) -{ - MOZ_ASSERT(mEditable); - - ALOGIME("IME: SetInputContext: s=0x%X, 0x%X, action=0x%X, 0x%X", - aContext.mIMEState.mEnabled, aContext.mIMEState.mOpen, - aAction.mCause, aAction.mFocusChange); - - // Ensure that opening the virtual keyboard is allowed for this specific - // InputContext depending on the content.ime.strict.policy pref - if (aContext.mIMEState.mEnabled != IMEState::DISABLED && - aContext.mIMEState.mEnabled != IMEState::PLUGIN && - Preferences::GetBool("content.ime.strict_policy", false) && - !aAction.ContentGotFocusByTrustedCause() && - !aAction.UserMightRequestOpenVKB()) { - return; - } - - IMEState::Enabled enabled = aContext.mIMEState.mEnabled; - - // Only show the virtual keyboard for plugins if mOpen is set appropriately. - // This avoids showing it whenever a plugin is focused. Bug 747492 - if (aContext.mIMEState.mEnabled == IMEState::PLUGIN && - aContext.mIMEState.mOpen != IMEState::OPEN) { - enabled = IMEState::DISABLED; - } - - mInputContext = aContext; - mInputContext.mIMEState.mEnabled = enabled; - - if (enabled == IMEState::ENABLED && aAction.UserMightRequestOpenVKB()) { - // Don't reset keyboard when we should simply open the vkb - mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_OPEN_VKB); - return; - } - - if (mIMEUpdatingContext) { - return; - } - - // Keep a strong reference to the window to keep 'this' alive. - RefPtr<nsWindow> window(&this->window); - mIMEUpdatingContext = true; - - nsAppShell::PostEvent([this, window] { - mIMEUpdatingContext = false; - if (window->Destroyed()) { - return; - } - MOZ_ASSERT(mEditable); - mEditable->NotifyIMEContext(mInputContext.mIMEState.mEnabled, - mInputContext.mHTMLInputType, - mInputContext.mHTMLInputInputmode, - mInputContext.mActionHint); - }); -} - -InputContext -nsWindow::GeckoViewSupport::GetInputContext() -{ - InputContext context = mInputContext; - context.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED; - return context; -} - -void -nsWindow::GeckoViewSupport::OnImeSynchronize() -{ - if (!mIMEMaskEventsCount) { - FlushIMEChanges(); - } - mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_REPLY_EVENT); -} - -void -nsWindow::GeckoViewSupport::OnImeReplaceText(int32_t aStart, int32_t aEnd, - jni::String::Param aText) -{ - AutoIMESynchronize as(this); - - if (mIMEMaskEventsCount > 0) { - // Not focused; still reply to events, but don't do anything else. - return; - } - - /* - Replace text in Gecko thread from aStart to aEnd with the string text. - */ - RefPtr<nsWindow> kungFuDeathGrip(&window); - nsString string(aText->ToString()); - - const auto composition(window.GetIMEComposition()); - MOZ_ASSERT(!composition || !composition->IsEditorHandlingEvent()); - - const bool composing = !mIMERanges->IsEmpty(); - - if (!mIMEKeyEvents.IsEmpty() || !composition || - uint32_t(aStart) != composition->NativeOffsetOfStartComposition() || - uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() + - composition->String().Length()) - { - // Only start a new composition if we have key events, - // if we don't have an existing composition, or - // the replaced text does not match our composition. - window.RemoveIMEComposition(); - - { - // Use text selection to set target postion(s) for - // insert, or replace, of text. - WidgetSelectionEvent event(true, eSetSelection, &window); - window.InitEvent(event, nullptr); - event.mOffset = uint32_t(aStart); - event.mLength = uint32_t(aEnd - aStart); - event.mExpandToClusterBoundary = false; - event.mReason = nsISelectionListener::IME_REASON; - window.DispatchEvent(&event); - } - - if (!mIMEKeyEvents.IsEmpty()) { - nsEventStatus status; - for (uint32_t i = 0; i < mIMEKeyEvents.Length(); i++) { - const auto event = static_cast<WidgetGUIEvent*>( - mIMEKeyEvents[i].get()); - if (event->mMessage == eKeyPress && - status == nsEventStatus_eConsumeNoDefault) { - MOZ_ASSERT(i > 0 && - mIMEKeyEvents[i - 1]->mMessage == eKeyDown); - // The previous key down event resulted in eConsumeNoDefault - // so we should not dispatch the current key press event. - continue; - } - // widget for duplicated events is initially nullptr. - event->mWidget = &window; - window.DispatchEvent(event, status); - } - mIMEKeyEvents.Clear(); - return; - } - - if (aStart != aEnd) { - // Perform a deletion first. - WidgetContentCommandEvent event( - true, eContentCommandDelete, &window); - window.InitEvent(event, nullptr); - window.DispatchEvent(&event); - } - - // Start a composition if we're not just performing a deletion. - if (composing || !string.IsEmpty()) { - WidgetCompositionEvent event(true, eCompositionStart, &window); - window.InitEvent(event, nullptr); - window.DispatchEvent(&event); - } - - } else if (composition->String().Equals(string)) { - /* If the new text is the same as the existing composition text, - * the NS_COMPOSITION_CHANGE event does not generate a text - * change notification. However, the Java side still expects - * one, so we manually generate a notification. */ - IMETextChange dummyChange; - dummyChange.mStart = aStart; - dummyChange.mOldEnd = dummyChange.mNewEnd = aEnd; - AddIMETextChange(dummyChange); - } - - // Check composition again because previous events may have destroyed our - // composition; in which case we should just skip the next event. - if (window.GetIMEComposition()) { - WidgetCompositionEvent event(true, eCompositionChange, &window); - window.InitEvent(event, nullptr); - event.mData = string; - - if (composing) { - event.mRanges = new TextRangeArray(); - mIMERanges.swap(event.mRanges); - } else { - event.mMessage = eCompositionCommit; - } - - window.DispatchEvent(&event); - - } else if (composing) { - // Ensure IME ranges are empty. - mIMERanges->Clear(); - } - - if (mInputContext.mMayBeIMEUnaware) { - SendIMEDummyKeyEvents(); - } -} - -void -nsWindow::GeckoViewSupport::OnImeAddCompositionRange( - int32_t aStart, int32_t aEnd, int32_t aRangeType, int32_t aRangeStyle, - int32_t aRangeLineStyle, bool aRangeBoldLine, int32_t aRangeForeColor, - int32_t aRangeBackColor, int32_t aRangeLineColor) -{ - if (mIMEMaskEventsCount > 0) { - // Not focused. - return; - } - - TextRange range; - range.mStartOffset = aStart; - range.mEndOffset = aEnd; - range.mRangeType = ToTextRangeType(aRangeType); - range.mRangeStyle.mDefinedStyles = aRangeStyle; - range.mRangeStyle.mLineStyle = aRangeLineStyle; - range.mRangeStyle.mIsBoldLine = aRangeBoldLine; - range.mRangeStyle.mForegroundColor = - ConvertAndroidColor(uint32_t(aRangeForeColor)); - range.mRangeStyle.mBackgroundColor = - ConvertAndroidColor(uint32_t(aRangeBackColor)); - range.mRangeStyle.mUnderlineColor = - ConvertAndroidColor(uint32_t(aRangeLineColor)); - mIMERanges->AppendElement(range); -} - -void -nsWindow::GeckoViewSupport::OnImeUpdateComposition(int32_t aStart, int32_t aEnd) -{ - if (mIMEMaskEventsCount > 0) { - // Not focused. - return; - } - - RefPtr<nsWindow> kungFuDeathGrip(&window); - - // A composition with no ranges means we want to set the selection. - if (mIMERanges->IsEmpty()) { - MOZ_ASSERT(aStart >= 0 && aEnd >= 0); - window.RemoveIMEComposition(); - - WidgetSelectionEvent selEvent(true, eSetSelection, &window); - window.InitEvent(selEvent, nullptr); - - selEvent.mOffset = std::min(aStart, aEnd); - selEvent.mLength = std::max(aStart, aEnd) - selEvent.mOffset; - selEvent.mReversed = aStart > aEnd; - selEvent.mExpandToClusterBoundary = false; - - window.DispatchEvent(&selEvent); - return; - } - - /* - Update the composition from aStart to aEnd using - information from added ranges. This is only used for - visual indication and does not affect the text content. - Only the offsets are specified and not the text content - to eliminate the possibility of this event altering the - text content unintentionally. - */ - const auto composition(window.GetIMEComposition()); - MOZ_ASSERT(!composition || !composition->IsEditorHandlingEvent()); - - WidgetCompositionEvent event(true, eCompositionChange, &window); - window.InitEvent(event, nullptr); - - event.mRanges = new TextRangeArray(); - mIMERanges.swap(event.mRanges); - - if (!composition || - uint32_t(aStart) != composition->NativeOffsetOfStartComposition() || - uint32_t(aEnd) != composition->NativeOffsetOfStartComposition() + - composition->String().Length()) - { - // Only start new composition if we don't have an existing one, - // or if the existing composition doesn't match the new one. - window.RemoveIMEComposition(); - - { - WidgetSelectionEvent event(true, eSetSelection, &window); - window.InitEvent(event, nullptr); - event.mOffset = uint32_t(aStart); - event.mLength = uint32_t(aEnd - aStart); - event.mExpandToClusterBoundary = false; - event.mReason = nsISelectionListener::IME_REASON; - window.DispatchEvent(&event); - } - - { - WidgetQueryContentEvent queryEvent(true, eQuerySelectedText, - &window); - window.InitEvent(queryEvent, nullptr); - window.DispatchEvent(&queryEvent); - MOZ_ASSERT(queryEvent.mSucceeded); - event.mData = queryEvent.mReply.mString; - } - - { - WidgetCompositionEvent event(true, eCompositionStart, &window); - window.InitEvent(event, nullptr); - window.DispatchEvent(&event); - } - - } else { - // If the new composition matches the existing composition, - // reuse the old composition. - event.mData = composition->String(); - } - -#ifdef DEBUG_ANDROID_IME - const NS_ConvertUTF16toUTF8 data(event.mData); - const char* text = data.get(); - ALOGIME("IME: IME_SET_TEXT: text=\"%s\", length=%u, range=%u", - text, event.mData.Length(), event.mRanges->Length()); -#endif // DEBUG_ANDROID_IME - - // Previous events may have destroyed our composition; bail in that case. - if (window.GetIMEComposition()) { - window.DispatchEvent(&event); - } -} - -void -nsWindow::GeckoViewSupport::OnImeRequestCursorUpdates(int aRequestMode) -{ - if (aRequestMode == IME_MONITOR_CURSOR_ONE_SHOT) { - UpdateCompositionRects(); - return; - } - - mIMEMonitorCursor = (aRequestMode == IME_MONITOR_CURSOR_START_MONITOR); -} - -void -nsWindow::UserActivity() -{ - if (!mIdleService) { - mIdleService = do_GetService("@mozilla.org/widget/idleservice;1"); - } - - if (mIdleService) { - mIdleService->ResetIdleTimeOut(0); - } -} - -nsresult -nsWindow::NotifyIMEInternal(const IMENotification& aIMENotification) -{ - MOZ_ASSERT(this == FindTopLevel()); - - if (!mGeckoViewSupport) { - // Non-GeckoView windows don't support IME operations. - return NS_ERROR_NOT_AVAILABLE; - } - - if (mGeckoViewSupport->NotifyIME(aIMENotification)) { - return NS_OK; - } - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP_(void) -nsWindow::SetInputContext(const InputContext& aContext, - const InputContextAction& aAction) -{ - nsWindow* top = FindTopLevel(); - MOZ_ASSERT(top); - - if (!top->mGeckoViewSupport) { - // Non-GeckoView windows don't support IME operations. - return; - } - - // We are using an IME event later to notify Java, and the IME event - // will be processed by the top window. Therefore, to ensure the - // IME event uses the correct mInputContext, we need to let the top - // window process SetInputContext - top->mGeckoViewSupport->SetInputContext(aContext, aAction); -} - -NS_IMETHODIMP_(InputContext) -nsWindow::GetInputContext() -{ - nsWindow* top = FindTopLevel(); - MOZ_ASSERT(top); - - if (!top->mGeckoViewSupport) { - // Non-GeckoView windows don't support IME operations. - return InputContext(); - } - - // We let the top window process SetInputContext, - // so we should let it process GetInputContext as well. - return top->mGeckoViewSupport->GetInputContext(); -} - -nsIMEUpdatePreference -nsWindow::GetIMEUpdatePreference() -{ - // While a plugin has focus, nsWindow for Android doesn't need any - // notifications. - if (GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN) { - return nsIMEUpdatePreference(); - } - return nsIMEUpdatePreference(nsIMEUpdatePreference::NOTIFY_TEXT_CHANGE); -} - -nsresult -nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId, - TouchPointerState aPointerState, - LayoutDeviceIntPoint aPoint, - double aPointerPressure, - uint32_t aPointerOrientation, - nsIObserver* aObserver) -{ - mozilla::widget::AutoObserverNotifier notifier(aObserver, "touchpoint"); - - int eventType; - switch (aPointerState) { - case TOUCH_CONTACT: - // This could be a ACTION_DOWN or ACTION_MOVE depending on the - // existing state; it is mapped to the right thing in Java. - eventType = sdk::MotionEvent::ACTION_POINTER_DOWN; - break; - case TOUCH_REMOVE: - // This could be turned into a ACTION_UP in Java - eventType = sdk::MotionEvent::ACTION_POINTER_UP; - break; - case TOUCH_CANCEL: - eventType = sdk::MotionEvent::ACTION_CANCEL; - break; - case TOUCH_HOVER: // not supported for now - default: - return NS_ERROR_UNEXPECTED; - } - - MOZ_ASSERT(mLayerViewSupport); - GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient(); - client->SynthesizeNativeTouchPoint(aPointerId, eventType, - aPoint.x, aPoint.y, aPointerPressure, aPointerOrientation); - - return NS_OK; -} - -nsresult -nsWindow::SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - uint32_t aModifierFlags, - nsIObserver* aObserver) -{ - mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent"); - - MOZ_ASSERT(mLayerViewSupport); - GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient(); - client->SynthesizeNativeMouseEvent(aNativeMessage, aPoint.x, aPoint.y); - - return NS_OK; -} - -nsresult -nsWindow::SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint, - nsIObserver* aObserver) -{ - mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent"); - - MOZ_ASSERT(mLayerViewSupport); - GeckoLayerClient::LocalRef client = mLayerViewSupport->GetLayerClient(); - client->SynthesizeNativeMouseEvent(sdk::MotionEvent::ACTION_HOVER_MOVE, aPoint.x, aPoint.y); - - return NS_OK; -} - -bool -nsWindow::PreRender(WidgetRenderingContext* aContext) -{ - if (Destroyed()) { - return true; - } - - layers::Compositor* compositor = aContext->mCompositor; - - GeckoLayerClient::LocalRef client; - - if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) { - client = lvs->GetLayerClient(); - } - - if (compositor && client) { - // Android Color is ARGB which is apparently unusual. - compositor->SetDefaultClearColor(gfx::Color::UnusualFromARGB((uint32_t)client->ClearColor())); - } - - return true; -} -void -nsWindow::DrawWindowUnderlay(WidgetRenderingContext* aContext, - LayoutDeviceIntRect aRect) -{ - if (Destroyed()) { - return; - } - - GeckoLayerClient::LocalRef client; - - if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) { - client = lvs->GetLayerClient(); - } - - if (!client) { - return; - } - - LayerRenderer::Frame::LocalRef frame = client->CreateFrame(); - mLayerRendererFrame = frame; - if (NS_WARN_IF(!mLayerRendererFrame)) { - return; - } - - if (!WidgetPaintsBackground()) { - return; - } - - frame->BeginDrawing(); -} - -void -nsWindow::DrawWindowOverlay(WidgetRenderingContext* aContext, - LayoutDeviceIntRect aRect) -{ - PROFILER_LABEL("nsWindow", "DrawWindowOverlay", - js::ProfileEntry::Category::GRAPHICS); - - if (Destroyed() || NS_WARN_IF(!mLayerRendererFrame)) { - return; - } - - mLayerRendererFrame->EndDrawing(); - mLayerRendererFrame = nullptr; -} - -bool -nsWindow::WidgetPaintsBackground() -{ - static bool sWidgetPaintsBackground = true; - static bool sWidgetPaintsBackgroundPrefCached = false; - - if (!sWidgetPaintsBackgroundPrefCached) { - sWidgetPaintsBackgroundPrefCached = true; - mozilla::Preferences::AddBoolVarCache(&sWidgetPaintsBackground, - "android.widget_paints_background", - true); - } - - return sWidgetPaintsBackground; -} - -bool -nsWindow::NeedsPaint() -{ - if (!mLayerViewSupport || mLayerViewSupport->CompositorPaused() || - // FindTopLevel() != nsWindow::TopWindow() || - !GetLayerManager(nullptr)) { - return false; - } - return nsIWidget::NeedsPaint(); -} - -void -nsWindow::ConfigureAPZControllerThread() -{ - APZThreadUtils::SetControllerThread(nullptr); -} - -already_AddRefed<GeckoContentController> -nsWindow::CreateRootContentController() -{ - RefPtr<GeckoContentController> controller = new AndroidContentController(this, mAPZEventState, mAPZC); - return controller.forget(); -} - -uint32_t -nsWindow::GetMaxTouchPoints() const -{ - return GeckoAppShell::GetMaxTouchPoints(); -} - -void -nsWindow::UpdateZoomConstraints(const uint32_t& aPresShellId, - const FrameMetrics::ViewID& aViewId, - const mozilla::Maybe<ZoomConstraints>& aConstraints) -{ - nsBaseWidget::UpdateZoomConstraints(aPresShellId, aViewId, aConstraints); -} - -CompositorBridgeParent* -nsWindow::GetCompositorBridgeParent() const -{ - return mCompositorSession ? mCompositorSession->GetInProcessBridge() : nullptr; -} - -already_AddRefed<nsIScreen> -nsWindow::GetWidgetScreen() -{ - nsCOMPtr<nsIScreenManager> screenMgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - MOZ_ASSERT(screenMgr, "Failed to get nsIScreenManager"); - - nsCOMPtr<nsIScreen> screen; - screenMgr->ScreenForId(mScreenId, getter_AddRefs(screen)); - - return screen.forget(); -} - -jni::DependentRef<java::GeckoLayerClient> -nsWindow::GetLayerClient() -{ - if (NativePtr<LayerViewSupport>::Locked lvs{mLayerViewSupport}) { - return lvs->GetLayerClient().Get(); - } - return nullptr; -} diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h deleted file mode 100644 index f3d7566f7..000000000 --- a/widget/android/nsWindow.h +++ /dev/null @@ -1,289 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * vim: set sw=4 ts=4 expandtab: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NSWINDOW_H_ -#define NSWINDOW_H_ - -#include "nsBaseWidget.h" -#include "gfxPoint.h" -#include "nsIIdleServiceInternal.h" -#include "nsTArray.h" -#include "AndroidJavaWrappers.h" -#include "GeneratedJNIWrappers.h" -#include "mozilla/EventForwards.h" -#include "mozilla/Mutex.h" -#include "mozilla/StaticPtr.h" -#include "mozilla/TextRange.h" -#include "mozilla/UniquePtr.h" - -struct ANPEvent; - -namespace mozilla { - class TextComposition; - class WidgetTouchEvent; - - namespace layers { - class CompositorBridgeParent; - class CompositorBridgeChild; - class LayerManager; - class APZCTreeManager; - } -} - -class nsWindow : public nsBaseWidget -{ -private: - virtual ~nsWindow(); - -public: - using nsBaseWidget::GetLayerManager; - - nsWindow(); - - NS_DECL_ISUPPORTS_INHERITED - - static void InitNatives(); - void SetScreenId(uint32_t aScreenId) { mScreenId = aScreenId; } - -private: - uint32_t mScreenId; - - // An Event subclass that guards against stale events. - template<typename Lambda, - bool IsStatic = Lambda::isStatic, - typename InstanceType = typename Lambda::ThisArgType, - class Impl = typename Lambda::TargetClass> - class WindowEvent; - - // Smart pointer for holding a pointer back to the nsWindow inside a native - // object class. The nsWindow pointer is automatically cleared when the - // nsWindow is destroyed, and a WindowPtr<Impl>::Locked class is provided - // for thread-safe access to the nsWindow pointer off of the Gecko thread. - template<class Impl> class WindowPtr; - - // Smart pointer for holding a pointer to a native object class. The - // pointer is automatically cleared when the object is destroyed. - template<class Impl> - class NativePtr final - { - friend WindowPtr<Impl>; - - static const char sName[]; - - WindowPtr<Impl>* mPtr; - Impl* mImpl; - mozilla::Mutex mImplLock; - - public: - class Locked; - - NativePtr() : mPtr(nullptr), mImpl(nullptr), mImplLock(sName) {} - ~NativePtr() { MOZ_ASSERT(!mPtr); } - - operator Impl*() const - { - MOZ_ASSERT(NS_IsMainThread()); - return mImpl; - } - - Impl* operator->() const { return operator Impl*(); } - - template<class Instance, typename... Args> - void Attach(Instance aInstance, nsWindow* aWindow, Args&&... aArgs); - void Detach(); - }; - - class LayerViewSupport; - // Object that implements native LayerView calls. - // Owned by the Java LayerView instance. - NativePtr<LayerViewSupport> mLayerViewSupport; - - class NPZCSupport; - // Object that implements native NativePanZoomController calls. - // Owned by the Java NativePanZoomController instance. - NativePtr<NPZCSupport> mNPZCSupport; - - class GeckoViewSupport; - // Object that implements native GeckoView calls and associated states. - // nullptr for nsWindows that were not opened from GeckoView. - // Because other objects get destroyed in the mGeckOViewSupport destructor, - // keep it last in the list, so its destructor is called first. - mozilla::UniquePtr<GeckoViewSupport> mGeckoViewSupport; - - // Class that implements native PresentationMediaPlayerManager calls. - class PMPMSupport; - -public: - static nsWindow* TopWindow(); - - void OnSizeChanged(const mozilla::gfx::IntSize& aSize); - - void InitEvent(mozilla::WidgetGUIEvent& event, - LayoutDeviceIntPoint* aPoint = 0); - - void UpdateOverscrollVelocity(const float aX, const float aY); - void UpdateOverscrollOffset(const float aX, const float aY); - void SetScrollingRootContent(const bool isRootContent); - - // - // nsIWidget - // - - using nsBaseWidget::Create; // for Create signature not overridden here - virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const LayoutDeviceIntRect& aRect, - nsWidgetInitData* aInitData) override; - virtual void Destroy() override; - NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&) override; - NS_IMETHOD SetParent(nsIWidget* aNewParent) override; - virtual nsIWidget *GetParent(void) override; - virtual float GetDPI() override; - virtual double GetDefaultScaleInternal() override; - NS_IMETHOD Show(bool aState) override; - virtual bool IsVisible() const override; - virtual void ConstrainPosition(bool aAllowSlop, - int32_t *aX, - int32_t *aY) override; - NS_IMETHOD Move(double aX, - double aY) override; - NS_IMETHOD Resize(double aWidth, - double aHeight, - bool aRepaint) override; - NS_IMETHOD Resize(double aX, - double aY, - double aWidth, - double aHeight, - bool aRepaint) override; - void SetZIndex(int32_t aZIndex) override; - virtual void SetSizeMode(nsSizeMode aMode) override; - NS_IMETHOD Enable(bool aState) override; - virtual bool IsEnabled() const override; - NS_IMETHOD Invalidate(const LayoutDeviceIntRect& aRect) override; - NS_IMETHOD SetFocus(bool aRaise = false) override; - virtual LayoutDeviceIntRect GetScreenBounds() override; - virtual LayoutDeviceIntPoint WidgetToScreenOffset() override; - NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus) override; - nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent); - virtual already_AddRefed<nsIScreen> GetWidgetScreen() override; - virtual nsresult MakeFullScreen(bool aFullScreen, - nsIScreen* aTargetScreen = nullptr) - override; - - NS_IMETHOD SetCursor(nsCursor aCursor) override { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetCursor(imgIContainer* aCursor, - uint32_t aHotspotX, - uint32_t aHotspotY) override { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetHasTransparentBackground(bool aTransparent) { return NS_OK; } - NS_IMETHOD GetHasTransparentBackground(bool& aTransparent) { aTransparent = false; return NS_OK; } - NS_IMETHOD HideWindowChrome(bool aShouldHide) override { return NS_ERROR_NOT_IMPLEMENTED; } - void* GetNativeData(uint32_t aDataType) override; - void SetNativeData(uint32_t aDataType, uintptr_t aVal) override; - NS_IMETHOD SetTitle(const nsAString& aTitle) override { return NS_OK; } - NS_IMETHOD SetIcon(const nsAString& aIconSpec) override { return NS_OK; } - NS_IMETHOD GetAttention(int32_t aCycleCount) override { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, - int32_t aHorizontal, - int32_t aVertical) override - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, - const InputContextAction& aAction) override; - NS_IMETHOD_(InputContext) GetInputContext() override; - virtual nsIMEUpdatePreference GetIMEUpdatePreference() override; - - void SetSelectionDragState(bool aState); - LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr, - LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, - LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override; - - virtual bool NeedsPaint() override; - virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override; - virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext, - LayoutDeviceIntRect aRect) override; - virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext, - LayoutDeviceIntRect aRect) override; - - virtual bool WidgetPaintsBackground() override; - - virtual uint32_t GetMaxTouchPoints() const override; - - void UpdateZoomConstraints(const uint32_t& aPresShellId, - const FrameMetrics::ViewID& aViewId, - const mozilla::Maybe<ZoomConstraints>& aConstraints) override; - - nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId, - TouchPointerState aPointerState, - LayoutDeviceIntPoint aPoint, - double aPointerPressure, - uint32_t aPointerOrientation, - nsIObserver* aObserver) override; - nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint, - uint32_t aNativeMessage, - uint32_t aModifierFlags, - nsIObserver* aObserver) override; - nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint, - nsIObserver* aObserver) override; - - CompositorBridgeParent* GetCompositorBridgeParent() const; - - mozilla::jni::DependentRef<mozilla::java::GeckoLayerClient> GetLayerClient(); - -protected: - void BringToFront(); - nsWindow *FindTopLevel(); - bool IsTopLevel(); - - RefPtr<mozilla::TextComposition> GetIMEComposition(); - enum RemoveIMECompositionFlag { - CANCEL_IME_COMPOSITION, - COMMIT_IME_COMPOSITION - }; - void RemoveIMEComposition(RemoveIMECompositionFlag aFlag = COMMIT_IME_COMPOSITION); - - void ConfigureAPZControllerThread() override; - void DispatchHitTest(const mozilla::WidgetTouchEvent& aEvent); - - already_AddRefed<GeckoContentController> CreateRootContentController() override; - - // Call this function when the users activity is the direct cause of an - // event (like a keypress or mouse click). - void UserActivity(); - - bool mIsVisible; - nsTArray<nsWindow*> mChildren; - nsWindow* mParent; - - double mStartDist; - double mLastDist; - - nsCOMPtr<nsIIdleServiceInternal> mIdleService; - - bool mAwaitingFullScreen; - bool mIsFullScreen; - - virtual nsresult NotifyIMEInternal( - const IMENotification& aIMENotification) override; - - bool UseExternalCompositingSurface() const override { - return true; - } - - static void DumpWindows(); - static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0); - static void LogWindow(nsWindow *win, int index, int indent); - -private: - void CreateLayerManager(int aCompositorWidth, int aCompositorHeight); - void RedrawAll(); - - mozilla::java::LayerRenderer::Frame::GlobalRef mLayerRendererFrame; -}; - -#endif /* NSWINDOW_H_ */ diff --git a/widget/moz.build b/widget/moz.build index b156346eb..3ca4c9785 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -6,9 +6,10 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit in ('cocoa', 'android', 'uikit'): +if toolkit in ('cocoa', 'uikit'): DIRS += [toolkit] -if toolkit in ('android', 'gtk2', 'gtk3'): + +if toolkit in ('gtk2', 'gtk3'): EXPORTS += ['nsIPrintDialogService.h'] if toolkit == 'windows': @@ -41,8 +42,6 @@ elif toolkit == 'cocoa': 'nsIPrintDialogService.h', ] -TEST_DIRS += ['tests'] - # Don't build the DSO under the 'build' directory as windows does. # # The DSOs get built in the toolkit dir itself. Do this so that @@ -221,20 +220,14 @@ if toolkit in ('cocoa', 'windows'): 'nsBaseClipboard.cpp', ] -if toolkit in {'gtk2', 'gtk3', 'cocoa', 'windows', - 'android', 'uikit'}: - UNIFIED_SOURCES += [ - 'nsBaseFilePicker.cpp', - ] +if toolkit in {'gtk2', 'gtk3', 'cocoa', 'windows', 'uikit'}: + UNIFIED_SOURCES += ['nsBaseFilePicker.cpp'] if toolkit in ('gtk2', 'gtk3', 'windows', 'cocoa'): - UNIFIED_SOURCES += [ - 'nsNativeTheme.cpp', - ] + UNIFIED_SOURCES += ['nsNativeTheme.cpp'] + if toolkit == 'gtk3': - XPIDL_SOURCES += [ - 'nsIApplicationChooser.idl', - ] + XPIDL_SOURCES += ['nsIApplicationChooser.idl'] DEFINES['MOZ_CROSS_PROCESS_IME'] = True diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 2d14cc107..8e28c24da 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -134,11 +134,6 @@ typedef void* nsNativeWidget; #define NS_NATIVE_COMPOSITOR_DISPLAY 105 #endif // MOZ_X11 #endif -#ifdef MOZ_WIDGET_ANDROID -#define NS_JAVA_SURFACE 100 -#define NS_PRESENTATION_WINDOW 101 -#define NS_PRESENTATION_SURFACE 102 -#endif #define NS_IWIDGET_IID \ { 0x06396bf6, 0x2dd8, 0x45e5, \ diff --git a/widget/nsIdleService.cpp b/widget/nsIdleService.cpp index f9904d39c..5750a2754 100644 --- a/widget/nsIdleService.cpp +++ b/widget/nsIdleService.cpp @@ -21,10 +21,6 @@ #include "mozilla/Telemetry.h" #include <algorithm> -#ifdef MOZ_WIDGET_ANDROID -#include <android/log.h> -#endif - using namespace mozilla; // interval in milliseconds between internal idle time requests. @@ -53,7 +49,6 @@ using namespace mozilla; static PRLogModuleInfo *sLog = nullptr; #define LOG_TAG "GeckoIdleService" -#define LOG_LEVEL ANDROID_LOG_DEBUG // Use this to find previously added observers in our array: class IdleListenerComparator @@ -98,10 +93,6 @@ nsIdleServiceDaily::Observe(nsISupports *, MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: Notifying idle-daily observers")); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Notifying idle-daily observers"); -#endif // Send the idle-daily observer event nsCOMPtr<nsIObserverService> observerService = @@ -134,10 +125,6 @@ nsIdleServiceDaily::Observe(nsISupports *, MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: Storing last idle time as %d sec.", nowSec)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Storing last idle time as %d", nowSec); -#endif // Note the moment we expect to get the next timer callback mExpectedTriggerTime = PR_Now() + ((PRTime)SECONDS_PER_DAY * @@ -202,10 +189,6 @@ nsIdleServiceDaily::Init() } else { MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: Setting timer a day from now")); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Setting timer a day from now"); -#endif // According to our last idle-daily pref, the last idle-daily was fired // less then 24 hours ago. Set a wait for the amount of time remaining. @@ -255,10 +238,7 @@ nsIdleServiceDaily::StageIdleDaily(bool aHasBeenLongWait) MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: Registering Idle observer callback " "(short wait requested? %d)", aHasBeenLongWait)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Registering Idle observer callback"); -#endif + mIdleDailyTriggerWait = (aHasBeenLongWait ? DAILY_SHORTENED_IDLE_SERVICE_SEC : DAILY_SIGNIFICANT_IDLE_SERVICE_SEC); @@ -271,15 +251,10 @@ nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) { MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: DailyCallback running")); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "DailyCallback running"); -#endif nsIdleServiceDaily* self = static_cast<nsIdleServiceDaily*>(aClosure); - // Check to be sure the timer didn't fire early. This currently only - // happens on android. + // Check to be sure the timer didn't fire early. PRTime now = PR_Now(); if (self->mExpectedTriggerTime && now < self->mExpectedTriggerTime) { // Timer returned early, reschedule to the appropriate time. @@ -290,11 +265,6 @@ nsIdleServiceDaily::DailyCallback(nsITimer* aTimer, void* aClosure) MOZ_LOG(sLog, LogLevel::Debug, ("nsIdleServiceDaily: DailyCallback resetting timer to %lld msec", delayTime / PR_USEC_PER_MSEC)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "DailyCallback resetting timer to %lld msec", - delayTime / PR_USEC_PER_MSEC); -#endif (void)self->mTimer->InitWithFuncCallback(DailyCallback, self, @@ -438,11 +408,6 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Register idle observer %p for %d seconds", aObserver, aIdleTimeInS)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Register idle observer %p for %d seconds", - aObserver, aIdleTimeInS); -#endif // Put the time + observer in a struct we can keep: IdleListener listener(aObserver, aIdleTimeInS); @@ -466,11 +431,6 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Register: adjusting next switch from %d to %d seconds", mDeltaToNextIdleSwitchInS, aIdleTimeInS)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Register: adjusting next switch from %d to %d seconds", - mDeltaToNextIdleSwitchInS, aIdleTimeInS); -#endif mDeltaToNextIdleSwitchInS = aIdleTimeInS; } @@ -508,11 +468,7 @@ nsIdleService::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aTimeInS) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Remove observer %p (%d seconds), %d remain idle", aObserver, aTimeInS, mIdleObserverCount)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Remove observer %p (%d seconds), %d remain idle", - aObserver, aTimeInS, mIdleObserverCount); -#endif + return NS_OK; } @@ -520,11 +476,7 @@ nsIdleService::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aTimeInS) MOZ_LOG(sLog, LogLevel::Warning, ("idleService: Failed to remove idle observer %p (%d seconds)", aObserver, aTimeInS)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Failed to remove idle observer %p (%d seconds)", - aObserver, aTimeInS); -#endif + return NS_ERROR_FAILURE; } @@ -591,11 +543,7 @@ nsIdleService::ResetIdleTimeOut(uint32_t idleDeltaInMS) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Reset idle timeout: tell observer %p user is back", notifyList[numberOfPendingNotifications])); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Reset idle timeout: tell observer %p user is back", - notifyList[numberOfPendingNotifications]); -#endif + notifyList[numberOfPendingNotifications]->Observe(this, OBSERVER_TOPIC_ACTIVE, timeStr.get()); @@ -627,11 +575,6 @@ nsIdleService::GetIdleTime(uint32_t* idleTime) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Get idle time: time since reset %u msec", timeSinceResetInMS)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Get idle time: time since reset %u msec", - timeSinceResetInMS); -#endif // If we did't get pulled data, return the time since last idle reset. if (!polledIdleTimeIsValid) { @@ -682,21 +625,13 @@ nsIdleService::IdleTimerCallback(void) if (NS_FAILED(GetIdleTime(¤tIdleTimeInMS))) { MOZ_LOG(sLog, LogLevel::Info, ("idleService: Idle timer callback: failed to get idle time")); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Idle timer callback: failed to get idle time"); -#endif + return; } MOZ_LOG(sLog, LogLevel::Debug, ("idleService: Idle timer callback: current idle time %u msec", currentIdleTimeInMS)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Idle timer callback: current idle time %u msec", - currentIdleTimeInMS); -#endif // Check if we have had some user interaction we didn't handle previously // we do the calculation in ms to lessen the chance for rounding errors to @@ -770,11 +705,7 @@ nsIdleService::IdleTimerCallback(void) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: **** Idle timer callback: tell observer %p user is idle", notifyList[numberOfPendingNotifications])); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "Idle timer callback: tell observer %p user is idle", - notifyList[numberOfPendingNotifications]); -#endif + notifyList[numberOfPendingNotifications]->Observe(this, OBSERVER_TOPIC_IDLE, timeStr.get()); @@ -790,12 +721,6 @@ nsIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) ("idleService: SetTimerExpiryIfBefore: next timeout %0.f msec from now", nextTimeoutDuration.ToMilliseconds())); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "SetTimerExpiryIfBefore: next timeout %0.f msec from now", - nextTimeoutDuration.ToMilliseconds()); -#endif - // Bail if we don't have a timer service. if (!mTimer) { return; @@ -824,11 +749,6 @@ nsIdleService::SetTimerExpiryIfBefore(TimeStamp aNextTimeout) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: IdleService reset timer expiry to %0.f msec from now", deltaTime.ToMilliseconds())); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "reset timer expiry to %0.f msec from now", - deltaTime.ToMilliseconds()); -#endif // Start the timer mTimer->InitWithFuncCallback(StaticIdleTimerCallback, @@ -848,10 +768,7 @@ nsIdleService::ReconfigureTimer(void) // And bail out. MOZ_LOG(sLog, LogLevel::Debug, ("idleService: ReconfigureTimer: no idle or waiting observers")); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "ReconfigureTimer: no idle or waiting observers"); -#endif + return; } @@ -870,12 +787,6 @@ nsIdleService::ReconfigureTimer(void) ("idleService: next timeout %0.f msec from now", nextTimeoutDuration.ToMilliseconds())); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "next timeout %0.f msec from now", - nextTimeoutDuration.ToMilliseconds()); -#endif - // Check if we should correct the timeout time because we should poll before. if ((mIdleObserverCount > 0) && UsePollMode()) { TimeStamp pollTimeout = @@ -885,11 +796,7 @@ nsIdleService::ReconfigureTimer(void) MOZ_LOG(sLog, LogLevel::Debug, ("idleService: idle observers, reducing timeout to %lu msec from now", MIN_IDLE_POLL_INTERVAL_MSEC)); -#ifdef MOZ_WIDGET_ANDROID - __android_log_print(LOG_LEVEL, LOG_TAG, - "idle observers, reducing timeout to %lu msec from now", - MIN_IDLE_POLL_INTERVAL_MSEC); -#endif + nextTimeoutAt = pollTimeout; } } diff --git a/widget/tests/TestAppShellSteadyState.cpp b/widget/tests/TestAppShellSteadyState.cpp deleted file mode 100644 index 162343e38..000000000 --- a/widget/tests/TestAppShellSteadyState.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -#include "TestHarness.h" - -#include "nsIAppShell.h" -#include "nsIAppShellService.h" -#include "nsIDocument.h" -#include "nsIDOMEvent.h" -#include "nsIDOMEventListener.h" -#include "nsIDOMEventTarget.h" -#include "nsIDOMWindow.h" -#include "nsIDOMWindowUtils.h" -#include "nsIInterfaceRequestor.h" -#include "nsIRunnable.h" -#include "nsIURI.h" -#include "nsIWebBrowserChrome.h" -#include "nsIXULWindow.h" - -#include "nsAppShellCID.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsNetUtil.h" -#include "nsThreadUtils.h" -#include "mozilla/Attributes.h" - -#ifdef XP_WIN -#include <windows.h> -#endif - -using namespace mozilla; - -typedef void (*TestFunc)(nsIAppShell*); - -bool gStableStateEventHasRun = false; - -class ExitAppShellRunnable : public Runnable -{ - nsCOMPtr<nsIAppShell> mAppShell; - -public: - explicit ExitAppShellRunnable(nsIAppShell* aAppShell) - : mAppShell(aAppShell) - { } - - NS_IMETHOD - Run() override - { - return mAppShell->Exit(); - } -}; - -class StableStateRunnable : public Runnable -{ -public: - NS_IMETHOD - Run() override - { - if (gStableStateEventHasRun) { - fail("StableStateRunnable already ran"); - } - gStableStateEventHasRun = true; - return NS_OK; - } -}; - -class CheckStableStateRunnable : public Runnable -{ - bool mShouldHaveRun; - -public: - explicit CheckStableStateRunnable(bool aShouldHaveRun) - : mShouldHaveRun(aShouldHaveRun) - { } - - NS_IMETHOD - Run() override - { - if (mShouldHaveRun == gStableStateEventHasRun) { - passed("StableStateRunnable state correct (%s)", - mShouldHaveRun ? "true" : "false"); - } else { - fail("StableStateRunnable ran at wrong time"); - } - return NS_OK; - } -}; - -class ScheduleStableStateRunnable : public CheckStableStateRunnable -{ -protected: - nsCOMPtr<nsIAppShell> mAppShell; - -public: - explicit ScheduleStableStateRunnable(nsIAppShell* aAppShell) - : CheckStableStateRunnable(false), mAppShell(aAppShell) - { } - - NS_IMETHOD - Run() override - { - CheckStableStateRunnable::Run(); - - nsCOMPtr<nsIRunnable> runnable = new StableStateRunnable(); - nsresult rv = mAppShell->RunBeforeNextEvent(runnable); - if (NS_FAILED(rv)) { - fail("RunBeforeNextEvent returned failure code %u", rv); - } - - return rv; - } -}; - -class NextTestRunnable : public Runnable -{ - nsCOMPtr<nsIAppShell> mAppShell; - -public: - explicit NextTestRunnable(nsIAppShell* aAppShell) - : mAppShell(aAppShell) - { } - - NS_IMETHOD Run(); -}; - -class ScheduleNestedStableStateRunnable : public ScheduleStableStateRunnable -{ -public: - explicit ScheduleNestedStableStateRunnable(nsIAppShell* aAppShell) - : ScheduleStableStateRunnable(aAppShell) - { } - - NS_IMETHOD - Run() override - { - ScheduleStableStateRunnable::Run(); - - nsCOMPtr<nsIRunnable> runnable = new CheckStableStateRunnable(false); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch check runnable"); - } - - if (NS_FAILED(NS_ProcessPendingEvents(nullptr))) { - fail("Failed to process all pending events"); - } - - runnable = new CheckStableStateRunnable(true); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch check runnable"); - } - - runnable = new NextTestRunnable(mAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } - - return NS_OK; - } -}; - -class EventListener final : public nsIDOMEventListener -{ - nsCOMPtr<nsIAppShell> mAppShell; - - static nsIDOMWindowUtils* sWindowUtils; - static nsIAppShell* sAppShell; - - ~EventListener() {} - -public: - NS_DECL_ISUPPORTS - - explicit EventListener(nsIAppShell* aAppShell) - : mAppShell(aAppShell) - { } - - NS_IMETHOD - HandleEvent(nsIDOMEvent* aEvent) override - { - nsString type; - if (NS_FAILED(aEvent->GetType(type))) { - fail("Failed to get event type"); - return NS_ERROR_FAILURE; - } - - if (type.EqualsLiteral("load")) { - passed("Got load event"); - - nsCOMPtr<nsIDOMEventTarget> target; - if (NS_FAILED(aEvent->GetTarget(getter_AddRefs(target)))) { - fail("Failed to get event type"); - return NS_ERROR_FAILURE; - } - - nsCOMPtr<nsIDocument> document = do_QueryInterface(target); - if (!document) { - fail("Failed to QI to nsIDocument!"); - return NS_ERROR_FAILURE; - } - - nsCOMPtr<nsPIDOMWindow> window = document->GetWindow(); - if (!window) { - fail("Failed to get window from document!"); - return NS_ERROR_FAILURE; - } - - nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window); - if (!utils) { - fail("Failed to get DOMWindowUtils!"); - return NS_ERROR_FAILURE; - } - - if (!ScheduleTimer(utils)) { - return NS_ERROR_FAILURE; - } - - return NS_OK; - } - - if (type.EqualsLiteral("keypress")) { - passed("Got keypress event"); - - nsCOMPtr<nsIRunnable> runnable = new StableStateRunnable(); - nsresult rv = mAppShell->RunBeforeNextEvent(runnable); - if (NS_FAILED(rv)) { - fail("RunBeforeNextEvent returned failure code %u", rv); - return NS_ERROR_FAILURE; - } - - return NS_OK; - } - - fail("Got an unexpected event: %s", NS_ConvertUTF16toUTF8(type).get()); - return NS_OK; - } - -#ifdef XP_WIN - static VOID CALLBACK - TimerCallback(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime) - { - if (sWindowUtils) { - nsCOMPtr<nsIDOMWindowUtils> utils = dont_AddRef(sWindowUtils); - sWindowUtils = nullptr; - - if (gStableStateEventHasRun) { - fail("StableStateRunnable ran at wrong time"); - } else { - passed("StableStateRunnable state correct (false)"); - } - - int32_t layout = 0x409; // US - int32_t keyCode = 0x41; // VK_A - NS_NAMED_LITERAL_STRING(a, "a"); - - if (NS_FAILED(utils->SendNativeKeyEvent(layout, keyCode, 0, a, a, nullptr))) { - fail("Failed to synthesize native event"); - } - - return; - } - - KillTimer(nullptr, idEvent); - - nsCOMPtr<nsIAppShell> appShell = dont_AddRef(sAppShell); - - if (!gStableStateEventHasRun) { - fail("StableStateRunnable didn't run yet"); - } else { - passed("StableStateRunnable state correct (true)"); - } - - nsCOMPtr<nsIRunnable> runnable = new NextTestRunnable(appShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } - - } -#endif - - bool - ScheduleTimer(nsIDOMWindowUtils* aWindowUtils) - { -#ifdef XP_WIN - UINT_PTR timerId = SetTimer(nullptr, 0, 1000, (TIMERPROC)TimerCallback); - if (!timerId) { - fail("SetTimer failed!"); - return false; - } - - nsCOMPtr<nsIDOMWindowUtils> utils = aWindowUtils; - utils.forget(&sWindowUtils); - - nsCOMPtr<nsIAppShell> appShell = mAppShell; - appShell.forget(&sAppShell); - - return true; -#else - return false; -#endif - } -}; - -nsIDOMWindowUtils* EventListener::sWindowUtils = nullptr; -nsIAppShell* EventListener::sAppShell = nullptr; - -NS_IMPL_ISUPPORTS(EventListener, nsIDOMEventListener) - -already_AddRefed<nsIAppShell> -GetAppShell() -{ - static const char* platforms[] = { - "android", "mac", "gtk", "qt", "win" - }; - - NS_NAMED_LITERAL_CSTRING(contractPrefix, "@mozilla.org/widget/appshell/"); - NS_NAMED_LITERAL_CSTRING(contractSuffix, ";1"); - - for (size_t index = 0; index < ArrayLength(platforms); index++) { - nsAutoCString contractID(contractPrefix); - contractID.AppendASCII(platforms[index]); - contractID.Append(contractSuffix); - - nsCOMPtr<nsIAppShell> appShell = do_GetService(contractID.get()); - if (appShell) { - return appShell.forget(); - } - } - - return nullptr; -} - -void -Test1(nsIAppShell* aAppShell) -{ - // Schedule stable state runnable to be run before next event. - - nsCOMPtr<nsIRunnable> runnable = new StableStateRunnable(); - if (NS_FAILED(aAppShell->RunBeforeNextEvent(runnable))) { - fail("RunBeforeNextEvent failed"); - } - - runnable = new CheckStableStateRunnable(true); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch check runnable"); - } - - runnable = new NextTestRunnable(aAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } -} - -void -Test2(nsIAppShell* aAppShell) -{ - // Schedule stable state runnable to be run before next event from another - // runnable. - - nsCOMPtr<nsIRunnable> runnable = new ScheduleStableStateRunnable(aAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch schedule runnable"); - } - - runnable = new CheckStableStateRunnable(true); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch check runnable"); - } - - runnable = new NextTestRunnable(aAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } -} - -void -Test3(nsIAppShell* aAppShell) -{ - // Schedule steadystate runnable to be run before next event with nested loop. - - nsCOMPtr<nsIRunnable> runnable = - new ScheduleNestedStableStateRunnable(aAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch schedule runnable"); - } -} - -bool -Test4Internal(nsIAppShell* aAppShell) -{ -#ifndef XP_WIN - // Not sure how to test on other platforms. - return false; -#else - nsCOMPtr<nsIAppShellService> appService = - do_GetService(NS_APPSHELLSERVICE_CONTRACTID); - if (!appService) { - fail("Failed to get appshell service!"); - return false; - } - - nsCOMPtr<nsIURI> uri; - if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), "about:", nullptr))) { - fail("Failed to create new uri"); - return false; - } - - uint32_t flags = nsIWebBrowserChrome::CHROME_DEFAULT; - - nsCOMPtr<nsIXULWindow> xulWindow; - if (NS_FAILED(appService->CreateTopLevelWindow(nullptr, uri, flags, 100, 100, nullptr, - getter_AddRefs(xulWindow)))) { - fail("Failed to create new window"); - return false; - } - - nsCOMPtr<nsIDOMWindow> window = do_GetInterface(xulWindow); - if (!window) { - fail("Can't get dom window!"); - return false; - } - - nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(window); - if (!target) { - fail("Can't QI to nsIDOMEventTarget!"); - return false; - } - - nsCOMPtr<nsIDOMEventListener> listener = new EventListener(aAppShell); - if (NS_FAILED(target->AddEventListener(NS_LITERAL_STRING("keypress"), - listener, false, false)) || - NS_FAILED(target->AddEventListener(NS_LITERAL_STRING("load"), listener, - false, false))) { - fail("Can't add event listeners!"); - return false; - } - - return true; -#endif -} - -void -Test4(nsIAppShell* aAppShell) -{ - if (!Test4Internal(aAppShell)) { - nsCOMPtr<nsIRunnable> runnable = new NextTestRunnable(aAppShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } - } -} - -const TestFunc gTests[] = { - Test1, Test2, Test3, Test4 -}; - -size_t gTestIndex = 0; - -NS_IMETHODIMP -NextTestRunnable::Run() -{ - if (gTestIndex > 0) { - passed("Finished test %u", gTestIndex); - } - - gStableStateEventHasRun = false; - - if (gTestIndex < ArrayLength(gTests)) { - gTests[gTestIndex++](mAppShell); - } - else { - nsCOMPtr<nsIRunnable> exitRunnable = new ExitAppShellRunnable(mAppShell); - - nsresult rv = NS_DispatchToCurrentThread(exitRunnable); - if (NS_FAILED(rv)) { - fail("Failed to dispatch exit runnable!"); - } - } - - return NS_OK; -} - -int main(int argc, char** argv) -{ - ScopedLogging log; - ScopedXPCOM xpcom("TestAppShellSteadyState"); - - if (!xpcom.failed()) { - nsCOMPtr<nsIAppShell> appShell = GetAppShell(); - if (!appShell) { - fail("Couldn't get appshell!"); - } else { - nsCOMPtr<nsIRunnable> runnable = new NextTestRunnable(appShell); - if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) { - fail("Failed to dispatch next test runnable"); - } else if (NS_FAILED(appShell->Run())) { - fail("Failed to run appshell"); - } - } - } - - return gFailCount != 0; -} diff --git a/widget/tests/TestChromeMargin.cpp b/widget/tests/TestChromeMargin.cpp deleted file mode 100644 index 22330f467..000000000 --- a/widget/tests/TestChromeMargin.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* This tests the margin parsing functionality in nsAttrValue.cpp, which - * is accessible via nsContentUtils, and is used in setting chromemargins - * to widget windows. It's located here due to linking issues in the - * content directory. - */ - -/* This test no longer compiles now that we've removed nsIContentUtils (bug - * 647273). We need to be internal code in order to include nsContentUtils.h, - * but defining MOZILLA_INTERNAL_API is not enough to make us internal. - */ - -#include "TestHarness.h" - -#ifndef MOZILLA_INTERNAL_API -// some of the includes make use of internal string types -#define nsAString_h___ -#define nsString_h___ -#define nsStringFwd_h___ -#define nsReadableUtils_h___ -class nsACString; -class nsAString; -class nsAFlatString; -class nsAFlatCString; -class nsAdoptingString; -class nsAdoptingCString; -class nsXPIDLString; -template<class T> class nsReadingIterator; -#endif - -#include "nscore.h" -#include "nsContentUtils.h" - -#ifndef MOZILLA_INTERNAL_API -#undef nsString_h___ -#undef nsAString_h___ -#undef nsReadableUtils_h___ -#endif - -struct DATA { - bool shouldfail; - const char* margins; - int top; - int right; - int bottom; - int left; -}; - -const bool SHOULD_FAIL = true; -const int SHOULD_PASS = false; - -const DATA Data[] = { - { SHOULD_FAIL, "", 1, 2, 3, 4 }, - { SHOULD_FAIL, "1,0,0,0", 1, 2, 3, 4 }, - { SHOULD_FAIL, "1,2,0,0", 1, 2, 3, 4 }, - { SHOULD_FAIL, "1,2,3,0", 1, 2, 3, 4 }, - { SHOULD_FAIL, "4,3,2,1", 1, 2, 3, 4 }, - { SHOULD_FAIL, "azsasdasd", 0, 0, 0, 0 }, - { SHOULD_FAIL, ",azsasdasd", 0, 0, 0, 0 }, - { SHOULD_FAIL, " ", 1, 2, 3, 4 }, - { SHOULD_FAIL, "azsdfsdfsdfsdfsdfsasdasd,asdasdasdasdasdasd,asdadasdasd,asdasdasdasd", 0, 0, 0, 0 }, - { SHOULD_FAIL, "as,as,as,as", 0, 0, 0, 0 }, - { SHOULD_FAIL, "0,0,0", 0, 0, 0, 0 }, - { SHOULD_FAIL, "0,0", 0, 0, 0, 0 }, - { SHOULD_FAIL, "4.6,1,1,1", 0, 0, 0, 0 }, - { SHOULD_FAIL, ",,,,", 0, 0, 0, 0 }, - { SHOULD_FAIL, "1, , , ,", 0, 0, 0, 0 }, - { SHOULD_FAIL, "1, , ,", 0, 0, 0, 0 }, - { SHOULD_FAIL, "@!@%^&^*()", 1, 2, 3, 4 }, - { SHOULD_PASS, "4,3,2,1", 4, 3, 2, 1 }, - { SHOULD_PASS, "-4,-3,-2,-1", -4, -3, -2, -1 }, - { SHOULD_PASS, "10000,3,2,1", 10000, 3, 2, 1 }, - { SHOULD_PASS, "4 , 3 , 2 , 1", 4, 3, 2, 1 }, - { SHOULD_PASS, "4, 3 ,2,1", 4, 3, 2, 1 }, - { SHOULD_FAIL, "4,3,2,10000000000000 --", 4, 3, 2, 10000000000000 }, - { SHOULD_PASS, "4,3,2,1000", 4, 3, 2, 1000 }, - { SHOULD_PASS, "2147483647,3,2,1000", 2147483647, 3, 2, 1000 }, - { SHOULD_PASS, "2147483647,2147483647,2147483647,2147483647", 2147483647, 2147483647, 2147483647, 2147483647 }, - { SHOULD_PASS, "-2147483647,3,2,1000", -2147483647, 3, 2, 1000 }, - { SHOULD_FAIL, "2147483648,3,2,1000", 1, 3, 2, 1000 }, - { 0, nullptr, 0, 0, 0, 0 } -}; - -void DoAttrValueTest() -{ - int idx = -1; - bool didFail = false; - while (Data[++idx].margins) { - nsAutoString str; - str.AssignLiteral(Data[idx].margins); - nsIntMargin values(99,99,99,99); - bool result = nsContentUtils::ParseIntMarginValue(str, values); - - // if the parse fails - if (!result) { - if (Data[idx].shouldfail) - continue; - fail(Data[idx].margins); - didFail = true; - printf("*1\n"); - continue; - } - - if (Data[idx].shouldfail) { - if (Data[idx].top == values.top && - Data[idx].right == values.right && - Data[idx].bottom == values.bottom && - Data[idx].left == values.left) { - // not likely - fail(Data[idx].margins); - didFail = true; - printf("*2\n"); - continue; - } - // good failure, parse failed and that's what we expected. - continue; - } -#if 0 - printf("%d==%d %d==%d %d==%d %d==%d\n", - Data[idx].top, values.top, - Data[idx].right, values.right, - Data[idx].bottom, values.bottom, - Data[idx].left, values.left); -#endif - if (Data[idx].top == values.top && - Data[idx].right == values.right && - Data[idx].bottom == values.bottom && - Data[idx].left == values.left) { - // good parse results - continue; - } - else { - fail(Data[idx].margins); - didFail = true; - printf("*3\n"); - continue; - } - } - - if (!didFail) - passed("nsAttrValue margin parsing tests passed."); -} - -int main(int argc, char** argv) -{ - ScopedXPCOM xpcom(""); - if (xpcom.failed()) - return 1; - DoAttrValueTest(); - return 0; -} diff --git a/widget/tests/bug586713_window.xul b/widget/tests/bug586713_window.xul deleted file mode 100644 index 78397afad..000000000 --- a/widget/tests/bug586713_window.xul +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> - -<window id="bug586713_window" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - width="300" - height="300" - onload="onLoad();" - title="Bug 586713 Test"> - - <menubar id="nativemenubar"> - <menu id="foo" label="Foo"> - <menupopup> - <menuitem label="FooItem0"/> - </menupopup> - </menu> - </menubar> - - <script type="application/javascript"><![CDATA[ - function ok(condition, message) { - window.opener.wrappedJSObject.SimpleTest.ok(condition, message); - } - - function onTestsFinished() { - window.close(); - window.opener.wrappedJSObject.SimpleTest.finish(); - } - - var fooCallCount = 0; - function foo() { - fooCallCount++; - let instruction = document.createProcessingInstruction("xml-stylesheet", 'href="chrome://foo.css" type="text/css"'); - document.insertBefore(instruction, document.documentElement); - if (fooCallCount == 2) { - ok(true, "If we got here we didn't crash, excellent."); - onTestsFinished(); - } - } - - function onLoad() { - foo(); - setTimeout(() => foo(), 0); - } - ]]></script> -</window> diff --git a/widget/tests/chrome.ini b/widget/tests/chrome.ini deleted file mode 100644 index 00d0d57a9..000000000 --- a/widget/tests/chrome.ini +++ /dev/null @@ -1,100 +0,0 @@ -[DEFAULT] -skip-if = os == 'android' -support-files = - empty_window.xul - utils.js - -[test_bug343416.xul] -skip-if = debug -[test_bug429954.xul] -support-files = window_bug429954.xul -[test_bug444800.xul] -subsuite = clipboard -[test_bug478536.xul] -skip-if = true # Bug 561929 -support-files = window_bug478536.xul -[test_bug517396.xul] -[test_bug538242.xul] -support-files = window_bug538242.xul -[test_bug593307.xul] -support-files = window_bug593307_offscreen.xul window_bug593307_centerscreen.xul -[test_bug1151186.html] -skip-if = os == 'linux' && debug #Bug 1176038 -[test_keycodes.xul] -[test_wheeltransaction.xul] -support-files = window_wheeltransaction.xul -[test_imestate.html] -support-files = window_imestate_iframes.html -[test_plugin_scroll_consistency.html] -[test_composition_text_querycontent.xul] -support-files = window_composition_text_querycontent.xul -[test_input_events_on_deactive_window.xul] -[test_position_on_resize.xul] -[test_sizemode_events.xul] -[test_taskbar_progress.xul] -skip-if = toolkit != "cocoa" && toolkit != "windows" -[test_bug760802.xul] -[test_clipboard.xul] -subsuite = clipboard -[test_panel_mouse_coords.xul] -skip-if = toolkit == "windows" # bug 1009955 - -# Cocoa -[test_native_menus.xul] -skip-if = toolkit != "cocoa" -support-files = native_menus_window.xul -[test_native_mouse_mac.xul] -skip-if = toolkit != "cocoa" || os_version == '10.10' # 10.10: bug 1137575 -support-files = native_mouse_mac_window.xul -[test_bug413277.html] -skip-if = toolkit != "cocoa" -[test_bug428405.xul] -skip-if = toolkit != "cocoa" -[test_bug466599.xul] -subsuite = clipboard -skip-if = toolkit != "cocoa" -[test_bug485118.xul] -skip-if = toolkit != "cocoa" -[test_bug522217.xul] -tags = fullscreen -skip-if = toolkit != "cocoa" -support-files = window_bug522217.xul -[test_platform_colors.xul] -#skip-if = toolkit != "cocoa" -skip-if = true # Bug 1207190 -[test_standalone_native_menu.xul] -skip-if = toolkit != "cocoa" -support-files = standalone_native_menu_window.xul -[test_bug586713.xul] -skip-if = toolkit != "cocoa" -support-files = bug586713_window.xul -[test_key_event_counts.xul] -skip-if = toolkit != "cocoa" -[test_bug596600.xul] -skip-if = toolkit != "cocoa" -[test_bug673301.xul] -subsuite = clipboard -skip-if = toolkit != "cocoa" -[test_secure_input.html] -skip-if = toolkit != "cocoa" -[test_native_key_bindings_mac.html] -skip-if = toolkit != "cocoa" -[test_system_status_bar.xul] -skip-if = toolkit != "cocoa" - -# Windows -# taskbar_previews.xul -# window_state_windows.xul -[test_chrome_context_menus_win.xul] -skip-if = toolkit != "windows" -support-files = chrome_context_menus_win.xul -[test_plugin_input_event.html] -skip-if = toolkit != "windows" -[test_mouse_scroll.xul] -skip-if = toolkit != "windows" -support-files = window_mouse_scroll_win.html - -# Privacy relevant -[test_bug1123480.xul] -subsuite = clipboard - diff --git a/widget/tests/chrome_context_menus_win.xul b/widget/tests/chrome_context_menus_win.xul deleted file mode 100644 index 9a4590747..000000000 --- a/widget/tests/chrome_context_menus_win.xul +++ /dev/null @@ -1,101 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> - -<window id="ChromeContextMenuTest" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - width="300" - height="300" - title="Chrome Context Menu Test w/Plugin Focus"> - -<script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> -<script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - -<popupset> - <menupopup id="testmenu" onpopupshown="menuDisplayed()"> - <menuitem label="One"/> - <menuitem label="Two"/> - <menuitem label="Three"/> - </menupopup> -</popupset> - -<toolbox> - <toolbar id="nav-toolbar" style="height:30px" context="testmenu"> - </toolbar> -</toolbox> - -<script type="application/javascript"><![CDATA[ - -function ok(condition, message) { - window.opener.wrappedJSObject.SimpleTest.ok(condition, message); -} - -function onTestsFinished() { - window.close(); - window.opener.wrappedJSObject.SimpleTest.finish(); -} - -function openContextMenuFor(element) { - - var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - - var tbX = (window.mozInnerScreenX + 10) * utils.screenPixelsPerCSSPixel; - var tbY = (window.mozInnerScreenY + 10) * utils.screenPixelsPerCSSPixel; - - // See nsWidnow's SynthesizeNativeMouseEvent & SendInput on msdn - var MOUSEEVENTF_RIGHTDOWN = 0x0008; - var MOUSEEVENTF_RIGHTUP = 0x0010; - - utils.sendNativeMouseEvent(tbX, tbY, - MOUSEEVENTF_RIGHTDOWN, - 0, element); - utils.sendNativeMouseEvent(tbX, tbY, - MOUSEEVENTF_RIGHTUP, - 0, element); -} - -var tid = 0; - -function onFocus() { - var _delayedOnLoad = function() { - var plugin = document.getElementById("plugin"); - var toolbar = document.getElementById("nav-toolbar"); - - plugin.focus(); - - tid = setTimeout("menuTimeout()", 5000); - - openContextMenuFor(toolbar); - } - setTimeout(_delayedOnLoad, 3000); -} - -function menuTimeout() { - ok(false, "Right-click chrome menu did not display with focus on a plugin."); - onTestsFinished(); -} - -function menuDisplayed() { - clearTimeout(tid); - ok(true, "Right-click chrome menu displayed despite plugin having focus."); - onTestsFinished(); -} - -window.opener.wrappedJSObject.SimpleTest.waitForFocus(onFocus, window); - - -]]></script> - -<body xmlns="http://www.w3.org/1999/xhtml"> - <br/> - <embed id="plugin" type="application/x-test" width="50" height="50"></embed> -</body> - -</window> diff --git a/widget/tests/empty_window.xul b/widget/tests/empty_window.xul deleted file mode 100644 index f0e01761d..000000000 --- a/widget/tests/empty_window.xul +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Empty window" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/> diff --git a/widget/tests/mochitest.ini b/widget/tests/mochitest.ini deleted file mode 100644 index bf7bfe689..000000000 --- a/widget/tests/mochitest.ini +++ /dev/null @@ -1,12 +0,0 @@ -[DEFAULT] -support-files = utils.js - -[test_assign_event_data.html] -subsuite = clipboard -skip-if = toolkit == "cocoa" # Mac: Bug 933303 -[test_bug565392.html] -subsuite = clipboard -skip-if = toolkit != "windows" || e10s # Bug 1267406 -[test_picker_no_crash.html] -skip-if = toolkit != "windows" || e10s # Bug 1267491 -support-files = window_picker_no_crash_child.html diff --git a/widget/tests/moz.build b/widget/tests/moz.build deleted file mode 100644 index 750202b48..000000000 --- a/widget/tests/moz.build +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] -MOCHITEST_MANIFESTS += ['mochitest.ini'] -MOCHITEST_CHROME_MANIFESTS += ['chrome.ini'] - -# if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': -# -# Test disabled because it requires the internal API. Re-enabling this test -# is bug 652123. -# CPP_UNIT_TESTS += ['TestChromeMargin'] diff --git a/widget/tests/native_menus_window.xul b/widget/tests/native_menus_window.xul deleted file mode 100644 index 6e614d017..000000000 --- a/widget/tests/native_menus_window.xul +++ /dev/null @@ -1,285 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> - -<window id="NativeMenuWindow" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - width="300" - height="300" - onload="onLoad();" - title="Native Menu Test"> - - <command id="cmd_FooItem0" oncommand="executedCommandID = 'cmd_FooItem0';"/> - <command id="cmd_FooItem1" oncommand="executedCommandID = 'cmd_FooItem1';"/> - <command id="cmd_BarItem0" oncommand="executedCommandID = 'cmd_BarItem0';"/> - <command id="cmd_BarItem1" oncommand="executedCommandID = 'cmd_BarItem1';"/> - <command id="cmd_NewItem0" oncommand="executedCommandID = 'cmd_NewItem0';"/> - <command id="cmd_NewItem1" oncommand="executedCommandID = 'cmd_NewItem1';"/> - <command id="cmd_NewItem2" oncommand="executedCommandID = 'cmd_NewItem2';"/> - <command id="cmd_NewItem3" oncommand="executedCommandID = 'cmd_NewItem3';"/> - <command id="cmd_NewItem4" oncommand="executedCommandID = 'cmd_NewItem4';"/> - <command id="cmd_NewItem5" oncommand="executedCommandID = 'cmd_NewItem5';"/> - - <!-- We do not modify any menus or menu items defined here in testing. These - serve as a baseline structure for us to test after other modifications. - We add children to the menubar defined here and test by modifying those - children. --> - <menubar id="nativemenubar"> - <menu id="foo" label="Foo"> - <menupopup> - <menuitem label="FooItem0" command="cmd_FooItem0"/> - <menuitem label="FooItem1" command="cmd_FooItem1"/> - <menuseparator/> - <menu label="Bar"> - <menupopup> - <menuitem label="BarItem0" command="cmd_BarItem0"/> - <menuitem label="BarItem1" command="cmd_BarItem1"/> - </menupopup> - </menu> - </menupopup> - </menu> - </menubar> - - <script type="application/javascript"><![CDATA[ - - function ok(condition, message) { - window.opener.wrappedJSObject.SimpleTest.ok(condition, message); - } - - function onTestsFinished() { - window.close(); - window.opener.wrappedJSObject.SimpleTest.finish(); - } - - // Force a menu to update itself. All of the menus parents will be updated - // as well. An empty string will force a complete menu system reload. - function forceUpdateNativeMenuAt(location) { - var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - try { - utils.forceUpdateNativeMenuAt(location); - } - catch (e) { - dump(e + "\n"); - } - } - - var executedCommandID = ""; - - function testItem(location, targetID) { - var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - var correctCommandHandler = false; - try { - utils.activateNativeMenuItemAt(location); - correctCommandHandler = executedCommandID == targetID; - } - catch (e) { - dump(e + "\n"); - } - finally { - executedCommandID = ""; - return correctCommandHandler; - } - } - - function createXULMenuPopup() { - const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var item = document.createElementNS(XUL_NS, "menupopup"); - return item; - } - - function createXULMenu(aLabel) { - const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var item = document.createElementNS(XUL_NS, "menu"); - item.setAttribute("label", aLabel); - return item; - } - - function createXULMenuItem(aLabel, aCommandId) { - const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var item = document.createElementNS(XUL_NS, "menuitem"); - item.setAttribute("label", aLabel); - item.setAttribute("command", aCommandId); - return item; - } - - function runBaseMenuTests() { - forceUpdateNativeMenuAt("0|3"); - return testItem("0|0", "cmd_FooItem0") && - testItem("0|1", "cmd_FooItem1") && - testItem("0|3|0", "cmd_BarItem0") && - testItem("0|3|1", "cmd_BarItem1"); - } - - function onLoad() { - var _delayedOnLoad = function() { - // First let's run the base menu tests. - ok(runBaseMenuTests()); - - // Set up some nodes that we'll use. - var menubarNode = document.getElementById("nativemenubar"); - var newMenu0 = createXULMenu("NewMenu0"); - var newMenu1 = createXULMenu("NewMenu1"); - var newMenuPopup0 = createXULMenuPopup(); - var newMenuPopup1 = createXULMenuPopup(); - var newMenuItem0 = createXULMenuItem("NewMenuItem0", "cmd_NewItem0"); - var newMenuItem1 = createXULMenuItem("NewMenuItem1", "cmd_NewItem1"); - var newMenuItem2 = createXULMenuItem("NewMenuItem2", "cmd_NewItem2"); - var newMenuItem3 = createXULMenuItem("NewMenuItem3", "cmd_NewItem3"); - var newMenuItem4 = createXULMenuItem("NewMenuItem4", "cmd_NewItem4"); - var newMenuItem5 = createXULMenuItem("NewMenuItem5", "cmd_NewItem5"); - - // Create another submenu with hierarchy via DOM manipulation. - // ****************** - // * Foo * NewMenu0 * <- Menu bar - // ****************** - // **************** - // * NewMenuItem0 * <- NewMenu0 submenu - // **************** - // * NewMenuItem1 * - // **************** - // * NewMenuItem2 * - // ******************************* - // * NewMenu1 > * NewMenuItem3 * <- NewMenu1 submenu - // ******************************* - // * NewMenuItem4 * - // **************** - // * NewMenuItem5 * - // **************** - newMenu0.appendChild(newMenuPopup0); - newMenuPopup0.appendChild(newMenuItem0); - newMenuPopup0.appendChild(newMenuItem1); - newMenuPopup0.appendChild(newMenuItem2); - newMenuPopup0.appendChild(newMenu1); - newMenu1.appendChild(newMenuPopup1); - newMenuPopup1.appendChild(newMenuItem3); - newMenuPopup1.appendChild(newMenuItem4); - newMenuPopup1.appendChild(newMenuItem5); - //XXX - we have to append the menu to the top-level of the menu bar - // only after constructing it. If we append before construction, it is - // invalid because it has no children and we don't validate it if we add - // children later. - menubarNode.appendChild(newMenu0); - forceUpdateNativeMenuAt("1|3"); - // Run basic tests again. - ok(runBaseMenuTests()); - - // Error strings. - var sa = "Command handler(s) should have activated"; - var sna = "Command handler(s) should not have activated"; - - // Test middle items. - ok(testItem("1|1", "cmd_NewItem1"), sa); - ok(testItem("1|3|1", "cmd_NewItem4"), sa); - - // Hide newMenu0. - newMenu0.setAttribute("hidden", "true"); - ok(runBaseMenuTests(), sa); // the base menu should still be unhidden - ok(!testItem("1|0", ""), sna); - ok(!testItem("1|1", ""), sna); - ok(!testItem("1|2", ""), sna); - ok(!testItem("1|3|0", ""), sna); - ok(!testItem("1|3|1", ""), sna); - ok(!testItem("1|3|2", ""), sna); - - // Show newMenu0. - newMenu0.setAttribute("hidden", "false"); - forceUpdateNativeMenuAt("1|3"); - ok(runBaseMenuTests(), sa); - ok(testItem("1|0", "cmd_NewItem0"), sa); - ok(testItem("1|1", "cmd_NewItem1"), sa); - ok(testItem("1|2", "cmd_NewItem2"), sa); - ok(testItem("1|3|0", "cmd_NewItem3"), sa); - ok(testItem("1|3|1", "cmd_NewItem4"), sa); - ok(testItem("1|3|2", "cmd_NewItem5"), sa); - - // Hide items. - newMenuItem1.setAttribute("hidden", "true"); - newMenuItem4.setAttribute("hidden", "true"); - forceUpdateNativeMenuAt("1|2"); - ok(runBaseMenuTests(), sa); - ok(testItem("1|0", "cmd_NewItem0"), sa); - ok(testItem("1|1", "cmd_NewItem2"), sa); - ok(!testItem("1|2", ""), sna); - ok(testItem("1|2|0", "cmd_NewItem3"), sa); - ok(testItem("1|2|1", "cmd_NewItem5"), sa); - ok(!testItem("1|2|2", ""), sna); - - // Show items. - newMenuItem1.setAttribute("hidden", "false"); - newMenuItem4.setAttribute("hidden", "false"); - forceUpdateNativeMenuAt("1|3"); - ok(runBaseMenuTests(), sa); - ok(testItem("1|0", "cmd_NewItem0"), sa); - ok(testItem("1|1", "cmd_NewItem1"), sa); - ok(testItem("1|2", "cmd_NewItem2"), sa); - ok(testItem("1|3|0", "cmd_NewItem3"), sa); - ok(testItem("1|3|1", "cmd_NewItem4"), sa); - ok(testItem("1|3|2", "cmd_NewItem5"), sa); - - // At this point in the tests the state of the menus has been returned - // to the originally diagramed state. - - // Test command disabling - var cmd_NewItem0 = document.getElementById("cmd_NewItem0"); - ok(testItem("1|0", "cmd_NewItem0"), sa); - cmd_NewItem0.setAttribute("disabled", "true"); - ok(!testItem("1|0", "cmd_NewItem0"), sna); - cmd_NewItem0.removeAttribute("disabled"); - ok(testItem("1|0", "cmd_NewItem0"), sa); - - // Remove menu. - menubarNode.removeChild(newMenu0); - ok(runBaseMenuTests(), sa); - ok(!testItem("1|0", ""), sna); - ok(!testItem("1|1", ""), sna); - ok(!testItem("1|2", ""), sna); - ok(!testItem("1|3|0", ""), sna); - ok(!testItem("1|3|1", ""), sna); - ok(!testItem("1|3|2", ""), sna); - // return state to original diagramed state - menubarNode.appendChild(newMenu0); - - // Test for bug 447042, make sure that adding a menu node with no children - // to the menu bar and then adding another menu node with children works. - // Menus with no children don't get their native menu items shown and that - // caused internal arrays to get out of sync and an append crashed. - var tmpMenu0 = createXULMenu("tmpMenu0"); - menubarNode.removeChild(newMenu0); - menubarNode.appendChild(tmpMenu0); - menubarNode.appendChild(newMenu0); - forceUpdateNativeMenuAt("1|3"); - ok(runBaseMenuTests()); - ok(testItem("1|0", "cmd_NewItem0"), sa); - ok(testItem("1|1", "cmd_NewItem1"), sa); - ok(testItem("1|2", "cmd_NewItem2"), sa); - ok(testItem("1|3|0", "cmd_NewItem3"), sa); - ok(testItem("1|3|1", "cmd_NewItem4"), sa); - ok(testItem("1|3|2", "cmd_NewItem5"), sa); - // return state to original diagramed state - menubarNode.removeChild(tmpMenu0); - delete tmpMenu0; - - // This test is basically a crash test for bug 433858. - newMenuItem1.setAttribute("hidden", "true"); - newMenuItem2.setAttribute("hidden", "true"); - newMenu1.setAttribute("hidden", "true"); - forceUpdateNativeMenuAt("1"); - newMenuItem1.setAttribute("hidden", "false"); - newMenuItem2.setAttribute("hidden", "false"); - newMenu1.setAttribute("hidden", "false"); - forceUpdateNativeMenuAt("1"); - - onTestsFinished(); - } - - setTimeout(_delayedOnLoad, 1000); - } - - ]]></script> -</window> diff --git a/widget/tests/native_mouse_mac_window.xul b/widget/tests/native_mouse_mac_window.xul deleted file mode 100644 index 8680c3b1a..000000000 --- a/widget/tests/native_mouse_mac_window.xul +++ /dev/null @@ -1,773 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> - -<window id="NativeMenuWindow" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - xmlns:html="http://www.w3.org/1999/xhtml" - width="600" - height="600" - title="Native Mouse Event Test" - orient="vertical"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - - <box height="200" id="box"/> - <menupopup id="popup" width="250" height="50"/> - <panel id="panel" width="250" height="50" noautohide="true"/> - - <script type="application/javascript"><![CDATA[ - - function ok(condition, message) { - window.opener.wrappedJSObject.SimpleTest.ok(condition, message); - } - - function is(a, b, message) { - window.opener.wrappedJSObject.SimpleTest.is(a, b, message); - } - - function todo(condition, message) { - window.opener.wrappedJSObject.SimpleTest.todo(condition, message); - } - - function todo_is(a, b, message) { - window.opener.wrappedJSObject.SimpleTest.todo_is(a, b, message); - } - - function onTestsFinished() { - clearTimeout(gAfterLoopExecution); - observe(window, eventMonitor, false); - observe(gRightWindow, eventMonitor, false); - observe(gPopup, eventMonitor, false); - gRightWindow.close(); - var openerSimpleTest = window.opener.wrappedJSObject.SimpleTest; - window.close(); - openerSimpleTest.finish(); - } - - const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - const xulWin = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin" type="text/css"?><window xmlns="' + XUL_NS + '"/>'; - - const NSLeftMouseDown = 1, - NSLeftMouseUp = 2, - NSRightMouseDown = 3, - NSRightMouseUp = 4, - NSMouseMoved = 5, - NSLeftMouseDragged = 6, - NSRightMouseDragged = 7, - NSMouseEntered = 8, - NSMouseExited = 9, - NSKeyDown = 10, - NSKeyUp = 11, - NSFlagsChanged = 12, - NSAppKitDefined = 13, - NSSystemDefined = 14, - NSApplicationDefined = 15, - NSPeriodic = 16, - NSCursorUpdate = 17, - NSScrollWheel = 22, - NSTabletPoint = 23, - NSTabletProximity = 24, - NSOtherMouseDown = 25, - NSOtherMouseUp = 26, - NSOtherMouseDragged = 27, - NSEventTypeGesture = 29, - NSEventTypeMagnify = 30, - NSEventTypeSwipe = 31, - NSEventTypeRotate = 18, - NSEventTypeBeginGesture = 19, - NSEventTypeEndGesture = 20; - - const NSAlphaShiftKeyMask = 1 << 16, - NSShiftKeyMask = 1 << 17, - NSControlKeyMask = 1 << 18, - NSAlternateKeyMask = 1 << 19, - NSCommandKeyMask = 1 << 20, - NSNumericPadKeyMask = 1 << 21, - NSHelpKeyMask = 1 << 22, - NSFunctionKeyMask = 1 << 23; - - const gDebug = false; - - function printDebug(msg) { if (gDebug) dump(msg); } - - var gExpectedEvents = []; - var gRightWindow = null, gPopup = null; - var gCurrentMouseX = 0, gCurrentMouseY = 0; - var gAfterLoopExecution = 0; - - function testMouse(x, y, msg, elem, win, exp, flags, callback) { - clearExpectedEvents(); - var syntheticEvent = null; - exp.forEach(function (expEv) { - expEv.screenX = x; - expEv.screenY = y; - if (expEv.synthetic) { - is(syntheticEvent, null, - "Can't handle two synthetic events in a single testMouse call"); - syntheticEvent = expEv; - } - gExpectedEvents.push(expEv); - }); - printDebug("sending event: " + x + ", " + y + " (" + msg + ")\n"); - gCurrentMouseX = x; - gCurrentMouseY = y; - var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - var callbackFunc = function() { - clearExpectedEvents(); - callback(); - } - if (syntheticEvent) { - // Set up this listener before we sendNativeMouseEvent, just - // in case that synchronously calls us. - eventListenOnce(syntheticEvent.target, syntheticEvent.type, - // Trigger callbackFunc async, so we're not assuming - // anything about how our listener gets ordered with - // others. - function () { SimpleTest.executeSoon(callbackFunc) }); - } - utils.sendNativeMouseEvent(x, y, msg, flags || 0, elem); - if (!syntheticEvent) { - gAfterLoopExecution = setTimeout(callbackFunc, 0); - } - } - - function eventListenOnce(elem, name, callback) { - elem.addEventListener(name, function(e) { - elem.removeEventListener(name, arguments.callee, false); - callback(e); - }, false); - } - - function focusAndThen(win, callback) { - eventListenOnce(win, "focus", callback); - printDebug("focusing a window\n"); - win.focus(); - } - - function eventToString(e) { - return JSON.stringify({ - type: e.type, target: e.target.nodeName, screenX: e.screenX, screenY: e.screenY - }); - } - - function clearExpectedEvents() { - while (gExpectedEvents.length > 0) { - var expectedEvent = gExpectedEvents.shift(); - var errFun = expectedEvent.shouldFireButDoesnt ? todo : ok; - errFun(false, "Didn't receive expected event: " + eventToString(expectedEvent)); - } - } - - var gEventNum = 0; - - function eventMonitor(e) { - printDebug("got event: " + eventToString(e) + "\n"); - processEvent(e); - } - - function processEvent(e) { - if (e.screenX != gCurrentMouseX || e.screenY != gCurrentMouseY) { - todo(false, "Oh no! Received a stray event from a confused tracking area. Aborting test."); - onTestsFinished(); - return; - } - var expectedEvent = gExpectedEvents.shift(); - if (!expectedEvent) { - ok(false, "received event I didn't expect: " + eventToString(e)); - return; - } - if (e.type != expectedEvent.type) { - // Didn't get expectedEvent. - var errFun = expectedEvent.shouldFireButDoesnt ? todo : ok; - errFun(false, "Didn't receive expected event: " + eventToString(expectedEvent)); - return processEvent(e); - } - gEventNum++; - is(e.screenX, expectedEvent.screenX, gEventNum + " | wrong X coord for event " + eventToString(e)); - is(e.screenY, expectedEvent.screenY, gEventNum + " | wrong Y coord for event " + eventToString(e)); - is(e.target, expectedEvent.target, gEventNum + " | wrong target for event " + eventToString(e)); - if (expectedEvent.firesButShouldnt) { - todo(false, gEventNum + " | Got an event that should not have fired: " + eventToString(e)); - } - } - - function observe(elem, fun, add) { - var addOrRemove = add ? "addEventListener" : "removeEventListener"; - elem[addOrRemove]("mousemove", fun, false); - elem[addOrRemove]("mouseover", fun, false); - elem[addOrRemove]("mouseout", fun, false); - elem[addOrRemove]("mousedown", fun, false); - elem[addOrRemove]("mouseup", fun, false); - elem[addOrRemove]("click", fun, false); - } - - function start() { - window.resizeTo(200, 200); - window.moveTo(50, 50); - gRightWindow = open(xulWin, '', 'chrome,screenX=300,screenY=50,width=200,height=200'); - eventListenOnce(gRightWindow, "focus", function () { - focusAndThen(window, runTests); - }); - gPopup = document.getElementById("popup"); - } - - function runTests() { - observe(window, eventMonitor, true); - observe(gRightWindow, eventMonitor, true); - var left = window, right = gRightWindow; - var leftElem = document.getElementById("box"); - var rightElem = gRightWindow.document.documentElement; - var panel = document.getElementById("panel"); - var tooltip = (function createTooltipInRightWindow() { - var _tooltip = right.document.createElementNS(XUL_NS, "tooltip"); - _tooltip.setAttribute("id", "tip"); - _tooltip.setAttribute("width", "80"); - _tooltip.setAttribute("height", "20"); - right.document.documentElement.appendChild(_tooltip); - return _tooltip; - })(); - var tests = [ - - // Part 1: Disallow click-through - - function blockClickThrough(callback) { - document.documentElement.setAttribute("clickthrough", "never"); - gRightWindow.document.documentElement.setAttribute("clickthrough", "never"); - callback(); - }, - // Enter the left window, which is focused. - [150, 150, NSMouseMoved, null, left, [ - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem } - ]], - // Test that moving inside the window fires mousemove events. - [170, 150, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - // Leaving the window should fire a mouseout event... - [170, 20, NSMouseMoved, null, left, [ - { type: "mouseout", target: leftElem }, - ]], - // ... and entering a mouseover event. - [170, 120, NSMouseMoved, null, left, [ - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - // Move over the right window, which is inactive. - // Inactive windows shouldn't respond to mousemove events when clickthrough="never", - // so we should only get a mouseout event, no mouseover event. - [400, 150, NSMouseMoved, null, right, [ - { type: "mouseout", target: leftElem }, - ]], - // Left-clicking while holding Cmd and middle clicking should work even - // on inactive windows, but without making them active. - [400, 150, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ], NSCommandKeyMask], - [400, 150, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ], NSCommandKeyMask], - [400, 150, NSOtherMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 150, NSOtherMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // Clicking an inactive window should make it active and fire a mouseover - // event. - [400, 150, NSLeftMouseDown, null, right, [ - { type: "mouseover", target: rightElem, synthetic: true }, - ]], - [400, 150, NSLeftMouseUp, null, right, [ - ]], - // Now it's focused, so we should get a mousedown event when clicking. - [400, 150, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - // Let's drag to the right without letting the button go. - [410, 150, NSLeftMouseDragged, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Let go of the mouse. - [410, 150, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // Move the mouse back over the left window, which is inactive. - [150, 170, NSMouseMoved, null, left, [ - { type: "mouseout", target: rightElem }, - ]], - // Now we're being sneaky. The left window is inactive, but *right*-clicks to it - // should still get through. Test that. - // Ideally we'd be bracketing that event with over and out events, too, but it - // probably doesn't matter too much. - [150, 170, NSRightMouseDown, null, left, [ - { type: "mouseover", target: leftElem, shouldFireButDoesnt: true }, - { type: "mousedown", target: leftElem }, - { type: "mouseout", target: leftElem, shouldFireButDoesnt: true }, - ]], - // Let go of the mouse. - [150, 170, NSRightMouseUp, null, left, [ - { type: "mouseover", target: leftElem, shouldFireButDoesnt: true }, - { type: "mouseup", target: leftElem }, - { type: "click", target: leftElem }, - { type: "mouseout", target: leftElem, shouldFireButDoesnt: true }, - ]], - // Right clicking hasn't focused it, so the window is still inactive. - // Let's focus it; this time without the mouse, for variaton's sake. - // Still, mouseout and mouseover events should fire. - function raiseLeftWindow(callback) { - clearExpectedEvents(); - gExpectedEvents.push({ screenX: 150, screenY: 170, type: "mouseover", target: leftElem }); - // We have to be a bit careful here. The synthetic mouse event may - // not fire for a bit after we focus the left window. - eventListenOnce(leftElem, "mouseover", function() { - // Trigger callback async, so we're not assuming - // anything about how our listener gets ordered with others. - SimpleTest.executeSoon(callback); - }); - printDebug("focusing left window"); - left.focus(); - }, - // It's active, so it should respond to mousemove events now. - [150, 170, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - // This was boring... let's introduce a popup. It will overlap both the left - // and the right window. - function openPopupInLeftWindow(callback) { - eventListenOnce(gPopup, "popupshown", callback); - gPopup.openPopupAtScreen(150, 50, true); - }, - // Move the mouse over the popup. - [200, 80, NSMouseMoved, gPopup, left, [ - { type: "mouseout", target: leftElem }, - { type: "mouseover", target: gPopup }, - { type: "mousemove", target: gPopup }, - ]], - // Move the mouse back over the left window outside the popup. - [160, 170, NSMouseMoved, null, left, [ - { type: "mouseout", target: gPopup }, - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - // Back over the popup... - [190, 80, NSMouseMoved, gPopup, left, [ - { type: "mouseout", target: leftElem }, - { type: "mouseover", target: gPopup }, - { type: "mousemove", target: gPopup }, - ]], - // ...and over into the right window. - // It's inactive, so it shouldn't get mouseover events yet. - [400, 170, NSMouseMoved, null, right, [ - { type: "mouseout", target: gPopup }, - ]], - // Again, no mouse events please, even though a popup is open. (bug 425556) - [400, 180, NSMouseMoved, null, right, [ - ]], - // Activate the right window with a click. - // This will close the popup and make the mouse enter the right window. - [400, 180, NSLeftMouseDown, null, right, [ - { type: "mouseover", target: rightElem, synthetic: true }, - ]], - [400, 180, NSLeftMouseUp, null, right, [ - ]], - function verifyPopupClosed2(callback) { - is(gPopup.popupBoxObject.popupState, "closed", "popup should have closed when clicking"); - callback(); - }, - // Now the right window is active; click it again, just for fun. - [400, 180, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 180, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - - // Time for our next trick: a tooltip! - // Install the tooltip, but don't show it yet. - function setTooltip(callback) { - rightElem.setAttribute("tooltip", "tip"); - gExpectedEvents.push({ screenX: 410, screenY: 180, type: "mousemove", target: rightElem }); - eventListenOnce(rightElem, "popupshown", callback); - gCurrentMouseX = 410; - gCurrentMouseY = 180; - var utils = right.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - utils.sendNativeMouseEvent(410, 180, NSMouseMoved, 0, null); - }, - // Now the tooltip is visible. - // Move the mouse a little to the right. - [411, 180, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Move another pixel. - [412, 180, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Move up and click to make the tooltip go away. - [412, 80, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [412, 80, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [412, 80, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // OK, next round. Open a panel in the left window, which is inactive. - function openPanel(callback) { - eventListenOnce(panel, "popupshown", callback); - panel.openPopupAtScreen(150, 150, false); - }, - // The panel is parented, so it will be z-ordered over its parent but - // under the active window. - // Now we move the mouse over the part where the panel rect intersects the - // right window's rect. Since the panel is under the window, all the events - // should target the right window. - [390, 170, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [390, 171, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [391, 171, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Now move off the right window, so that the mouse is directly over the - // panel. - [260, 170, NSMouseMoved, panel, left, [ - { type: "mouseout", target: rightElem }, - ]], - [260, 171, NSMouseMoved, panel, left, [ - ]], - [261, 171, NSMouseMoved, panel, left, [ - ]], - // Let's be evil and click it. - [261, 171, NSLeftMouseDown, panel, left, [ - ]], - [261, 171, NSLeftMouseUp, panel, left, [ - ]], - // This didn't focus the window, unfortunately, so let's do it ourselves. - function raiseLeftWindowTakeTwo(callback) { - focusAndThen(left, callback); - }, - // Now mouse events should get through to the panel (which is now over the - // right window). - [387, 170, NSMouseMoved, panel, left, [ - { type: "mouseover", target: panel }, - { type: "mousemove", target: panel }, - ]], - [387, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - [388, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - // Click the panel. - [388, 171, NSLeftMouseDown, panel, left, [ - { type: "mousedown", target: panel } - ]], - [388, 171, NSLeftMouseUp, panel, left, [ - { type: "mouseup", target: panel }, - { type: "click", target: panel }, - ]], - - // Last test for this part: Hit testing in the Canyon of Nowhere - - // the pixel row directly south of the panel, over the left window. - // Before bug 515003 we wrongly thought the mouse wasn't over any window. - [173, 200, NSMouseMoved, null, left, [ - { type: "mouseout", target: panel }, - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - [173, 201, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - - // Part 2: Allow click-through - - function hideThatPanel(callback) { - eventListenOnce(panel, "popuphidden", callback); - panel.hidePopup(); - }, - function unblockClickThrough(callback) { - document.documentElement.removeAttribute("clickthrough"); - gRightWindow.document.documentElement.removeAttribute("clickthrough"); - callback(); - }, - // Enter the left window, which is focused. - [150, 150, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem } - ]], - // Test that moving inside the window fires mousemove events. - [170, 150, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - // Leaving the window should fire a mouseout event... - [170, 20, NSMouseMoved, null, left, [ - { type: "mouseout", target: leftElem }, - ]], - // ... and entering a mouseover event. - [170, 120, NSMouseMoved, null, left, [ - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - // Move over the right window, which is inactive but still accepts - // mouse events. - [400, 150, NSMouseMoved, null, right, [ - { type: "mouseout", target: leftElem }, - { type: "mouseover", target: rightElem }, - { type: "mousemove", target: rightElem }, - ]], - // Left-clicking while holding Cmd and middle clicking should work - // on inactive windows, but without making them active. - [400, 150, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ], NSCommandKeyMask], - [400, 150, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ], NSCommandKeyMask], - [400, 150, NSOtherMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 150, NSOtherMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // Clicking an inactive window should make it active - [400, 150, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 150, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // Now it's focused. - [401, 150, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - // Let's drag to the right without letting the button go. - [410, 150, NSLeftMouseDragged, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Let go of the mouse. - [410, 150, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // Move the mouse back over the left window, which is inactive. - [150, 170, NSMouseMoved, null, left, [ - { type: "mouseout", target: rightElem }, - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - // Right-click it. - [150, 170, NSRightMouseDown, null, left, [ - { type: "mousedown", target: leftElem }, - ]], - // Let go of the mouse. - [150, 170, NSRightMouseUp, null, left, [ - { type: "mouseup", target: leftElem }, - { type: "click", target: leftElem }, - ]], - // Right clicking hasn't focused it, so the window is still inactive. - // Let's focus it; this time without the mouse, for variaton's sake. - function raiseLeftWindow(callback) { - clearExpectedEvents(); - focusAndThen(left, function () { SimpleTest.executeSoon(callback); }); - }, - // It's active and should still respond to mousemove events. - [150, 170, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - - // This was boring... let's introduce a popup. It will overlap both the left - // and the right window. - function openPopupInLeftWindow(callback) { - eventListenOnce(gPopup, "popupshown", callback); - gPopup.openPopupAtScreen(150, 50, true); - }, - // Move the mouse over the popup. - [200, 80, NSMouseMoved, gPopup, left, [ - { type: "mouseout", target: leftElem }, - { type: "mouseover", target: gPopup }, - { type: "mousemove", target: gPopup }, - ]], - // Move the mouse back over the left window outside the popup. - [160, 170, NSMouseMoved, null, left, [ - { type: "mouseout", target: gPopup }, - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - // Back over the popup... - [190, 80, NSMouseMoved, gPopup, left, [ - { type: "mouseout", target: leftElem }, - { type: "mouseover", target: gPopup }, - { type: "mousemove", target: gPopup }, - ]], - // ...and over into the right window. - [400, 170, NSMouseMoved, null, right, [ - { type: "mouseout", target: gPopup }, - { type: "mouseover", target: rightElem }, - { type: "mousemove", target: rightElem }, - ]], - [400, 180, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Activate the right window with a click. - [400, 180, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 180, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - function verifyPopupClosed2(callback) { - is(gPopup.popupBoxObject.popupState, "closed", "popup should have closed when clicking"); - callback(); - }, - // Now the right window is active; click it again, just for fun. - [400, 180, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [400, 180, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - - // Time for our next trick: a tooltip! - // Install the tooltip, but don't show it yet. - function setTooltip2(callback) { - rightElem.setAttribute("tooltip", "tip"); - gExpectedEvents.push({ screenX: 410, screenY: 180, type: "mousemove", target: rightElem }); - eventListenOnce(rightElem, "popupshown", callback); - gCurrentMouseX = 410; - gCurrentMouseY = 180; - var utils = right.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - utils.sendNativeMouseEvent(410, 180, NSMouseMoved, 0, null); - }, - // Now the tooltip is visible. - // Move the mouse a little to the right. - [411, 180, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Move another pixel. - [412, 180, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Move up and click to make the tooltip go away. - [412, 80, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [412, 80, NSLeftMouseDown, null, right, [ - { type: "mousedown", target: rightElem }, - ]], - [412, 80, NSLeftMouseUp, null, right, [ - { type: "mouseup", target: rightElem }, - { type: "click", target: rightElem }, - ]], - // OK, next round. Open a panel in the left window, which is inactive. - function openPanel2(callback) { - eventListenOnce(panel, "popupshown", callback); - panel.openPopupAtScreen(150, 150, false); - }, - // The panel is parented, so it will be z-ordered over its parent but - // under the active window. - // Now we move the mouse over the part where the panel rect intersects the - // right window's rect. Since the panel is under the window, all the events - // should target the right window. - [390, 170, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [390, 171, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - [391, 171, NSMouseMoved, null, right, [ - { type: "mousemove", target: rightElem }, - ]], - // Now move off the right window, so that the mouse is directly over the - // panel. - [260, 170, NSMouseMoved, panel, left, [ - { type: "mouseout", target: rightElem }, - { type: "mouseover", target: panel }, - { type: "mousemove", target: panel }, - ]], - [260, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - [261, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - // Let's be evil and click it. - [261, 171, NSLeftMouseDown, panel, left, [ - { type: "mousedown", target: panel }, - ]], - [261, 171, NSLeftMouseUp, panel, left, [ - { type: "mouseup", target: panel }, - { type: "click", target: panel }, - ]], - // This didn't focus the window, unfortunately, so let's do it ourselves. - function raiseLeftWindowTakeTwo(callback) { - focusAndThen(left, callback); - }, - [387, 170, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - [387, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - [388, 171, NSMouseMoved, panel, left, [ - { type: "mousemove", target: panel }, - ]], - // Click the panel. - [388, 171, NSLeftMouseDown, panel, left, [ - { type: "mousedown", target: panel } - ]], - [388, 171, NSLeftMouseUp, panel, left, [ - { type: "mouseup", target: panel }, - { type: "click", target: panel }, - ]], - - // Last test for today: Hit testing in the Canyon of Nowhere - - // the pixel row directly south of the panel, over the left window. - // Before bug 515003 we wrongly thought the mouse wasn't over any window. - [173, 200, NSMouseMoved, null, left, [ - { type: "mouseout", target: panel }, - { type: "mouseover", target: leftElem }, - { type: "mousemove", target: leftElem }, - ]], - [173, 201, NSMouseMoved, null, left, [ - { type: "mousemove", target: leftElem }, - ]], - ]; - function runNextTest() { - if (!tests.length) - return onTestsFinished(); - - var test = tests.shift(); - if (typeof test == "function") - return test(runNextTest); - - var [x, y, msg, elem, win, exp, flags] = test; - testMouse(x, y, msg, elem, win, exp, flags, runNextTest); - } - runNextTest(); - } - - SimpleTest.waitForFocus(start); - - ]]></script> -</window> diff --git a/widget/tests/standalone_native_menu_window.xul b/widget/tests/standalone_native_menu_window.xul deleted file mode 100644 index 6783a66e6..000000000 --- a/widget/tests/standalone_native_menu_window.xul +++ /dev/null @@ -1,334 +0,0 @@ -<?xml version="1.0"?> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> - -<window id="StandaloneNativeMenuWindow" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - width="300" - height="300" - onload="onLoad();" - title="nsIStandaloneNativeMenu Test"> - - <command id="cmd_FooItem0" oncommand="executedCommandID = 'cmd_FooItem0';"/> - <command id="cmd_FooItem1" oncommand="executedCommandID = 'cmd_FooItem1';"/> - <command id="cmd_BarItem0" oncommand="executedCommandID = 'cmd_BarItem0';"/> - <command id="cmd_BarItem1" oncommand="executedCommandID = 'cmd_BarItem1';"/> - <command id="cmd_NewItem0" oncommand="executedCommandID = 'cmd_NewItem0';"/> - <command id="cmd_NewItem1" oncommand="executedCommandID = 'cmd_NewItem1';"/> - <command id="cmd_NewItem2" oncommand="executedCommandID = 'cmd_NewItem2';"/> - <command id="cmd_NewItem3" oncommand="executedCommandID = 'cmd_NewItem3';"/> - <command id="cmd_NewItem4" oncommand="executedCommandID = 'cmd_NewItem4';"/> - <command id="cmd_NewItem5" oncommand="executedCommandID = 'cmd_NewItem5';"/> - - <!-- We do not modify any menus or menu items defined here in testing. These - serve as a baseline structure for us to test after other modifications. - We add children to the menubar defined here and test by modifying those - children. --> - <popupset> - <menupopup id="standalonenativemenu"> - <menu id="foo" label="Foo"> - <menupopup> - <menuitem label="FooItem0" command="cmd_FooItem0"/> - <menuitem label="FooItem1" command="cmd_FooItem1"/> - <menuseparator/> - <menu label="Bar"> - <menupopup> - <menuitem label="BarItem0" command="cmd_BarItem0"/> - <menuitem label="BarItem1" command="cmd_BarItem1"/> - </menupopup> - </menu> - </menupopup> - </menu> - </menupopup> - </popupset> - - <script type="application/javascript"><![CDATA[ - - function ok(condition, message) { - window.opener.wrappedJSObject.SimpleTest.ok(condition, message); - } - - function todo(condition, message) { - window.opener.wrappedJSObject.SimpleTest.todo(condition, message); - } - - function onTestsFinished() { - window.close(); - window.opener.wrappedJSObject.SimpleTest.finish(); - } - - var executedCommandID = ""; - - function testItem(menu, location, targetID) { - var correctCommandHandler = false; - try { - menu.menuWillOpen(); - menu.activateNativeMenuItemAt(location); - correctCommandHandler = executedCommandID == targetID; - } - catch (e) { - dump(e + "\n"); - } - finally { - executedCommandID = ""; - return correctCommandHandler; - } - } - - var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - - function createXULMenuPopup() { - return document.createElementNS(XUL_NS, "menupopup"); - } - - function createXULMenu(aLabel) { - var item = document.createElementNS(XUL_NS, "menu"); - item.setAttribute("label", aLabel); - return item; - } - - function createXULMenuItem(aLabel, aCommandId) { - var item = document.createElementNS(XUL_NS, "menuitem"); - item.setAttribute("label", aLabel); - item.setAttribute("command", aCommandId); - return item; - } - - function runBaseMenuTests(menu) { - menu.forceUpdateNativeMenuAt("0|3"); - return testItem(menu, "0|0", "cmd_FooItem0") && - testItem(menu, "0|1", "cmd_FooItem1") && - testItem(menu, "0|3|0", "cmd_BarItem0") && - testItem(menu, "0|3|1", "cmd_BarItem1"); - } - - function createStandaloneNativeMenu(menuNode) { - try { - let Cc = Components.classes; - let Ci = Components.interfaces; - let menu = Cc["@mozilla.org/widget/standalonenativemenu;1"].createInstance(Ci.nsIStandaloneNativeMenu); - menu.init(menuNode); - return menu; - } catch (e) { - ok(false, "Failed creating nsIStandaloneNativeMenu instance"); - throw e; - } - } - - function runDetachedMenuTests(addMenupopupBeforeCreatingSNM) { - let menu = createXULMenu("Detached menu"); - menu.setAttribute("image", 'data:image/svg+xml,<svg%20xmlns="http://www.w3.org/2000/svg"%20width="32"%20height="32"><circle%20cx="16"%20cy="16"%20r="16"/></svg>'); - let menupopup = createXULMenuPopup(); - - let popupShowingFired = false; - let itemActivated = false; - - menupopup.addEventListener("popupshowing", function (e) { - popupShowingFired = true; - - let menuitem = document.createElementNS(XUL_NS, "menuitem"); - menuitem.setAttribute("label", "detached menu item"); - menuitem.addEventListener("command", function (e) { - itemActivated = true; - }) - menupopup.appendChild(menuitem); - }) - - // It shouldn't make a difference whether the menupopup is added to the - // menu element before or after we create the nsIStandaloneNativeMenu - // instance with it. We test both orders by calling this function twice - // with different values for addMenupopupBeforeCreatingSNM. - - var menuSNM = null; // the nsIStandaloneNativeMenu object for "menu" - if (addMenupopupBeforeCreatingSNM) { - menu.appendChild(menupopup); - menuSNM = createStandaloneNativeMenu(menu); - } else { - menuSNM = createStandaloneNativeMenu(menu); - menu.appendChild(menupopup); - } - - try { - ok(!popupShowingFired, "popupshowing shouldn't have fired before our call to menuWillOpen()"); - menuSNM.menuWillOpen(); - ok(popupShowingFired, "calling menuWillOpen() should have notified our popupshowing listener"); - - ok(!itemActivated, "our dynamically-added menuitem shouldn't have been activated yet"); - menuSNM.activateNativeMenuItemAt("0"); - ok(itemActivated, "the new menu item should have been activated now"); - } catch (ex) { - ok(false, "dynamic menu test failed: " + ex); - } - } - - function onLoad() { - var _delayedOnLoad = function() { - try { - - var menuNode = document.getElementById("standalonenativemenu"); - var menu = createStandaloneNativeMenu(menuNode); - - // First let's run the base menu tests. - ok(runBaseMenuTests(menu), "base tests #1"); - - // Set up some nodes that we'll use. - var newMenu0 = createXULMenu("NewMenu0"); - var newMenu1 = createXULMenu("NewMenu1"); - var newMenuPopup0 = createXULMenuPopup(); - var newMenuPopup1 = createXULMenuPopup(); - var newMenuItem0 = createXULMenuItem("NewMenuItem0", "cmd_NewItem0"); - var newMenuItem1 = createXULMenuItem("NewMenuItem1", "cmd_NewItem1"); - var newMenuItem2 = createXULMenuItem("NewMenuItem2", "cmd_NewItem2"); - var newMenuItem3 = createXULMenuItem("NewMenuItem3", "cmd_NewItem3"); - var newMenuItem4 = createXULMenuItem("NewMenuItem4", "cmd_NewItem4"); - var newMenuItem5 = createXULMenuItem("NewMenuItem5", "cmd_NewItem5"); - - // Create another submenu with hierarchy via DOM manipulation. - // ****************** - // * Foo * NewMenu0 * <- Menu bar - // ****************** - // **************** - // * NewMenuItem0 * <- NewMenu0 submenu - // **************** - // * NewMenuItem1 * - // **************** - // * NewMenuItem2 * - // ******************************* - // * NewMenu1 > * NewMenuItem3 * <- NewMenu1 submenu - // ******************************* - // * NewMenuItem4 * - // **************** - // * NewMenuItem5 * - // **************** - newMenu0.appendChild(newMenuPopup0); - newMenuPopup0.appendChild(newMenuItem0); - newMenuPopup0.appendChild(newMenuItem1); - newMenuPopup0.appendChild(newMenuItem2); - newMenuPopup0.appendChild(newMenu1); - newMenu1.appendChild(newMenuPopup1); - newMenuPopup1.appendChild(newMenuItem3); - newMenuPopup1.appendChild(newMenuItem4); - newMenuPopup1.appendChild(newMenuItem5); - //XXX - we have to append the menu to the top-level of the menu bar - // only after constructing it. If we append before construction, it is - // invalid because it has no children and we don't validate it if we add - // children later. - menuNode.appendChild(newMenu0); - menu.forceUpdateNativeMenuAt("1|3"); - // Run basic tests again. - ok(runBaseMenuTests(menu), "base tests #2"); - - // Error strings. - var sa = "Command handler(s) should have activated"; - var sna = "Command handler(s) should not have activated"; - - // Test middle items. - ok(testItem(menu, "1|1", "cmd_NewItem1"), "#1:" + sa); - ok(testItem(menu, "1|3|1", "cmd_NewItem4"), "#2:" + sa); - - // Hide newMenu0. - newMenu0.setAttribute("hidden", "true"); - ok(runBaseMenuTests(menu), "base tests #3: " + sa); // the base menu should still be unhidden - ok(!testItem(menu, "1|0", ""), "#3:" + sna); - ok(!testItem(menu, "1|1", ""), "#4:" + sna); - ok(!testItem(menu, "1|2", ""), "#5:" + sna); - ok(!testItem(menu, "1|3|0", ""), "#6:" + sna); - ok(!testItem(menu, "1|3|1", ""), "#7:" + sna); - ok(!testItem(menu, "1|3|2", ""), "#8:" + sna); - - // Show newMenu0. - newMenu0.setAttribute("hidden", "false"); - menu.forceUpdateNativeMenuAt("1|3"); - ok(runBaseMenuTests(menu), "base tests #4:" + sa); - ok(testItem(menu, "1|0", "cmd_NewItem0"), "#9:" + sa); - ok(testItem(menu, "1|1", "cmd_NewItem1"), "#10:" + sa); - ok(testItem(menu, "1|2", "cmd_NewItem2"), "#11:" + sa); - ok(testItem(menu, "1|3|0", "cmd_NewItem3"), "#12:" + sa); - ok(testItem(menu, "1|3|1", "cmd_NewItem4"), "#13:" + sa); - ok(testItem(menu, "1|3|2", "cmd_NewItem5"), "#14:" + sa); - - // Hide items. - newMenuItem1.setAttribute("hidden", "true"); - newMenuItem4.setAttribute("hidden", "true"); - menu.forceUpdateNativeMenuAt("1|2"); - ok(runBaseMenuTests(menu), "base tests #5:" + sa); - ok(testItem(menu, "1|0", "cmd_NewItem0"), "#15:" + sa); - ok(testItem(menu, "1|1", "cmd_NewItem2"), "#16:" + sa); - ok(!testItem(menu, "1|2", ""), "#17:" + sna); - ok(testItem(menu, "1|2|0", "cmd_NewItem3"), "#18:" + sa); - ok(testItem(menu, "1|2|1", "cmd_NewItem5"), "#19:" + sa); - ok(!testItem(menu, "1|2|2", ""), "#20:" + sna); - - // Show items. - newMenuItem1.setAttribute("hidden", "false"); - newMenuItem4.setAttribute("hidden", "false"); - //forceUpdateNativeMenuAt("1|3"); - ok(runBaseMenuTests(menu), "base tests #6:" + sa); - ok(testItem(menu, "1|0", "cmd_NewItem0"), "#21:" + sa); - ok(testItem(menu, "1|1", "cmd_NewItem1"), "#22:" + sa); - ok(testItem(menu, "1|2", "cmd_NewItem2"), "#23:" + sa); - ok(testItem(menu, "1|3|0", "cmd_NewItem3"), "#24:" + sa); - ok(testItem(menu, "1|3|1", "cmd_NewItem4"), "#25:" + sa); - ok(testItem(menu, "1|3|2", "cmd_NewItem5"), "#26:" + sa); - - // At this point in the tests the state of the menus has been returned - // to the originally diagramed state. - - // Remove menu. - menuNode.removeChild(newMenu0); - ok(runBaseMenuTests(menu), "base tests #7:" + sa); - ok(!testItem(menu, "1|0", ""), "#27:" + sna); - ok(!testItem(menu, "1|1", ""), "#28:" + sna); - ok(!testItem(menu, "1|2", ""), "#29:" + sna); - ok(!testItem(menu, "1|3|0", ""), "#30:" + sna); - ok(!testItem(menu, "1|3|1", ""), "#31:" + sna); - ok(!testItem(menu, "1|3|2", ""), "#32:" + sna); - // return state to original diagramed state - menuNode.appendChild(newMenu0); - - // Test for bug 447042, make sure that adding a menu node with no children - // to the menu bar and then adding another menu node with children works. - // Menus with no children don't get their native menu items shown and that - // caused internal arrays to get out of sync and an append crashed. - var tmpMenu0 = createXULMenu("tmpMenu0"); - menuNode.removeChild(newMenu0); - menuNode.appendChild(tmpMenu0); - menuNode.appendChild(newMenu0); - menu.forceUpdateNativeMenuAt("1|3"); - //todo(runBaseMenuTests(menu), "base tests #8"); - todo(testItem(menu, "1|0", "cmd_NewItem0"), "#33:" +sa); - todo(testItem(menu, "1|1", "cmd_NewItem1"), "#34:" +sa); - todo(testItem(menu, "1|2", "cmd_NewItem2"), "#35:" +sa); - todo(testItem(menu, "1|3|0", "cmd_NewItem3"), "#36:" +sa); - todo(testItem(menu, "1|3|1", "cmd_NewItem4"), "#37:" +sa); - todo(testItem(menu, "1|3|2", "cmd_NewItem5"), "#38:" +sa); - // return state to original diagramed state - menuNode.removeChild(tmpMenu0); - delete tmpMenu0; - - // This test is basically a crash test for bug 433858. - newMenuItem1.setAttribute("hidden", "true"); - newMenuItem2.setAttribute("hidden", "true"); - newMenu1.setAttribute("hidden", "true"); - menu.forceUpdateNativeMenuAt("1"); - newMenuItem1.setAttribute("hidden", "false"); - newMenuItem2.setAttribute("hidden", "false"); - newMenu1.setAttribute("hidden", "false"); - menu.forceUpdateNativeMenuAt("1"); - - // Run tests where the menu nodes are not in the document's node tree. - runDetachedMenuTests(false); - runDetachedMenuTests(true); - - } catch (e) { - ok(false, "Caught an exception: " + e); - } finally { - onTestsFinished(); - } - } - - setTimeout(_delayedOnLoad, 1000); - } - - ]]></script> -</window> diff --git a/widget/tests/taskbar_previews.xul b/widget/tests/taskbar_previews.xul deleted file mode 100644 index 2f294d187..000000000 --- a/widget/tests/taskbar_previews.xul +++ /dev/null @@ -1,127 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Taskbar Previews Test" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onload="loaded();"> - - <title>Previews - yeah!</title> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script class="testbody" type="application/javascript"> - <![CDATA[ - let Cc = Components.classes; - let Ci = Components.interfaces; - let Cu = Components.utils; - Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - - let taskbar = Cc["@mozilla.org/windows-taskbar;1"].getService(Ci.nsIWinTaskbar); - - function IsWin7OrHigher() { - try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); - var ver = parseFloat(sysInfo.getProperty("version")); - if (ver >= 6.1) - return true; - } catch (ex) { } - return false; - } - isnot(taskbar, null, "Taskbar service is defined"); - is(taskbar.available, IsWin7OrHigher(), "Expected availability of taskbar"); - - SimpleTest.waitForExplicitFinish(); - - function stdPreviewSuite(p) { - p.visible = !p.visible; - p.visible = !p.visible; - p.visible = true; - p.invalidate(); - p.visible = false; - } - - function loaded() - { - if (!taskbar.available) - SimpleTest.finish(); - let controller = { - width: 400, - height: 400, - thumbnailAspectRatio: 1.0, - drawThumbnail: function () { return false; }, - drawPreview: function () { return false; }, - get wrappedJSObject() { return this; } - } - // HACK from mconnor: - var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - let win = wm.getMostRecentWindow("navigator:browser"); - let docShell = win.gBrowser.docShell; - - let winPreview = taskbar.getTaskbarWindowPreview(docShell); - isnot(winPreview, null, "Window preview is not null"); - winPreview.controller = controller; - let button = winPreview.getButton(0); - isnot(button, null, "Could get button at valid index"); - try { - winPreview.getButton(-1); - ok(false, "Got button at negative index"); - } catch (ex) {} - try { - winPreview.getButton(Ci.nsITaskbarWindowPreview.NUM_TOOLBAR_BUTTONS); - ok(false, "Got button at index that is too large"); - } catch (ex) {} - button.image = null; - stdPreviewSuite(winPreview); - // Let's not perma-hide this window from the taskbar - winPreview.visible = true; - - let tabP = taskbar.createTaskbarTabPreview(docShell, controller); - isnot(tabP, null, "Tab preview is not null"); - is(tabP.controller.wrappedJSObject, controller, "Controllers match"); - is(tabP.icon, null, "Default icon is null (windows default)"); - tabP.icon = null; - tabP.move(null); - try { - tabP.move(tabP); - ok(false, "Moved a preview next to itself!"); - } catch (ex) {} - stdPreviewSuite(tabP); - - let tabP2 = taskbar.createTaskbarTabPreview(docShell, controller); - tabP.visible = true; - tabP2.visible = true; - - isnot(tabP2, null, "2nd Tab preview is not null"); - isnot(tabP,tabP2, "Tab previews are different"); - tabP.active = true; - ok(tabP.active && !tabP2.active, "Only one tab is active (part 1)"); - tabP2.active = true; - ok(!tabP.active && tabP2.active, "Only one tab is active (part 2)"); - tabP.active = true; - ok(tabP.active && !tabP2.active, "Only one tab is active (part 3)"); - tabP.active = false; - ok(!tabP.active && !tabP2.active, "Neither tab is active"); - is(winPreview.active, false, "Window preview is not active"); - tabP.active = true; - winPreview.active = true; - ok(winPreview.active && !tabP.active, "Tab preview takes activation from window"); - tabP.active = true; - ok(tabP.active && !winPreview.active, "Tab preview takes activation from window"); - - tabP.visible = false; - tabP2.visible = false; - - SimpleTest.finish(); - } - ]]> - </script> - - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - -</window> diff --git a/widget/tests/test_assign_event_data.html b/widget/tests/test_assign_event_data.html deleted file mode 100644 index 39f31cafe..000000000 --- a/widget/tests/test_assign_event_data.html +++ /dev/null @@ -1,748 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Testing ns*Event::Assign*EventData()</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/NativeKeyCodes.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> - <style> - #a { - background-color: transparent; - transition: background-color 0.1s linear; - } - #a:focus { - background-color: red; - } - .slidin { - border: green 1px solid; - width: 10px; - height: 10px; - animation-name: slidein; - animation-duration: 1s; - } - @keyframes slidein { - from { - margin-left: 100%; - } - to { - margin-left: 0; - } - } - #pointer-target { - border: 1px dashed red; - background: yellow; - margin: 0px 10px; - padding: 0px 10px; - } - #scrollable-div { - background: green; - overflow: auto; - width: 30px; - height: 30px; - } - #scrolled-div { - background: magenta; - width: 10px; - height: 10px; - } - #form { - background: silver; - padding: 0px 10px; - } - #animated-div { - background: cyan; - padding: 0px 10px; - } - </style> -</head> -<body> -<div id="display"> - <input id="input-text"> - <button id="button">button</button> - <a id="a" href="about:blank">hyper link</a> - <span id="pointer-target">span</span> - <div id="scrollable-div"><div id="scrolled-div"></div></div> - <form id="form">form</form> - <div id="animated-div"> </div> -</div> -<div id="content" style="display: none"> -</div> -<pre id="test"> -</pre> - -<script class="testbody" type="application/javascript"> - -SimpleTest.waitForExplicitFinish(); -SimpleTest.expectAssertions(0, 34); - -const kIsMac = (navigator.platform.indexOf("Mac") == 0); -const kIsWin = (navigator.platform.indexOf("Win") == 0); - -var gEvent = null; -var gCopiedEvent = []; -var gCallback = null; -var gCallPreventDefault = false; - -function onEvent(aEvent) -{ - if (gCallPreventDefault) { - aEvent.preventDefault(); - } - gEvent = aEvent; - for (var attr in aEvent) { - if (!attr.match(/^[A-Z0-9_]+$/) && // ignore const attributes - attr != "multipleActionsPrevented" && // multipleActionsPrevented isn't defined in any DOM event specs. - typeof(aEvent[attr]) != "function") { - gCopiedEvent.push({ name: attr, value: aEvent[attr]}); - } - } - setTimeout(gCallback, 0); -} - -const kTests = [ - { description: "InternalScrollPortEvent (overflow, vertical)", - targetID: "scrollable-div", eventType: "overflow", - dispatchEvent: function () { - document.getElementById("scrolled-div").style.height = "500px"; - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalScrollPortEvent (overflow, horizontal)", - targetID: "scrollable-div", eventType: "overflow", - dispatchEvent: function () { - document.getElementById("scrolled-div").style.width = "500px"; - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalScrollAreaEvent (MozScrolledAreaChanged, spreading)", - target: function () { return document; }, eventType: "MozScrolledAreaChanged", - dispatchEvent: function () { - document.getElementById("scrollable-div").style.width = "50000px"; - document.getElementById("scrollable-div").style.height = "50000px"; - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalScrollAreaEvent (MozScrolledAreaChanged, shrinking)", - target: function () { return document; }, eventType: "MozScrolledAreaChanged", - dispatchEvent: function () { - document.getElementById("scrollable-div").style.width = "30px"; - document.getElementById("scrollable-div").style.height = "30px"; - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "WidgetKeyboardEvent (keydown of 'a' key without modifiers)", - targetID: "input-text", eventType: "keydown", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_A : MAC_VK_ANSI_A, - {}, "a", "a"); - }, - canRun: function () { - return (kIsMac || kIsWin); - }, - todoMismatch: [], - }, - { description: "WidgetKeyboardEvent (keyup of 'a' key without modifiers)", - targetID: "input-text", eventType: "keydown", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_A : MAC_VK_ANSI_A, - {}, "a", "a"); - }, - canRun: function () { - return (kIsMac || kIsWin); - }, - todoMismatch: [], - }, - { description: "WidgetKeyboardEvent (keypress of 'b' key with Shift)", - targetID: "input-text", eventType: "keypress", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_B : MAC_VK_ANSI_B, - { shiftKey: true }, "B", "B"); - }, - canRun: function () { - return (kIsMac || kIsWin); - }, - todoMismatch: [], - }, - { description: "WidgetKeyboardEvent (keypress of 'c' key with Accel)", - targetID: "input-text", eventType: "keypress", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_C : MAC_VK_ANSI_C, - { accelKey: true }, kIsWin ? "\u0003" : "c", "c"); - }, - canRun: function () { - return (kIsMac || kIsWin); - }, - todoMismatch: [], - }, - { description: "WidgetKeyboardEvent (keyup during composition)", - targetID: "input-text", eventType: "keyup", - dispatchEvent: function () { - setAndObserveCompositionPref(true, () => { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeCompositionChange({ "composition": - { "string": "\u306D", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 }, - "key": { key: "a", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }, - }); - synthesizeComposition({ type: "compositioncommitasis" }); - setAndObserveCompositionPref(null, runNextTest); - }); - return true; - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetKeyboardEvent (keydown during composition)", - targetID: "input-text", eventType: "keydown", - dispatchEvent: function () { - setAndObserveCompositionPref(true, () => { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeCompositionChange({ "composition": - { "string": "\u306D", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - synthesizeComposition({ type: "compositioncommitasis", - key: { key: "KEY_Enter", code: "Enter" } }); - setAndObserveCompositionPref(null, runNextTest); - }); - return true; - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetMouseEvent (mousedown of left button without modifier)", - targetID: "button", eventType: "mousedown", - dispatchEvent: function () { - synthesizeMouseAtCenter(document.getElementById(this.targetID), - { button: 0 }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "WidgetMouseEvent (click of middle button with Shift)", - // XXX I'm not sure why middle click event isn't fired on button element. - targetID: "input-text", eventType: "click", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeMouseAtCenter(document.getElementById(this.targetID), - { button: 1, shiftKey: true, pressure: 0.5 }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "WidgetMouseEvent (mouseup of right button with Alt)", - targetID: "button", eventType: "mouseup", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeMouseAtCenter(document.getElementById(this.targetID), - { button: 2, altKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "WidgetDragEvent", - targetID: "input-text", eventType: "dragstart", - dispatchEvent: function () { - return; - }, - canRun: function () { - todo(false, "WidgetDragEvent isn't tested"); - return false; - }, - todoMismatch: [], - }, - { description: "WidgetTextEvent (text)", - targetID: "input-text", eventType: "text", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeComposition({ type: "compositioncommit", data: "\u306D" }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetCompositionEvent (compositionupdate)", - targetID: "input-text", eventType: "compositionupdate", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeComposition({ type: "compositioncommit", data: "\u30E9\u30FC\u30E1\u30F3" }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "InternalEditorInputEvent (input at key input)", - targetID: "input-text", eventType: "input", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, kIsWin ? WIN_VK_B : MAC_VK_ANSI_B, - { shiftKey: true }, "B", "B"); - }, - canRun: function () { - return (kIsMac || kIsWin); - }, - todoMismatch: [], - }, - { description: "InternalEditorInputEvent (input at composing)", - targetID: "input-text", eventType: "input", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - document.getElementById(this.targetID).focus(); - synthesizeCompositionChange({ "composition": - { "string": "\u30E9\u30FC\u30E1\u30F3", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "InternalEditorInputEvent (input at committing)", - targetID: "input-text", eventType: "input", - dispatchEvent: function () { - synthesizeComposition({ type: "compositioncommitasis" }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetMouseScrollEvent (DOMMouseScroll, vertical)", - targetID: "input-text", eventType: "DOMMouseScroll", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 3, 4, - { deltaY: 30, lineOrPageDeltaY: 2 }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetMouseScrollEvent (DOMMouseScroll, horizontal)", - targetID: "input-text", eventType: "DOMMouseScroll", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 4, 5, - { deltaX: 30, lineOrPageDeltaX: 2, shiftKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetMouseScrollEvent (MozMousePixelScroll, vertical)", - targetID: "input-text", eventType: "MozMousePixelScroll", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 3, 4, - { deltaY: 20, lineOrPageDeltaY: 1, altKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetMouseScrollEvent (MozMousePixelScroll, horizontal)", - targetID: "input-text", eventType: "MozMousePixelScroll", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 4, 5, - { deltaX: 20, lineOrPageDeltaX: 1, ctrlKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetWheelEvent (wheel, vertical)", - targetID: "input-text", eventType: "wheel", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 3, 4, - { deltaY: 20, lineOrPageDeltaY: 1, altKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetWheelEvent (wheel, horizontal)", - targetID: "input-text", eventType: "wheel", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 4, 5, - { deltaX: 20, lineOrPageDeltaX: 1, ctrlKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetWheelEvent (wheel, both)", - targetID: "input-text", eventType: "wheel", - dispatchEvent: function () { - document.getElementById(this.targetID).value = ""; - synthesizeWheel(document.getElementById(this.targetID), 4, 5, - { deltaX: 20, deltaY: 10, - lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetTouchEvent (touchstart)", - target: function () { return document; }, eventType: "touchstart", - dispatchEvent: function () { - synthesizeTouchAtPoint(1, 2, { id: 10, rx: 4, ry: 3, angle: 0, force: 1, shiftKey: true}); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetTouchEvent (touchend)", - target: function () { return document; }, eventType: "touchend", - dispatchEvent: function () { - synthesizeTouchAtPoint(4, 6, { id: 5, rx: 1, ry: 2, angle: 0.5, force: 0.8, ctrlKey: true}); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "InternalFormEvent (reset)", - targetID: "form", eventType: "reset", - dispatchEvent: function () { - document.getElementById("form").reset(); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "WidgetCommandEvent", - targetID: "input-text", eventType: "", - dispatchEvent: function () { - return; - }, - canRun: function () { - todo(false, "WidgetCommandEvent isn't tested"); - return false; - }, - todoMismatch: [], - }, - { description: "InternalClipboardEvent (copy)", - targetID: "input-text", eventType: "copy", - dispatchEvent: function () { - document.getElementById("input-text").value = "go to clipboard!"; - document.getElementById("input-text").focus(); - document.getElementById("input-text").select(); - synthesizeKey("c", { accelKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [ ], - }, - { description: "InternalUIEvent (DOMActivate)", - targetID: "button", eventType: "DOMActivate", - dispatchEvent: function () { - synthesizeMouseAtCenter(document.getElementById(this.targetID), - { button: 0, shiftKey: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalFocusEvent (focus)", - targetID: "input-text", eventType: "focus", - dispatchEvent: function () { - document.getElementById(this.targetID).focus(); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalFocusEvent (blur)", - targetID: "input-text", eventType: "blur", - dispatchEvent: function () { - document.getElementById(this.targetID).blur(); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "WidgetSimpleGestureEvent", - targetID: "", eventType: "", - dispatchEvent: function () { - return; - }, - canRun: function () { - // Simple gesture event may be handled before it comes content. - // So, we cannot test it in this test. - todo(false, "WidgetSimpleGestureEvent isn't tested"); - return false; - }, - todoMismatch: [], - }, - { description: "InternalTransitionEvent (transitionend)", - targetID: "a", eventType: "transitionend", - dispatchEvent: function () { - document.getElementById(this.targetID).focus(); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalAnimationEvent (animationend)", - targetID: "animated-div", eventType: "animationend", - dispatchEvent: function () { - document.getElementById(this.targetID).className = "slidin"; - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalMutationEvent (DOMAttrModified)", - targetID: "animated-div", eventType: "DOMAttrModified", - dispatchEvent: function () { - document.getElementById(this.targetID).setAttribute("x-data", "foo"); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalMutationEvent (DOMNodeInserted)", - targetID: "animated-div", eventType: "DOMNodeInserted", - dispatchEvent: function () { - var div = document.createElement("div"); - div.id = "inserted-div"; - document.getElementById("animated-div").appendChild(div); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "InternalMutationEvent (DOMNodeRemoved)", - targetID: "animated-div", eventType: "DOMNodeRemoved", - dispatchEvent: function () { - document.getElementById("animated-div").removeChild(document.getElementById("inserted-div")); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "PointerEvent (pointerdown)", - targetID: "pointer-target", eventType: "pointerdown", - dispatchEvent: function () { - var elem = document.getElementById(this.targetID); - var rect = elem.getBoundingClientRect(); - synthesizePointer(elem, rect.width/2, rect.height/2, - { type: this.eventType, button: 1, clickCount: 1, inputSource: 2, pressure: 0.25, isPrimary: true }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, - { description: "PointerEvent (pointerup)", - targetID: "pointer-target", eventType: "pointerup", - dispatchEvent: function () { - var elem = document.getElementById(this.targetID); - var rect = elem.getBoundingClientRect(); - synthesizePointer(elem, rect.width/2, rect.height/2, - { type: this.eventType, button: -1, ctrlKey: true, shiftKey: true, altKey: true, isSynthesized: false }); - }, - canRun: function () { - return true; - }, - todoMismatch: [], - }, -]; - -/** - * Sets or clears dom.keyboardevent.dispatch_during_composition and calls the - * given callback when the change is observed. - * - * @param aValue - * Pass null to clear the pref. Otherwise pass a bool. - * @param aCallback - * Called when the pref change is observed. - */ -function setAndObserveCompositionPref(aValue, aCallback) { - let pref = "dom.keyboardevent.dispatch_during_composition"; - let branch = SpecialPowers.Cc["@mozilla.org/preferences-service;1"]. - getService(SpecialPowers.Ci.nsIPrefService). - getBranch(pref); - let obs = SpecialPowers.wrapCallback(function () { - branch.removeObserver("", obs); - // Make sure the code under test sees the change first, so executeSoon(). - SimpleTest.executeSoon(aCallback); - }); - branch.addObserver("", obs, false); - if (aValue === null) { - SpecialPowers.clearUserPref(pref); - } else { - SpecialPowers.setBoolPref(pref, aValue); - } -} - -function doTest(aTest) -{ - if (!aTest.canRun()) { - SimpleTest.executeSoon(runNextTest); - return; - } - gEvent = null; - gCopiedEvent = []; - var target = aTest.target ? aTest.target() : document.getElementById(aTest.targetID); - target.addEventListener(aTest.eventType, onEvent, true); - gCallback = function () { - var description = aTest.description + " (gCallPreventDefault=" + gCallPreventDefault + ")"; - target.removeEventListener(aTest.eventType, onEvent, true); - ok(gEvent !== null, description + ": failed to get duplicated event"); - ok(gCopiedEvent.length > 0, description + ": count of attribute of the event must be larger than 0"); - for (var i = 0; i < gCopiedEvent.length; ++i) { - var name = gCopiedEvent[i].name; - if (name == "rangeOffset") { - todo(false, description + ": " + name + " attribute value is never reset (" + gEvent[name] + ")"); - } else if (name == "eventPhase") { - is(gEvent[name], 0, description + ": mismatch with fixed value (" + name + ")"); - } else if (name == "rangeParent" || name == "currentTarget") { - is(gEvent[name], null, description + ": mismatch with fixed value (" + name + ")"); - } else if (aTest.todoMismatch.indexOf(name) >= 0) { - todo_is(gEvent[name], gCopiedEvent[i].value, description + ": mismatch (" + name + ")"); - } else if (name == "offsetX" || name == "offsetY") { - // do nothing; these are defined to return different values during event dispatch - // vs not during event dispatch - } else { - is(gEvent[name], gCopiedEvent[i].value, description + ": mismatch (" + name + ")"); - } - } - if (!testWillCallRunNextTest) { - runNextTest(); - } - }; - var testWillCallRunNextTest = aTest.dispatchEvent(); -} - -var gIndex = -1; -function runNextTest() -{ - if (++gIndex == kTests.length) { - if (gCallPreventDefault) { - finish(); - return; - } - // Test with a call of preventDefault() of the events. - gCallPreventDefault = true; - gIndex = -1; - // Restoring the initial state of all elements. - document.getElementById("scrollable-div").style.height = "30px"; - document.getElementById("scrollable-div").style.width = "30px"; - document.getElementById("scrolled-div").style.height = "10px"; - document.getElementById("scrolled-div").style.width = "10px"; - document.getElementById("input-text").value = ""; - document.getElementById("animated-div").className = ""; - document.getElementById("animated-div").removeAttribute("x-data"); - if (document.activeElement) { - document.activeElement.blur(); - } - window.requestAnimationFrame(function () { - setTimeout(runNextTest, 0); - }); - return; - } - doTest(kTests[gIndex]); -} - -function init() -{ - SpecialPowers.pushPrefEnv({"set":[["middlemouse.contentLoadURL", false], - ["middlemouse.paste", false], - ["general.autoScroll", false], - ["mousewheel.default.action", 0], - ["mousewheel.default.action.override_x", -1], - ["mousewheel.with_shift.action", 0], - ["mousewheel.with_shift.action.override_x", -1], - ["mousewheel.with_control.action", 0], - ["mousewheel.with_control.action.override_x", -1], - ["mousewheel.with_alt.action", 0], - ["mousewheel.with_alt.action.override_x", -1], - ["mousewheel.with_meta.action", 0], - ["mousewheel.with_meta.action.override_x", -1]]}, runNextTest); -} - -function finish() -{ - SimpleTest.finish(); -} - -SimpleTest.waitForFocus(init); - -</script> -</body> diff --git a/widget/tests/test_bug1123480.xul b/widget/tests/test_bug1123480.xul deleted file mode 100644 index 56ce0ed10..000000000 --- a/widget/tests/test_bug1123480.xul +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=1123480 ---> -<window title="Mozilla Bug 1123480" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onload="RunTest();"> - <title>nsTransferable PBM Overflow Selection Test</title> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - - <script type="application/javascript"> - <![CDATA[ - // Boilerplate constructs - var SmallDataset = 100000; // Hundred thousand bytes - - // Create 1 Mo of sample garbage text - var Ipsum = ""; // Select text from this - for (var Iter = 0; Iter < SmallDataset; Iter++) { - Ipsum += Math.random().toString(36) + ' '; - } - - function RunTest() { - // Construct a nsIFile object for access to file methods - Components.utils.import("resource://gre/modules/FileUtils.jsm"); - var clipboardFile = FileUtils.getFile("TmpD", ["clipboardcache"]); - - // Sanitize environment - if (clipboardFile.exists()) { - clipboardFile.remove(false); - } - ok(!clipboardFile.exists(), "failed to presanitize the environment"); - - // Overflow a nsTransferable region by using the clipboard helper - const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); - gClipboardHelper.copyString(Ipsum); - - // Disabled private browsing mode should cache large selections to disk - ok(clipboardFile.exists(), "correctly saved memory by caching to disk"); - - // Sanitize environment again - if (clipboardFile.exists()) { - clipboardFile.remove(false); - } - ok(!clipboardFile.exists(), "failed to postsanitize the environment"); - - // Repeat procedure of plain text selection with private browsing enabled - Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); - var Winpriv = window.open("about:blank", "_blank", "chrome, width=500, height=200, private"); - ok(Winpriv, "failed to open private window"); - ok(PrivateBrowsingUtils.isContentWindowPrivate(Winpriv), "correctly used a private window context"); - - // Select plaintext in private channel - Components.utils.import('resource://gre/modules/Services.jsm'); - const nsTransferable = Components.Constructor("@mozilla.org/widget/transferable;1", "nsITransferable"); - const nsSupportsString = Components.Constructor("@mozilla.org/supports-string;1", "nsISupportsString"); - var Loadctx = PrivateBrowsingUtils.privacyContextFromWindow(Winpriv); - var Transfer = nsTransferable(); - var Suppstr = nsSupportsString(); - Suppstr.data = Ipsum; - Transfer.init(Loadctx); - Transfer.addDataFlavor("text/plain"); - Transfer.setTransferData("text/plain", Suppstr, Ipsum.length); - Services.clipboard.setData(Transfer, null, Services.clipboard.kGlobalClipboard); - - // Enabled private browsing mode should not cache any selection to disk - ok(!clipboardFile.exists(), "did not violate private browsing mode"); - } - ]]> - </script> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1123480" - target="_blank">Mozilla Bug 1123480</a> - </body> -</window> diff --git a/widget/tests/test_bug1151186.html b/widget/tests/test_bug1151186.html deleted file mode 100644 index 391e53d78..000000000 --- a/widget/tests/test_bug1151186.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=1151186 ---> -<head> - <meta charset="utf-8"> - <title>Test for Bug 1151186</title> - <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="chrome://global/skin"/> - <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> - <script type="application/javascript"> - - /** Test for Bug 1151186 **/ - SimpleTest.waitForExplicitFinish(); - - document.addEventListener("focus", () => { - document.getElementById("editor").focus(); - SimpleTest.executeSoon(runTests); - }); - - function runTests() - { - is(document.activeElement, document.getElementById("editor"), - "The div element should be focused"); - var utils = SpecialPowers.getDOMWindowUtils(window); - is(utils.IMEStatus, utils.IME_STATUS_ENABLED, - "IME should be enabled"); - SimpleTest.finish(); - } - </script> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151186">Mozilla Bug 1151186</a> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<div id="editor" contenteditable="true"></div> -<pre id="test"> -</pre> -</body> -</html> diff --git a/widget/tests/test_bug343416.xul b/widget/tests/test_bug343416.xul deleted file mode 100644 index 1c31bdf54..000000000 --- a/widget/tests/test_bug343416.xul +++ /dev/null @@ -1,202 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=343416 ---> -<window title="Mozilla Bug 343416" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=343416">Mozilla Bug 343416</a> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -/** Test for Bug 343416 **/ -SimpleTest.waitForExplicitFinish(); - -// Observer: -var idleObserver = -{ - QueryInterface: function _qi(iid) - { - if (iid.equals(Components.interfaces.nsISupports) || - iid.equals(Components.interfaces.nsIObserver)) - { - return this; - } - throw Components.results.NS_ERROR_NO_INTERFACE; - }, - observe: function _observe(subject, topic, data) - { - if (topic != "idle") - return; - - var diff = Math.abs(data - newIdleSeconds * 1000); - -// ok (diff < 5000, "The idle time should have increased by roughly 6 seconds, " + -// "as that's when we told this listener to fire."); -// if (diff >= 5000) -// alert(data + " " + newIdleSeconds); - - // Attempt to get to the nsIIdleService - var subjectOK = false; - try { - var idleService = subject.QueryInterface(nsIIdleService); - subjectOK = true; - } - catch (ex) - {} - ok(subjectOK, "The subject of the notification should be the " + - "nsIIdleService."); - - // Attempt to remove ourselves. - var removedObserver = false; - try { - idleService.removeIdleObserver(this, newIdleSeconds); - removedObserver = true; - } - catch (ex) - {} - ok(removedObserver, "We should be able to remove our observer here."); - finishedListenerOK = true; - if (finishedTimeoutOK) - { - clearTimeout(testBailout); - finishThisTest(); - } - } -}; - - -const nsIIdleService = Components.interfaces.nsIIdleService; -const nsIISCID = "@mozilla.org/widget/idleservice;1"; -var idleService = null; -try -{ - idleService = Components.classes[nsIISCID].getService(nsIIdleService); -} -catch (ex) -{} - -ok(idleService, "nsIIdleService should exist and be implemented on all tier 1 platforms."); - -var idleTime = null; -var gotIdleTime = false; -try -{ - idleTime = idleService.idleTime; - gotIdleTime = true; -} -catch (ex) -{} - -ok (gotIdleTime, "Getting the idle time should not fail " + - "in normal circumstances on any tier 1 platform."); - -// Now we set up a timeout to sanity-test the idleTime after 5 seconds -setTimeout(testIdleTime, 5000); -var startTimeStamp = Date.now(); - -// Now we add the listener: -var newIdleSeconds = Math.floor(idleTime / 1000) + 6; -var addedObserver = false; -try -{ - idleService.addIdleObserver(idleObserver, newIdleSeconds); - addedObserver = true; -} -catch (ex) -{} - -ok(addedObserver, "The nsIIdleService should allow us to add an observer."); - -addedObserver = false; -try -{ - idleService.addIdleObserver(idleObserver, newIdleSeconds); - addedObserver = true; -} -catch (ex) -{} - -ok(addedObserver, "The nsIIdleService should allow us to add the same observer again."); - -var removedObserver = false; -try -{ - idleService.removeIdleObserver(idleObserver, newIdleSeconds); - removedObserver = true; -} -catch (ex) -{} - -ok(removedObserver, "The nsIIdleService should allow us to remove the observer just once."); - -function testIdleTime() -{ - var gotIdleTime = false - try - { - var newIdleTime = idleService.idleTime; - gotIdleTime = true - } - catch (ex) - {} - ok(gotIdleTime, "Getting the idle time should not fail " + - "in normal circumstances on any tier 1 platform."); - // Get the time difference, remove the approx. 5 seconds that we've waited, - // should be very close to 0 left. - var timeDiff = Math.abs((newIdleTime - idleTime) - - (Date.now() - startTimeStamp)); - - var timePassed = Date.now() - startTimeStamp; - var idleTimeDiff = newIdleTime - idleTime; - // 1.5 second leniency. - ok(timeDiff < 1500, "The idle time should have increased by roughly the " + - "amount of time it took for the timeout to fire. " + - "You didn't touch the mouse or keyboard during the " + - "test did you?"); - finishedTimeoutOK = true; -} - -// make sure we still exit when the listener and/or setTimeout don't fire: -var testBailout = setTimeout(finishThisTest, 12000); -var finishedTimeoutOK = false, finishedListenerOK = false; -function finishThisTest() -{ - ok(finishedTimeoutOK, "We set a timeout and it should have fired by now."); - ok(finishedListenerOK, "We added a listener and it should have been called by now."); - if (!finishedListenerOK) - { - var removedListener = false; - try - { - idleService.removeIdleObserver(idleObserver, newIdleSeconds); - removedListener = true; - } - catch (ex) - {} - - ok(removedListener, "We added a listener and we should be able to remove it."); - } - // Done: - SimpleTest.finish(); -} - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug413277.html b/widget/tests/test_bug413277.html deleted file mode 100644 index dfb1ac8d4..000000000 --- a/widget/tests/test_bug413277.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=413277 ---> -<head> - <title>Test for Bug 413277</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=413277">Mozilla Bug 413277</a> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -<script class="testbody" type="application/javascript"> - var atts='width=100, height=100, top=100, screenY=100'; - atts += ', left=100, screenX=100, toolbar=no'; - atts += ', location=no, directories=no, status=no'; - atts += ', menubar=no, scrollbars=no, resizable=no'; - var newWindow = window.open('_blank', 'win_name', atts); - - newWindow.resizeBy(1000000, 1000000); - SimpleTest.is(newWindow.outerWidth, newWindow.screen.availWidth, true); - SimpleTest.is(newWindow.outerHeight, newWindow.screen.availHeight, true); - SimpleTest.is(newWindow.screenY, newWindow.screen.availTop, true); - SimpleTest.is(newWindow.screenX, newWindow.screen.availLeft, true); - - newWindow.close(); -</script> -</pre> -</body> diff --git a/widget/tests/test_bug428405.xul b/widget/tests/test_bug428405.xul deleted file mode 100644 index 365480468..000000000 --- a/widget/tests/test_bug428405.xul +++ /dev/null @@ -1,167 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> - -<window id="window1" title="Test Bug 428405" - onload="setGlobals(); loadFirstTab();" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> - <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"/> - - <tabbox id="tabbox" flex="100%"> - <tabs> - <tab label="Tab 1"/> - <tab label="Tab 2"/> - </tabs> - <tabpanels flex="100%"> - <browser onload="configureFirstTab();" id="tab1browser" flex="100%"/> - <browser onload="configureSecondTab();" id="tab2browser" flex="100%"/> - </tabpanels> - </tabbox> - - <script type="application/javascript"><![CDATA[ - - SimpleTest.waitForExplicitFinish(); - - var gCmdOptYReceived = false; - - // Look for a cmd-opt-y event. - function onKeyPress(aEvent) { - gCmdOptYReceived = false; - if (String.fromCharCode(aEvent.charCode) != 'y') - return; - if (aEvent.ctrlKey || aEvent.shiftKey || !aEvent.metaKey || !aEvent.altKey) - return; - gCmdOptYReceived = true; - } - - function setGlobals() { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. - getService(Components.interfaces.nsIWindowMediator); - gChromeWindow = wm.getMostRecentWindow("navigator:browser"); - // For some reason, a global <key> element's oncommand handler only gets - // invoked if the focus is outside both of the <browser> elements - // (tab1browser and tab2browser). So, to make sure we can see a - // cmd-opt-y event in window1 (if one is available), regardless of where - // the focus is in this window, we need to add a "keypress" event - // listener to gChromeWindow, and then check (in onKeyPress()) to see if - // it's a cmd-opt-y event. - gChromeWindow.addEventListener("keypress", onKeyPress, false); - } - - // 1) Start loading first tab. - // 6) Start reloading first tab. - function loadFirstTab() { - var browser = document.getElementById("tab1browser"); - browser.loadURI("data:text/html;charset=utf-8,<body><h2>First Tab</h2><p><input type='submit' value='Button' id='button1'/></body>", null, null); - } - - function configureFirstTab() { - try { - var button = document.getElementById("tab1browser").contentDocument.getElementById("button1"); - button.addEventListener("click", onFirstTabButtonClicked, false); - button.focus(); - if (document.getElementById("tabbox").selectedIndex == 0) { - // 2) When first tab has finished loading (while first tab is - // focused), hit Return to trigger the action of first tab's - // button. - synthesizeNativeReturnKey(); - } else { - // 7) When first tab has finished reloading (while second tab is - // focused), start loading second tab. - loadSecondTab(); - } - } catch(e) { - } - } - - // 8) Start loading second tab. - function loadSecondTab() { - var browser = document.getElementById("tab2browser"); - browser.loadURI("data:text/html;charset=utf-8,<body><h2>Second Tab</h2><p><input type='submit' value='Button' id='button1'/></body>", null, null); - } - - function configureSecondTab() { - try { - var button = document.getElementById("tab2browser").contentDocument.getElementById("button1"); - button.addEventListener("click", onSecondTabButtonClicked, false); - button.focus(); - if (document.getElementById("tabbox").selectedIndex == 1) { - // 9) When second tab has finished loading (while second tab is - // focused), hit Return to trigger action of second tab's - // button. - synthesizeNativeReturnKey(); - } - } catch(e) { - } - } - - // 3) First tab's button clicked. - function onFirstTabButtonClicked() { - switchToSecondTabAndReloadFirst(); - } - - // 10) Second tab's button clicked. - function onSecondTabButtonClicked() { - switchToFirstTab(); - } - - function switchToSecondTabAndReloadFirst() { - // 4) Switch to second tab. - document.getElementById("tabbox").selectedIndex = 1; - // 5) Start reloading first tab (while second tab is focused). - loadFirstTab(); - } - - function switchToFirstTab() { - // 11) Switch back to first tab. - document.getElementById("tabbox").selectedIndex = 0; - doCmdY(); - } - - function doCmdY() { - // 12) Back in first tab, try cmd-y. - gCmdOptYReceived = false; - if (!synthesizeNativeCmdOptY(finishTest)) { - ok(false, "Failed to synthesize native key"); - finishTest(); - } - } - - function finishTest() { - // 13) Check result. - is(gCmdOptYReceived, true); - - SimpleTest.finish(); - } - - // synthesizeNativeReturnKey() and synthesizeNativeCmdOptY() are needed - // because their synthesizeKey() counterparts don't work properly -- the - // latter make this test succeed when it should fail. - - // The 'aNativeKeyCode', 'aCharacters' and 'aUnmodifiedCharacters' - // parameters used below (in synthesizeNativeReturnKey() and - // synthesizeNativeCmdOptY()) were confirmed accurate using the - // DebugEventsPlugin v1.01 from bmo bug 441880. - - function synthesizeNativeReturnKey() { - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Return, {}, "\u000a", "\u000a"); - } - - function synthesizeNativeCmdOptY(aCallback) { - return synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Y, {metaKey:1, altKey:1}, "y", "y", aCallback); - } - - ]]></script> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - -</window> diff --git a/widget/tests/test_bug429954.xul b/widget/tests/test_bug429954.xul deleted file mode 100644 index 9b617ed4d..000000000 --- a/widget/tests/test_bug429954.xul +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=429954 ---> -<window title="Mozilla Bug 429954" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -SimpleTest.waitForFocus(function () { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. - getService(Components.interfaces.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - win.maximize(); - var maxX = win.screenX, maxY = win.screenY; - var maxWidth = win.outerWidth, maxHeight = win.outerHeight; - win.restore(); - - window.open("window_bug429954.xul", "_blank", - "chrome,resizable,width=" + maxWidth + ",height=" + maxHeight + - "screenX=" + maxX + "screenY=" + maxY); -}); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug444800.xul b/widget/tests/test_bug444800.xul deleted file mode 100644 index 14d572baa..000000000 --- a/widget/tests/test_bug444800.xul +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" - type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=444800 ---> -<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - title="Mozilla Bug 444800" onload="initAndRunTests()"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=444800" - target="_blank">Mozilla Bug 444800</a> - <p/> - <img id="bitmapImage" src="data:image/bmp;base64,Qk2KAwAAAAAAAIoAAAB8AAAADwAAABAAAAABABgAAAAAAAADAAASCwAAEgsAAAAAAAAAAAAAAAD%2FAAD%2FAAD%2FAAAAAAAA%2FwEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F0vf%2FAABc8tKY%2F%2F%2F%2FyNfq3Mi9%2F%2F%2F70vf%2FAABP8s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABB8s2R5f%2F%2FAAB5LgAA%2F%2B7Czff%2FAABB7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABB99KRpdz%2FAAAAAAAA4Ktm0vv%2FAABB7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABB7teYQZHNkS4AebfImAAA1%2FfyAABP7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABByMiYAAB5159P0v%2F%2FAABBwtKrAABc7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABPcIJwAAAA%2B%2BW3%2F%2F%2F%2FAHC3gnBBAABP7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2Fzff%2FAABcAAAAmE8A%2F%2F%2Fy%2F%2F%2F%2Fn9LyAAAAAAAA7s2Y%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FzfL%2FAABcAAAA4LFw%2F%2F%2F%2F%2F%2F%2F%2F4P%2F%2FAAB5AAAA7s2R%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F0vf%2FAABmXAAA%2F%2B7I%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FXJ%2FSAAAA8s2Y%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAA"/> - <p/> - <pre id="test"> - </pre> - </body> - - <script class="testbody" type="application/javascript"> - <![CDATA[ -const knsIClipboard = Components.interfaces.nsIClipboard; - -function copyImageToClipboard() -{ - var tmpNode = document.popupNode; - document.popupNode = document.getElementById("bitmapImage"); - - const kCmd = "cmd_copyImageContents"; - var controller = top.document.commandDispatcher - .getControllerForCommand(kCmd); - ok((controller && controller.isCommandEnabled(kCmd)), "have copy command"); - controller.doCommand(kCmd); - - document.popupNode = tmpNode; -} - -function getLoadContext() { - const Ci = Components.interfaces; - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); -} - -function runImageClipboardTests(aCBSvc, aImageType) -{ - // Verify that hasDataMatchingFlavors() is working correctly. - var typeArray = [ aImageType ]; - var hasImage = aCBSvc.hasDataMatchingFlavors(typeArray, typeArray.length, - knsIClipboard.kGlobalClipboard); - ok(hasImage, aImageType + " - hasDataMatchingFlavors()"); - - // Verify that getData() is working correctly. - var xfer = Components.classes["@mozilla.org/widget/transferable;1"] - .createInstance(Components.interfaces.nsITransferable); - xfer.init(getLoadContext()); - xfer.addDataFlavor(aImageType); - aCBSvc.getData(xfer, knsIClipboard.kGlobalClipboard); - - var typeObj = {}, dataObj = {}, lenObj = {}; - xfer.getAnyTransferData(typeObj, dataObj, lenObj); - var gotValue = (null != dataObj.value); - ok(gotValue, aImageType + " - getData() returned a value"); - if (gotValue) - { - const knsIInputStream = Components.interfaces.nsIInputStream; - var imgStream = dataObj.value.QueryInterface(knsIInputStream); - ok((null != imgStream), aImageType + " - got an nsIInputStream"); - var bytesAvailable = imgStream.available(); - ok((bytesAvailable > 10), aImageType + " - got some data"); - } -} - -function initAndRunTests() -{ - SimpleTest.waitForExplicitFinish(); - - copyImageToClipboard(); - - var cbSvc = Components.classes["@mozilla.org/widget/clipboard;1"] - .getService(knsIClipboard); - - // Work around a problem on Windows where clipboard is not ready after copy. - setTimeout(function() { runTests(cbSvc); }, 0); -} - -function runTests(aCBSvc) -{ - runImageClipboardTests(aCBSvc, "image/png"); - runImageClipboardTests(aCBSvc, "image/jpg"); - runImageClipboardTests(aCBSvc, "image/jpeg"); - - SimpleTest.finish(); -} - -]]> -</script> -</window> diff --git a/widget/tests/test_bug466599.xul b/widget/tests/test_bug466599.xul deleted file mode 100644 index a70f47add..000000000 --- a/widget/tests/test_bug466599.xul +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=466599 ---> -<window title="Mozilla Bug 466599" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onload="initAndRunTests()"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - - <!-- test code goes here --> - <script class="testbody" type="application/javascript"> - <![CDATA[ - - /** Test for Bug 466599 **/ - -function getLoadContext() { - const Ci = Components.interfaces; - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); -} - -function copyToClipboard(txt) -{ - var clipid = Components.interfaces.nsIClipboard; - var clip = - Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(clipid); - if (!clip) - return false; - var trans = - Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); - if (!trans) - return false; - trans.init(getLoadContext()); - trans.addDataFlavor('text/html'); - var str = - Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString); - var copytext = txt; - str.data = copytext; - trans.setTransferData("text/html",str,copytext.length*2); - if (!clip) - return false; - clip.setData(trans,null,clipid.kGlobalClipboard); - return true; -} - -function readFromClipboard() -{ - var clipid = Components.interfaces.nsIClipboard; - var clip = - Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(clipid); - if (!clip) - return; - var trans = - Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); - if (!trans) - return; - trans.init(getLoadContext()); - trans.addDataFlavor('text/html'); - clip.getData(trans,clipid.kGlobalClipboard); - var str = new Object(); - var strLength = new Object(); - trans.getTransferData("text/html",str,strLength); - if (str) - str = str.value.QueryInterface(Components.interfaces.nsISupportsString); - if (str) - pastetext = str.data.substring(0,strLength.value / 2); - return pastetext; -} - -function encodeHtmlEntities(s) -{ - var result = ''; - for (var i = 0; i < s.length; i++) { - var c = s.charAt(i); - result += {'<':'<', '>':'>', '&':'&', '"':'"'}[c] || c; - } - return result; -} - -function initAndRunTests() -{ - var source = '<p>Lorem ipsum</p>'; - var expect = new RegExp('<html>.*charset=utf-8.*' + source + '.*</html>', 'im'); - - var result = copyToClipboard(source); - ok(result, "copied HTML data to system pasteboard"); - - result = readFromClipboard(); - ok(expect.test(result), "data on system pasteboard is wrapped with charset metadata"); - - $("display").innerHTML = - '<em>source:</em> <pre>' + encodeHtmlEntities(source) + '</pre><br/>' + - '<em>result:</em> <pre>' + encodeHtmlEntities(result) + '</pre>'; -} - - ]]> - </script> -</window> diff --git a/widget/tests/test_bug478536.xul b/widget/tests/test_bug478536.xul deleted file mode 100644 index e83ff6032..000000000 --- a/widget/tests/test_bug478536.xul +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=478536 ---> -<window title="Mozilla Bug 478536" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <title>Test for Bug 478536</title> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("window_bug478536.xul", "_blank", - "chrome,width=600,height=600"); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug485118.xul b/widget/tests/test_bug485118.xul deleted file mode 100644 index bbd5daed9..000000000 --- a/widget/tests/test_bug485118.xul +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=485118 ---> -<window title="Mozilla Bug 485118" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<hbox height="300"> - <vbox width="300"> - <scrollbar orient="horizontal" - maxpos="10000" - pageincrement="1" - id="horizontal"/> - <scrollbar orient="horizontal" - maxpos="10000" - pageincrement="1" - style="-moz-appearance: scrollbar-small;" - id="horizontalSmall"/> - <hbox flex="1"> - <scrollbar orient="vertical" - maxpos="10000" - pageincrement="1" - id="vertical"/> - <scrollbar orient="vertical" - maxpos="10000" - pageincrement="1" - style="-moz-appearance: scrollbar-small;" - id="verticalSmall"/> - <spacer flex="1"/> - </hbox> - </vbox> -</hbox> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -function runTest() { - ["horizontal", "vertical"].forEach(function (orient) { - ["", "Small"].forEach(function (size) { - var elem = document.getElementById(orient + size); - var thumbRect = document.getAnonymousElementByAttribute(elem, 'sbattr', 'scrollbar-thumb').getBoundingClientRect(); - var sizeToCheck = orient == "horizontal" ? "width" : "height"; - // var expectedSize = size == "Small" ? 19 : 26; - var expectedSize = 26; - is(thumbRect[sizeToCheck], expectedSize, size + " scrollbar has wrong minimum " + sizeToCheck); - }); - }); - SimpleTest.finish(); -} -window.addEventListener("load", runTest, false); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug517396.xul b/widget/tests/test_bug517396.xul deleted file mode 100644 index 18a1b8f59..000000000 --- a/widget/tests/test_bug517396.xul +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=517396 ---> -<window title="Mozilla Bug 517396" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -SimpleTest.waitForFocus(function () { - // this test fails on Linux, bug 526236 - if (navigator.platform.indexOf("Lin") != -1) { - ok(true, "disabled on Linux"); - SimpleTest.finish(); - return; - } - - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]. - getService(Components.interfaces.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - var oldWidth = win.outerWidth, oldHeight = win.outerHeight; - win.maximize(); - var newWidth = win.outerWidth, newHeight = win.outerHeight; - win.moveBy(10, 0); - var sizeShouldHaveChanged = !navigator.platform.match(/Mac/); - var compFunc = sizeShouldHaveChanged ? isnot : is; - var not = sizeShouldHaveChanged ? "" : "not "; - compFunc(win.outerWidth, newWidth, "moving a maximized window should " + not + "have changed its width"); - compFunc(win.outerHeight, newHeight, "moving a maximized window should " + not + "have changed its height"); - win.restore(); - is(win.outerWidth, oldWidth, "restored window has wrong width"); - is(win.outerHeight, oldHeight, "restored window has wrong height"); - SimpleTest.finish(); -}); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug522217.xul b/widget/tests/test_bug522217.xul deleted file mode 100644 index 22aa1a061..000000000 --- a/widget/tests/test_bug522217.xul +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=522217 ---> -<window title="Mozilla Bug 522217" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -SimpleTest.waitForFocus(function () { - window.open("window_bug522217.xul", "_blank", - "chrome,resizable,width=400,height=300"); -}); - - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug538242.xul b/widget/tests/test_bug538242.xul deleted file mode 100644 index 9ebab5259..000000000 --- a/widget/tests/test_bug538242.xul +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=538242 ---> -<window title="Mozilla Bug 538242" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -if (navigator.platform.startsWith("Win")) { - SimpleTest.expectAssertions(0, 1); -} - -SimpleTest.waitForExplicitFinish(); - -SimpleTest.waitForFocus(function () { - if (navigator.platform.indexOf("Lin") != -1) { - ok(true, "This test is disabled on Linux because it expects moving windows to be synchronous which is not guaranteed on Linux."); - SimpleTest.finish(); - return; - } - - var win = window.open("window_bug538242.xul", "_blank", - "chrome=1,width=400,height=300,left=100,top=100"); - SimpleTest.waitForFocus(function () { - is(win.screenX, 100, "window should open at 100, 100"); - is(win.screenY, 100, "window should open at 100, 100"); - var [oldX, oldY] = [win.screenX, win.screenY]; - win.moveTo(0, 0); - isnot(win.screenX, oldX, "window should have moved to a point near 0, 0"); - isnot(win.screenY, oldY, "window should have moved to a point near 0, 0"); - win.close(); - SimpleTest.finish(); - }, win); -}); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug565392.html b/widget/tests/test_bug565392.html deleted file mode 100644 index da6999ec6..000000000 --- a/widget/tests/test_bug565392.html +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=565392 ---> -<head> - <title>Test for Bug 565392</title> - <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=565392">Mozilla Bug 565392</a> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -<script type="application/javascript"> - -/** Test for Bug 565392 **/ - - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - const Cc = SpecialPowers.Cc; - const Ci = SpecialPowers.Ci; - var ds = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - var dir1 = ds.get("ProfD", Ci.nsIFile); - var clipboard = Cc["@mozilla.org/widget/clipboard;1"] - .getService(Ci.nsIClipboard); - - function getLoadContext() { - return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); - } - - function getTransferableFile(file) { - var transferable = Cc['@mozilla.org/widget/transferable;1'] - .createInstance(Ci.nsITransferable); - transferable.init(getLoadContext()); - transferable.setTransferData("application/x-moz-file", file, 0); - return transferable; - } - - function setClipboardData(transferable) { - clipboard.setData(transferable, null, 1); - } - - function getClipboardData(mime) { - var transferable = Cc['@mozilla.org/widget/transferable;1'] - .createInstance(Ci.nsITransferable); - transferable.init(getLoadContext()); - transferable.addDataFlavor(mime); - clipboard.getData(transferable, 1); - var data = {}; - transferable.getTransferData(mime, data, {}) ; - return data; - } - -setClipboardData(getTransferableFile(dir1)) -is(clipboard.hasDataMatchingFlavors(["application/x-moz-file"], 1,1), true); -var data = getClipboardData("application/x-moz-file"); -var file = data.value.QueryInterface(Ci.nsIFile); -ok(file.isDirectory(), true); -is(file.target, dir1.target, true); - -</script> -</pre> -</body> -</html> diff --git a/widget/tests/test_bug586713.xul b/widget/tests/test_bug586713.xul deleted file mode 100644 index e91eb7931..000000000 --- a/widget/tests/test_bug586713.xul +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Native menu system tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("bug586713_window.xul", "bug586713_window", - "chrome,width=600,height=600"); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug593307.xul b/widget/tests/test_bug593307.xul deleted file mode 100644 index 0b6e4d4a1..000000000 --- a/widget/tests/test_bug593307.xul +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=593307 ---> -<window title="Mozilla Bug 593307" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); - -function finish() { - offscreenWindow.close(); - SimpleTest.finish(); -} - -var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIWebNavigation) - .QueryInterface(Components.interfaces.nsIDocShellTreeItem) - .rootTreeItem - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindow); - -var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xul", "", - "dialog=no,chrome,width=200,height=200,screenX=-3000,screenY=-3000", - SimpleTest, finish); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug596600.xul b/widget/tests/test_bug596600.xul deleted file mode 100644 index 0468f7d4d..000000000 --- a/widget/tests/test_bug596600.xul +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Native mouse event tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; -const NSMouseMoved = 5; - -var gLeftWindow, gRightWindow, gIFrame; -var gExpectedEvents = []; - -function moveMouseTo(x, y, andThen) { - var utils = gLeftWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - utils.sendNativeMouseEvent(x, y, NSMouseMoved, 0, gLeftWindow.documentElement); - SimpleTest.executeSoon(andThen); -} - -function openWindows() { - gLeftWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200'); - SimpleTest.waitForFocus(function () { - gRightWindow = open('empty_window.xul', '', 'chrome,screenX=300,screenY=50,width=200,height=200'); - SimpleTest.waitForFocus(attachIFrameToRightWindow, gRightWindow); - }, gLeftWindow); -} - -function attachIFrameToRightWindow() { - gIFrame = gLeftWindow.document.createElementNS(XUL_NS, "iframe"); - gIFrame.setAttribute("type", "content"); - gIFrame.setAttribute("clickthrough", "never"); - gIFrame.setAttribute("src", "data:text/html,<!DOCTYPE html>Content page"); - gIFrame.style.width = "100px"; - gIFrame.style.height = "100px"; - gIFrame.style.margin = "50px"; - gLeftWindow.document.documentElement.appendChild(gIFrame); - gIFrame.contentWindow.addEventListener("load", function (e) { - gIFrame.removeEventListener("load", arguments.callee, false); - test1(); - }, false); -} - -function test1() { - // gRightWindow is active, gLeftWindow is inactive. - moveMouseTo(0, 0, function () { - var expectMouseOver = false, expectMouseOut = false; - function mouseOverListener(e) { - ok(expectMouseOver, "Got expected mouseover at " + e.screenX + ", " + e.screenY); - expectMouseOver = false; - } - function mouseOutListener(e) { - ok(expectMouseOut, "Got expected mouseout at " + e.screenX + ", " + e.screenY); - expectMouseOut = false; - } - gLeftWindow.addEventListener("mouseover", mouseOverListener, false); - gLeftWindow.addEventListener("mouseout", mouseOutListener, false); - - // Move into the left window - expectMouseOver = true; - moveMouseTo(80, 80, function () { - ok(!expectMouseOver, "Should have got mouseover event"); - - // Move over the iframe, which has clickthrough="never". - expectMouseOut = true; - moveMouseTo(150, 150, function () { - ok (!expectMouseOut, "Should have got mouseout event"); - gLeftWindow.removeEventListener("mouseover", mouseOverListener, false); - gLeftWindow.removeEventListener("mouseout", mouseOutListener, false); - test2(); - }); - }); - }); -} - -function test2() { - // Make the iframe cover the whole window. - gIFrame.style.margin = "0"; - gIFrame.style.width = gIFrame.style.height = "200px"; - - // Add a box to the iframe at the left edge. - var doc = gIFrame.contentDocument; - var box = doc.createElement("div"); - box.setAttribute("id", "box"); - box.style.position = "absolute"; - box.style.left = "0"; - box.style.top = "50px"; - box.style.width = "100px"; - box.style.height = "100px"; - box.style.backgroundColor = "green"; - doc.body.appendChild(box); - - ok(!box.matches(":hover"), "Box shouldn't be hovered (since the mouse isn't over it and since it's in a non-clickthrough iframe in a background window)"); - - // A function to waitForFocus and then wait for synthetic mouse - // events to happen. Note that those happen off the refresh driver, - // and happen after animation frame requests. - function changeFocusAndAwaitSyntheticMouse(callback, winToFocus, - elementToWatchForMouseEventOn) { - function mouseWatcher() { - elementToWatchForMouseEventOn.removeEventListener("mouseover", - mouseWatcher, - false); - elementToWatchForMouseEventOn.removeEventListener("mouseout", - mouseWatcher, - false); - SimpleTest.executeSoon(callback); - } - elementToWatchForMouseEventOn.addEventListener("mouseover", - mouseWatcher, - false); - elementToWatchForMouseEventOn.addEventListener("mouseout", - mouseWatcher, - false); - // Just pass a dummy function to waitForFocus; the mouseout/over listener - // will actually handle things for us. - SimpleTest.waitForFocus(function() {}, winToFocus); - } - - // Move the mouse over the box. - moveMouseTo(100, 150, function () { - ok(!box.matches(":hover"), "Box shouldn't be hovered (since it's in a non-clickthrough iframe in a background window)"); - // Activate the left window. - changeFocusAndAwaitSyntheticMouse(function () { - ok(gIFrame.matches(":hover"), "iframe should be hovered"); - ok(box.matches(":hover"), "Box should be hovered"); - // De-activate the window (by activating the right window). - changeFocusAndAwaitSyntheticMouse(function () { - ok(!gIFrame.matches(":hover"), "iframe shouldn't be hovered"); - ok(!box.matches(":hover"), "Box shouldn't be hovered"); - // Re-activate it. - changeFocusAndAwaitSyntheticMouse(function () { - ok(gIFrame.matches(":hover"), "iframe should be hovered"); - ok(box.matches(":hover"), "Box should be hovered"); - // Unhover box and iframe by moving the mouse outside the window. - moveMouseTo(0, 150, function () { - const isOSXSnowLeopard = navigator.userAgent.indexOf("Mac OS X 10.6") != -1; - if (!isOSXSnowLeopard) { - ok(!gIFrame.matches(":hover"), "iframe shouldn't be hovered"); - ok(!box.matches(":hover"), "box shouldn't be hovered"); - } - finalize(); - }); - }, gLeftWindow, box); - }, gRightWindow, box); - }, gLeftWindow, box); - }); -} - -function finalize() { - gRightWindow.close(); - gLeftWindow.close(); - SimpleTest.finish(); -} - -SimpleTest.waitForExplicitFinish(); -SimpleTest.waitForFocus(openWindows); - -]]> -</script> - -</window> diff --git a/widget/tests/test_bug673301.xul b/widget/tests/test_bug673301.xul deleted file mode 100644 index a5736b86f..000000000 --- a/widget/tests/test_bug673301.xul +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> - -<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - -<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/> -<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"/> -</body> - -<script type="application/javascript"> -function getLoadContext() { - const Ci = Components.interfaces; - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); -} - -var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"] - .getService(Components.interfaces.nsIClipboard); - -var transferable = Components.classes['@mozilla.org/widget/transferable;1'] - .createInstance(Components.interfaces.nsITransferable); -transferable.init(getLoadContext()); - -transferable.addDataFlavor("text/unicode"); -transferable.setTransferData("text/unicode", document, 4); - -clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard); - -transferable.setTransferData("text/unicode", null, 0); - -SimpleTest.ok(true, "Didn't crash setting non-text data for text/unicode type"); -</script> -</window> diff --git a/widget/tests/test_bug760802.xul b/widget/tests/test_bug760802.xul deleted file mode 100644 index c79be785e..000000000 --- a/widget/tests/test_bug760802.xul +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=760802 ---> -<window title="Mozilla Bug 760802" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=760802" - target="_blank">Mozilla Bug 760802</a> - <p id="display"></p> - <div id="content" style="display: none"/> - <iframe id="iframe_not_editable" width="300" height="150" - src="data:text/html,<html><body></body></html>"/><br/> - </body> - - <!-- test code goes here --> - <script type="application/javascript"><![CDATA[ -SimpleTest.waitForExplicitFinish(); - -var Cc = Components.classes; -var Ci = Components.interfaces; - -function getBaseWindowInterface(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor) - .nsIBaseWindow; -} - -function getBaseWindowInterfaceFromDocShell(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIBaseWindow); -} - -function shouldThrowException(fun, exception) { - try { - fun.call(); - return false; - } catch (e) { - $("display").innerHTML += "<br/>OK thrown: "+e.message; - return (e instanceof Components.Exception && - e.result === exception) - } -} -function doesntThrowException(fun) { - return !shouldThrowException(fun); -} - -var baseWindow = getBaseWindowInterface(this); -var nativeHandle = baseWindow.nativeHandle; -$("display").innerHTML = "found nativeHandle for this window: "+nativeHandle; - -var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); -var win = wm.getMostRecentWindow("navigator:browser"); -var docShell = getBaseWindowInterfaceFromDocShell(win); - -ok( - shouldThrowException(function(){docShell.nativeHandle;}, - Components.results.NS_ERROR_NOT_IMPLEMENTED), - "nativeHandle should not be implemented for nsDocShell" -); - -ok(typeof(nativeHandle) === "string", "nativeHandle should be a string"); -ok(nativeHandle.match(/^0x[0-9a-f]+$/), "nativeHandle should have a memory address format"); - -var iWin = document.getElementById("iframe_not_editable").contentWindow; -is(getBaseWindowInterface(iWin).nativeHandle, nativeHandle, - "the nativeHandle of an iframe should be its parent's nativeHandle"); - -var dialog = win.openDialog("data:text/plain,this is an active window.", "_blank", - "chrome,dialog=yes,width=100,height=100"); - -isnot(getBaseWindowInterface(dialog).nativeHandle, "", - "the nativeHandle of a dialog should not be empty"); - -dialog.close(); - -todo(false, "the nativeHandle of a window without a mainWidget should be empty"); // how to build a window without a mainWidget ? - -SimpleTest.finish(); - ]]></script> -</window> diff --git a/widget/tests/test_chrome_context_menus_win.xul b/widget/tests/test_chrome_context_menus_win.xul deleted file mode 100644 index 575e7743d..000000000 --- a/widget/tests/test_chrome_context_menus_win.xul +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> -<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> -<script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> -<script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> -<script type="application/javascript" src="utils.js"></script> -<script> - setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); - SimpleTest.waitForExplicitFinish(); - - var w = window.open('chrome_context_menus_win.xul', '_blank', 'chrome,resizable=yes,width=600,height=600'); - - function done() - { - w.close(); - SimpleTest.finish(); - } -</script> -<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;" /> -</window> diff --git a/widget/tests/test_clipboard.xul b/widget/tests/test_clipboard.xul deleted file mode 100644 index 19a55714d..000000000 --- a/widget/tests/test_clipboard.xul +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=948065 ---> -<window title="Mozilla Bug 948065" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onload="initAndRunTests()"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - - <!-- test code goes here --> - <script class="testbody" type="application/javascript"> - <![CDATA[ - - /** Test for Bug 948065 **/ - - const Cc = Components.classes; - const Ci = Components.interfaces; - - const kIsMac = navigator.platform.indexOf("Mac") == 0; - - function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); - } - - // Get clipboard data to paste. - function paste(clipboard) { - let trans = Cc['@mozilla.org/widget/transferable;1'] - .createInstance(Ci.nsITransferable); - trans.init(getLoadContext()); - trans.addDataFlavor("text/unicode"); - clipboard.getData(trans, Ci.nsIClipboard.kGlobalClipboard); - let str = {}; - let length = {}; - try { - trans.getTransferData('text/unicode', str, length); - } catch (e) { - str = ''; - } - if (str) { - str = str.value.QueryInterface(Ci.nsISupportsString); - if (str) { - str = str.data.substring(0, length.value / 2); - } - } - return str; - } - - function initAndRunTests() { - let clipboard = Cc['@mozilla.org/widget/clipboard;1'] - .getService(Ci.nsIClipboard); - - // Test copy. - const data = "random number: " + Math.random(); - let helper = Cc['@mozilla.org/widget/clipboardhelper;1'] - .getService(Ci.nsIClipboardHelper); - helper.copyString(data); - is(paste(clipboard), data, 'Data was successfully copied.'); - - // Test emptyClipboard, disabled for OSX because bug 666254 - if (!kIsMac) { - clipboard.emptyClipboard(Ci.nsIClipboard.kGlobalClipboard); - is(paste(clipboard), '', 'Data was successfully cleared.'); - } - } - - ]]> - </script> -</window> diff --git a/widget/tests/test_composition_text_querycontent.xul b/widget/tests/test_composition_text_querycontent.xul deleted file mode 100644 index e48a1b14a..000000000 --- a/widget/tests/test_composition_text_querycontent.xul +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Testing composition, text and query content events" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -// If setting selection with eSetSelection event whose range is larger than -// the actual range, hits "Can only call this on frames that have been reflowed: -// '!(GetStateBits() & NS_FRAME_FIRST_REFLOW) || (GetParent()->GetStateBits() & -// NS_FRAME_TOO_DEEP_IN_FRAME_TREE)'" in nsTextFrame.cpp. -// Strangely, this doesn't occur with RDP on Windows. -SimpleTest.expectAssertions(0, 3); -SimpleTest.waitForExplicitFinish(); -window.open("window_composition_text_querycontent.xul", "_blank", - "chrome,width=600,height=600"); - -]]> -</script> -</window> diff --git a/widget/tests/test_imestate.html b/widget/tests/test_imestate.html deleted file mode 100644 index fe5a3cce2..000000000 --- a/widget/tests/test_imestate.html +++ /dev/null @@ -1,1529 +0,0 @@ -<html style="ime-mode: disabled;"> -<head> - <title>Test for IME state controling</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="utils.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body onload="setTimeout(runTests, 0);" style="ime-mode: disabled;"> -<script> -setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); -</script> -<div id="display" style="ime-mode: disabled;"> - <!-- input elements --> - <input type="text" id="text"/><br/> - <input type="text" id="text_readonly" readonly="readonly"/><br/> - <input type="password" id="password"/><br/> - <input type="password" id="password_readonly" readonly="readonly"/><br/> - <input type="checkbox" id="checkbox"/><br/> - <input type="radio" id="radio"/><br/> - <input type="submit" id="submit"/><br/> - <input type="reset" id="reset"/><br/> - <input type="file" id="file"/><br/> - <input type="button" id="ibutton"/><br/> - <input type="image" id="image" alt="image"/><br/> - - <!-- html5 input elements --> - <input type="url" id="url"/><br/> - <input type="email" id="email"/><br/> - <input type="search" id="search"/><br/> - <input type="tel" id="tel"/><br/> - <input type="number" id="number"/><br/> - - <!-- form controls --> - <button id="button">button</button><br/> - <textarea id="textarea">textarea</textarea><br/> - <textarea id="textarea_readonly" readonly="readonly">textarea[readonly]</textarea><br/> - <select id="select"> - <option value="option" selected="selected"/> - </select><br/> - <select id="select_multiple" multiple="multiple"> - <option value="option" selected="selected"/> - </select><br/> - <isindex id="isindex" prompt="isindex"/><br/> - - <!-- a element --> - <a id="a_href" href="about:blank">a[href]</a><br/> - - <!-- ime-mode test --> - <input type="text" id="ime_mode_auto" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled" style="ime-mode: disabled;"/><br/> - - <input type="text" id="ime_mode_auto_url" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal_url" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active_url" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive_url" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled_url" style="ime-mode: disabled;"/><br/> - - <input type="text" id="ime_mode_auto_email" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal_email" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active_email" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive_email" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled_email" style="ime-mode: disabled;"/><br/> - - <input type="text" id="ime_mode_auto_search" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal_search" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active_search" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive_search" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled_search" style="ime-mode: disabled;"/><br/> - - <input type="text" id="ime_mode_auto_tel" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal_tel" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active_tel" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive_tel" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled_tel" style="ime-mode: disabled;"/><br/> - - <input type="text" id="ime_mode_auto_number" style="ime-mode: auto;"/><br/> - <input type="text" id="ime_mode_normal_number" style="ime-mode: normal;"/><br/> - <input type="text" id="ime_mode_active_number" style="ime-mode: active;"/><br/> - <input type="text" id="ime_mode_inactive_number" style="ime-mode: inactive;"/><br/> - <input type="text" id="ime_mode_disabled_number" style="ime-mode: disabled;"/><br/> - - <input type="password" id="ime_mode_auto_p" style="ime-mode: auto;"/><br/> - <input type="password" id="ime_mode_normal_p" style="ime-mode: normal;"/><br/> - <input type="password" id="ime_mode_active_p" style="ime-mode: active;"/><br/> - <input type="password" id="ime_mode_inactive_p" style="ime-mode: inactive;"/><br/> - <input type="password" id="ime_mode_disabled_p" style="ime-mode: disabled;"/><br/> - <textarea id="ime_mode_auto_t" style="ime-mode: auto;">textarea</textarea><br/> - <textarea id="ime_mode_normal_t" style="ime-mode: normal;">textarea</textarea><br/> - <textarea id="ime_mode_active_t" style="ime-mode: active;">textarea</textarea><br/> - <textarea id="ime_mode_inactive_t" style="ime-mode: inactive;">textarea</textarea><br/> - <textarea id="ime_mode_disabled_t" style="ime-mode: disabled;">textarea</textarea><br/> - - <!-- plugin --> - <object type="application/x-test" id="plugin"></object><br/> - - <!-- contenteditable editor --> - <div id="contenteditableEditor" contenteditable="true"></div> - - <!-- designMode editor --> - <iframe id="designModeEditor" - onload="document.getElementById('designModeEditor').contentDocument.designMode = 'on';" - src="data:text/html,<html><body></body></html>"></iframe><br/> -</div> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> - -<script class="testbody" type="application/javascript"> - -SimpleTest.waitForExplicitFinish(); - -function hitEventLoop(aFunc, aTimes) -{ - if (--aTimes) { - setTimeout(hitEventLoop, 0, aFunc, aTimes); - } else { - setTimeout(aFunc, 20); - } -} - -var gUtils = window. - QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); -var gFM = Components.classes["@mozilla.org/focus-manager;1"]. - getService(Components.interfaces.nsIFocusManager); -const kIMEEnabledSupported = navigator.platform.indexOf("Mac") == 0 || - navigator.platform.indexOf("Win") == 0 || - navigator.platform.indexOf("Linux") == 0; - -// We support to control IME open state on Windows and Mac actually. However, -// we cannot test it on Mac if the current keyboard layout is not CJK. And also -// we cannot test it on Win32 if the system didn't be installed IME. So, -// currently we should not run the open state testing. -const kIMEOpenSupported = false; - -function runBasicTest(aIsEditable, aInDesignMode, aDescription) -{ - var onIMEFocusBlurHandler = null; - var TIPCallback = function(aTIP, aNotification) { - switch (aNotification.type) { - case "request-to-commit": - aTIP.commitComposition(); - break; - case "request-to-cancel": - aTIP.cancelComposition(); - break; - case "notify-focus": - case "notify-blur": - if (onIMEFocusBlurHandler) { - onIMEFocusBlurHandler(aNotification); - } - break; - } - return true; - }; - - var TIP = Components.classes["@mozilla.org/text-input-processor;1"] - .createInstance(Components.interfaces.nsITextInputProcessor); - if (!TIP.beginInputTransactionForTests(window, TIPCallback)) { - ok(false, "runBasicTest(): failed to begin input transaction"); - return; - } - - function test(aTest) - { - function moveFocus(aTest, aFocusEventHandler) - { - if (aInDesignMode) { - if (document.activeElement) { - document.activeElement.blur(); - } - } else if (aIsEditable) { - document.getElementById("display").focus(); - } else if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED) { - document.getElementById("password").focus(); - } else { - document.getElementById("text").focus(); - } - var previousFocusedElement = gFM.focusedElement; - var element = document.getElementById(aTest.id); - var focusEventTarget = element; - var subDocument = null; - if (element.contentDocument) { - focusEventTarget = element.contentDocument; - subDocument = element.contentDocument; - element = element.contentDocument.documentElement; - } - - focusEventTarget.addEventListener("focus", aFocusEventHandler, true); - onIMEFocusBlurHandler = aFocusEventHandler; - - element.focus(); - - focusEventTarget.removeEventListener("focus", aFocusEventHandler, true); - onIMEFocusBlurHandler = null; - - var focusedElement = gFM.focusedElement; - if (focusedElement) { - var bindingParent = document.getBindingParent(focusedElement); - if (bindingParent) { - focusedElement = bindingParent; - } - } - if (aTest.focusable) { - is(focusedElement, element, - aDescription + ": " + aTest.description + ", focus didn't move"); - return (element == focusedElement); - } - is(focusedElement, previousFocusedElement, - aDescription + ": " + aTest.description + ", focus moved as unexpected"); - return (previousFocusedElement == focusedElement); - } - - function testOpened(aTest, aOpened) - { - document.getElementById("text").focus(); - gUtils.IMEIsOpen = aOpened; - if (!moveFocus(aTest)) { - return; - } - var message = aDescription + ": " + aTest.description + - ", wrong opened state"; - is(gUtils.IMEIsOpen, - aTest.changeOpened ? aTest.expectedOpened : aOpened, message); - } - - // IME Enabled state testing - var enabled = gUtils.IME_STATUS_ENABLED; - if (kIMEEnabledSupported) { - var focusEventCount = 0; - var IMEReceivesFocus = 0; - var IMEReceivesBlur = 0; - var IMEHasFocus = false; - - function onFocus(aEvent) - { - switch (aEvent.type) { - case "focus": - focusEventCount++; - is(gUtils.IMEStatus, aTest.expectedEnabled, - aDescription + ": " + aTest.description + ", wrong enabled state at focus event"); - break; - case "notify-focus": - IMEReceivesFocus++; - IMEHasFocus = true; - is(gUtils.IMEStatus, aTest.expectedEnabled, - aDescription + ": " + aTest.description + - ", IME should receive a focus notification after IME state is updated"); - break; - case "notify-blur": - IMEReceivesBlur++; - IMEHasFocus = false; - var changingStatus = !(aIsEditable && aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED); - if (aTest.toDesignModeEditor) { - is(gUtils.IME_STATUS_ENABLED, aTest.expectedEnabled, - aDescription + ": " + aTest.description + - ", IME should receive a blur notification after IME state is updated"); - } else if (changingStatus) { - isnot(gUtils.IMEStatus, aTest.expectedEnabled, - aDescription + ": " + aTest.description + - ", IME should receive a blur notification before IME state is updated"); - } else { - is(gUtils.IMEStatus, aTest.expectedEnabled, - aDescription + ": " + aTest.description + - ", IME should receive a blur notification and its context has expected IME state if the state isn't being changed"); - } - break; - } - } - - if (!moveFocus(aTest, onFocus)) { - return; - } - - if (aTest.focusable) { - if (!aTest.focusEventNotFired) { - ok(focusEventCount > 0, - aDescription + ": " + aTest.description + ", focus event is never fired"); - if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED || aTest.expectedEnabled == gUtils.IME_STATUS_PASSWORD) { - ok(IMEReceivesFocus > 0, - aDescription + ": " + aTest.description + ", IME should receive a focus notification"); - if (aInDesignMode && !aTest.toDesignModeEditor) { - is(IMEReceivesBlur, 0, - aDescription + ": " + aTest.description + - ", IME shouldn't receive a blur notification in designMode since focus isn't moved from another editor"); - } else { - ok(IMEReceivesBlur > 0, - aDescription + ": " + aTest.description + - ", IME should receive a blur notification for the previous focused editor"); - } - ok(IMEHasFocus, - aDescription + ": " + aTest.description + - ", IME should have focus right now"); - } else { - is(IMEReceivesFocus, 0, - aDescription + ": " + aTest.description + - ", IME shouldn't receive a focus notification"); - ok(IMEReceivesBlur > 0, - aDescription + ": " + aTest.description + - ", IME should receive a blur notification"); - ok(!IMEHasFocus, - aDescription + ": " + aTest.description + - ", IME shouldn't have focus right now"); - } - } else { - todo(focusEventCount > 0, - aDescription + ": " + aTest.description + ", focus event should be fired"); - } - } else { - is(IMEReceivesFocus, 0, - aDescription + ": " + aTest.description + - ", IME shouldn't receive a focus notification at testing non-focusable element"); - is(IMEReceivesBlur, 0, - aDescription + ": " + aTest.description + - ", IME shouldn't receive a blur notification at testing non-focusable element"); - } - - enabled = gUtils.IMEStatus; - inputtype = gUtils.focusedInputType; - is(enabled, aTest.expectedEnabled, - aDescription + ": " + aTest.description + ", wrong enabled state"); - if (aTest.expectedType && !aInDesignMode) { - is(inputtype, aTest.expectedType, - aDescription + ": " + aTest.description + ", wrong input type"); - } else if (aInDesignMode) { - is(inputtype, "", - aDescription + ": " + aTest.description + ", wrong input type") - } - } - - if (!kIMEOpenSupported || enabled != gUtils.IME_STATUS_ENABLED || - aTest.expectedEnabled != gUtils.IME_STATUS_ENABLED) { - return; - } - - // IME Open state testing - testOpened(aTest, false); - testOpened(aTest, true); - } - - if (kIMEEnabledSupported) { - // make sure there is an active element - document.getElementById("text").focus(); - document.activeElement.blur(); - is(gUtils.IMEStatus, - aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_DISABLED, - aDescription + ": unexpected enabled state when no element has focus"); - } - - // Form controls except text editable elements are "disable" in normal - // condition, however, if they are editable, they are "enabled". - // XXX Probably there are some bugs: If the form controls editable, they - // shouldn't be focusable. - const kEnabledStateOnNonEditableElement = - (aInDesignMode || aIsEditable) ? gUtils.IME_STATUS_ENABLED : - gUtils.IME_STATUS_DISABLED; - const kEnabledStateOnPasswordField = - aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_PASSWORD; - const kEnabledStateOnReadonlyField = - aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_DISABLED; - const kTests = [ - { id: "text", - description: "input[type=text]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "text" }, - { id: "text_readonly", - description: "input[type=text][readonly]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnReadonlyField }, - { id: "password", - description: "input[type=password]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField, - expectedType: "password" }, - { id: "password_readonly", - description: "input[type=password][readonly]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnReadonlyField }, - { id: "checkbox", - description: "input[type=checkbox]", - focusable: !aInDesignMode, - focusEventNotFired: aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "radio", - description: "input[type=radio]", - focusable: !aInDesignMode, - focusEventNotFired: aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "submit", - description: "input[type=submit]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "reset", - description: "input[type=reset]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "file", - description: "input[type=file]", - focusable: !aInDesignMode, - focusEventNotFired: aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "button", - description: "input[type=button]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "image", - description: "input[type=image]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "url", - description: "input[type=url]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "url" }, - { id: "email", - description: "input[type=email]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "email" }, - { id: "search", - description: "input[type=search]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "search" }, - { id: "tel", - description: "input[type=tel]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "tel" }, - { id: "number", - description: "input[type=number]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - expectedType: "number" }, - - // form controls - { id: "button", - description: "button", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "textarea", - description: "textarea", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "textarea_readonly", - description: "textarea[readonly]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnReadonlyField }, - { id: "select", - description: "select (dropdown list)", - focusable: !aInDesignMode, - focusEventNotFired: aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - { id: "select_multiple", - description: "select (list box)", - focusable: !aInDesignMode, - focusEventNotFired: aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - - // a element - { id: "a_href", - description: "a[href]", - focusable: !aIsEditable && !aInDesignMode, - expectedEnabled: kEnabledStateOnNonEditableElement }, - - // ime-mode - { id: "ime_mode_auto", - description: "input[type=text][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal", - description: "input[type=text][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active", - description: "input[type=text][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive", - description: "input[type=text][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled", - description: "input[type=text][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_url", - description: "input[type=url][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal_url", - description: "input[type=url][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_url", - description: "input[type=url][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_url", - description: "input[type=url][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_url", - description: "input[type=url][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_email", - description: "input[type=email][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal_email", - description: "input[type=email][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_email", - description: "input[type=email][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_email", - description: "input[type=email][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_email", - description: "input[type=email][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_search", - description: "input[type=search][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal_search", - description: "input[type=search][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_search", - description: "input[type=search][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_search", - description: "input[type=search][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_search", - description: "input[type=search][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_tel", - description: "input[type=tel][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal_tel", - description: "input[type=tel][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_tel", - description: "input[type=tel][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_tel", - description: "input[type=tel][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_tel", - description: "input[type=tel][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_number", - description: "input[type=number][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal_number", - description: "input[type=number][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_number", - description: "input[type=number][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_number", - description: "input[type=number][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_number", - description: "input[type=number][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - { id: "ime_mode_auto_p", - description: "input[type=password][style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - { id: "ime_mode_normal_p", - description: "input[type=password][style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active_p", - description: "input[type=password][style=\"ime-mode: active;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive_p", - description: "input[type=password][style=\"ime-mode: inactive;\"]", - expectedEnabled: gUtils.IME_STATUS_ENABLED, - focusable: !aInDesignMode, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled_p", - description: "input[type=password][style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - { id: "ime_mode_auto", - description: "textarea[style=\"ime-mode: auto;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_normal", - description: "textarea[style=\"ime-mode: normal;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "ime_mode_active", - description: "textarea[style=\"ime-mode: active;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - changeOpened: true, expectedOpened: true }, - { id: "ime_mode_inactive", - description: "textarea[style=\"ime-mode: inactive;\"]", - focusable: !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED, - changeOpened: true, expectedOpened: false }, - { id: "ime_mode_disabled", - description: "textarea[style=\"ime-mode: disabled;\"]", - focusable: !aInDesignMode, - expectedEnabled: kEnabledStateOnPasswordField }, - - // HTML editors - { id: "contenteditableEditor", - description: "div[contenteditable=\"true\"]", - focusable: !aIsEditable && !aInDesignMode, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - { id: "designModeEditor", - description: "designMode editor", - focusable: true, - toDesignModeEditor: true, - expectedEnabled: gUtils.IME_STATUS_ENABLED }, - ]; - - for (var i = 0; i < kTests.length; i++) { - test(kTests[i]); - } -} - -function runPluginTest() -{ - if (!kIMEEnabledSupported) { - return; - } - - if (navigator.platform.indexOf("Mac") == 0) { - // XXX on mac, currently, this test isn't passed because it doesn't return - // IME_STATUS_PLUGIN by its bug. - return; - } - - var plugin = document.getElementById("plugin"); - - document.activeElement.blur(); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - "runPluginTest: unexpected enabled state when no element has focus"); - - plugin.focus(); - is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN, - "runPluginTest: unexpected enabled state when plugin has focus"); - - plugin.blur(); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - "runPluginTest: unexpected enabled state when plugin has focus"); - - plugin.focus(); - is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN, - "runPluginTest: unexpected enabled state when plugin has focus #2"); - - var parent = plugin.parentNode; - parent.removeChild(plugin); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - "runPluginTest: unexpected enabled state when plugin is removed from tree"); - - document.getElementById("text").focus(); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - "runPluginTest: unexpected enabled state when input[type=text] has focus"); -} - -function runTypeChangingTest() -{ - if (!kIMEEnabledSupported) - return; - - const kInputControls = [ - { id: "text", - type: "text", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"text\"]" }, - { id: "text_readonly", - type: "text", expected: gUtils.IME_STATUS_DISABLED, isReadonly: true, - description: "[type=\"text\"][readonly]" }, - { id: "password", - type: "password", expected: gUtils.IME_STATUS_PASSWORD, - description: "[type=\"password\"]" }, - { id: "password_readonly", - type: "password", expected: gUtils.IME_STATUS_DISABLED, isReadonly: true, - description: "[type=\"password\"][readonly]" }, - { id: "checkbox", - type: "checkbox", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"checkbox\"]" }, - { id: "radio", - type: "radio", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"radio\"]" }, - { id: "submit", - type: "submit", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"submit\"]" }, - { id: "reset", - type: "reset", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"reset\"]" }, - { id: "file", - type: "file", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"file\"]" }, - { id: "ibutton", - type: "button", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"button\"]" }, - { id: "image", - type: "image", expected: gUtils.IME_STATUS_DISABLED, - description: "[type=\"image\"]" }, - { id: "url", - type: "url", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"url\"]" }, - { id: "email", - type: "email", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"email\"]" }, - { id: "search", - type: "search", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"search\"]" }, - { id: "tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"tel\"]" }, - { id: "number", - type: "number", expected: gUtils.IME_STATUS_ENABLED, - description: "[type=\"number\"]" }, - { id: "ime_mode_auto", - type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"text\"][ime-mode: auto;]" }, - { id: "ime_mode_normal", - type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"text\"][ime-mode: normal;]" }, - { id: "ime_mode_active", - type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"text\"][ime-mode: active;]" }, - { id: "ime_mode_inactive", - type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"text\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled", - type: "text", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"text\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_url", - type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"url\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_url", - type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"url\"][ime-mode: normal;]" }, - { id: "ime_mode_active_url", - type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"url\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_url", - type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"url\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_url", - type: "url", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"url\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_email", - type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"email\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_email", - type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"email\"][ime-mode: normal;]" }, - { id: "ime_mode_active_email", - type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"email\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_email", - type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"email\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_email", - type: "email", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"email\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_search", - type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"search\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_search", - type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"search\"][ime-mode: normal;]" }, - { id: "ime_mode_active_search", - type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"search\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_search", - type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"search\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_search", - type: "search", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"search\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"tel\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"tel\"][ime-mode: normal;]" }, - { id: "ime_mode_active_tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"tel\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"tel\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_tel", - type: "tel", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"tel\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_number", - type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"number\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_number", - type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"number\"][ime-mode: normal;]" }, - { id: "ime_mode_active_number", - type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"number\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_number", - type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"number\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_number", - type: "number", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"number\"][ime-mode: disabled;]" }, - - { id: "ime_mode_auto_p", - type: "password", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"password\"][ime-mode: auto;]" }, - { id: "ime_mode_normal_p", - type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"password\"][ime-mode: normal;]" }, - { id: "ime_mode_active_p", - type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"password\"][ime-mode: active;]" }, - { id: "ime_mode_inactive_p", - type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true, - description: "[type=\"password\"][ime-mode: inactive;]" }, - { id: "ime_mode_disabled_p", - type: "password", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true, - description: "[type=\"password\"][ime-mode: disabled;]" } - ]; - - const kInputTypes = [ - { type: "", expected: gUtils.IME_STATUS_ENABLED }, - { type: "text", expected: gUtils.IME_STATUS_ENABLED }, - { type: "password", expected: gUtils.IME_STATUS_PASSWORD }, - { type: "checkbox", expected: gUtils.IME_STATUS_DISABLED }, - { type: "radio", expected: gUtils.IME_STATUS_DISABLED }, - { type: "submit", expected: gUtils.IME_STATUS_DISABLED }, - { type: "reset", expected: gUtils.IME_STATUS_DISABLED }, - { type: "file", expected: gUtils.IME_STATUS_DISABLED }, - { type: "button", expected: gUtils.IME_STATUS_DISABLED }, - { type: "image", expected: gUtils.IME_STATUS_DISABLED }, - { type: "url", expected: gUtils.IME_STATUS_ENABLED }, - { type: "email", expected: gUtils.IME_STATUS_ENABLED }, - { type: "search", expected: gUtils.IME_STATUS_ENABLED }, - { type: "tel", expected: gUtils.IME_STATUS_ENABLED }, - { type: "number", expected: gUtils.IME_STATUS_ENABLED } - ]; - - function getExpectedIMEEnabled(aNewType, aInputControl) - { - if (aNewType.expected == gUtils.IME_STATUS_DISABLED || - aInputControl.isReadonly) - return gUtils.IME_STATUS_DISABLED; - return aInputControl.imeMode ? aInputControl.expected : aNewType.expected; - } - - const kOpenedState = [ true, false ]; - - for (var i = 0; i < kOpenedState.length; i++) { - const kOpened = kOpenedState[i]; - for (var j = 0; j < kInputControls.length; j++) { - const kInput = kInputControls[j]; - var e = document.getElementById(kInput.id); - e.focus(); - for (var k = 0; k < kInputTypes.length; k++) { - const kType = kInputTypes[k]; - var typeChangingDescription = - "\"" + e.getAttribute("type") + "\" to \"" + kInput.type + "\""; - e.setAttribute("type", kInput.type); - is(gUtils.IMEStatus, kInput.expected, - "type attr changing test (IMEStatus): " + typeChangingDescription + - " (" + kInput.description + ")"); - is(gUtils.focusedInputType, kInput.type, - "type attr changing test (type): " + typeChangingDescription + - " (" + kInput.description + ")"); - - const kTestOpenState = kIMEOpenSupported && - gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED && - getExpectedIMEEnabled(kType, kInput) == gUtils.IME_STATUS_ENABLED; - if (kTestOpenState) { - gUtils.IMEIsOpen = kOpened; - } - - typeChangingDescription = - "\"" + e.getAttribute("type") + "\" to \"" + kType.type + "\""; - if (kType.type != "") - e.setAttribute("type", kType.type); - else - e.removeAttribute("type"); - - is(gUtils.IMEStatus, getExpectedIMEEnabled(kType, kInput), - "type attr changing test (IMEStatus): " + typeChangingDescription + - " (" + kInput.description + ")"); - is(gUtils.focusedInputType, kType.type, - "type attr changing test (type): " + typeChangingDescription + - " (" + kInput.description + ")"); - if (kTestOpenState && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) { - is(gUtils.IMEIsOpen, kOpened, - "type attr changing test (open state is changed): " + - typeChangingDescription + " (" + kInput.description + ")"); - } - } - // reset the type to default - e.setAttribute("type", kInput.type); - } - if (!kIMEOpenSupported) - break; - } -} - -function runReadonlyChangingTest() -{ - if (!kIMEEnabledSupported) - return; - - const kInputControls = [ - { id: "text", - type: "text", expected: gUtils.IME_STATUS_ENABLED }, - { id: "password", - type: "password", expected: gUtils.IME_STATUS_PASSWORD }, - { id: "url", - type: "url", expected: gUtils.IME_STATUS_ENABLED }, - { id: "email", - type: "email", expected: gUtils.IME_STATUS_ENABLED }, - { id: "search", - type: "search", expected: gUtils.IME_STATUS_ENABLED }, - { id: "tel", - type: "tel", expected: gUtils.IME_STATUS_ENABLED }, - { id: "number", - type: "number", expected: gUtils.IME_STATUS_ENABLED }, - { id: "textarea", - type: "textarea", expected: gUtils.IME_STATUS_ENABLED } - ]; - const kOpenedState = [ true, false ]; - - for (var i = 0; i < kOpenedState.length; i++) { - const kOpened = kOpenedState[i]; - for (var j = 0; j < kInputControls.length; j++) { - const kInput = kInputControls[j]; - var e = document.getElementById(kInput.id); - e.focus(); - if (kIMEOpenSupported && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) { - gUtils.IMEIsOpen = kOpened; - } - e.setAttribute("readonly", "readonly"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - "readonly attr setting test: type=" + kInput.type); - e.removeAttribute("readonly"); - is(gUtils.IMEStatus, kInput.expected, - "readonly attr removing test: type=" + kInput.type); - if (kIMEOpenSupported && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) { - is(gUtils.IMEIsOpen, kOpened, - "readonly attr removing test (open state is changed): type=" + - kInput.type); - } - } - if (!kIMEOpenSupported) - break; - } -} - -function runComplexContenteditableTests() -{ - if (!kIMEEnabledSupported) { - return; - } - - var description = "runReadonlyChangingOnContenteditable: "; - - var container = document.getElementById("display"); - var button = document.getElementById("button"); - - // the editor has focus directly. - container.setAttribute("contenteditable", "true"); - container.focus(); - - is(gFM.focusedElement, container, - description + "The editor doesn't get focus"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "IME isn't enabled on HTML editor"); - const kReadonly = - Components.interfaces.nsIPlaintextEditor.eEditorReadonlyMask; - var editor = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - var flags = editor.flags; - editor.flags = flags | kReadonly; - is(gFM.focusedElement, container, - description + "The editor loses focus by flag change"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - description + "IME is still enabled on readonly HTML editor"); - editor.flags = flags; - is(gFM.focusedElement, container, - description + "The editor loses focus by flag change #2"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "IME is still disabled, the editor isn't readonly now"); - container.removeAttribute("contenteditable"); - todo_is(gFM.focusedElement, null, - description + "The container still has focus, the editor has been no editable"); - todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - description + "IME is still enabled on the editor, the editor has been no editable"); - - // a button which is in the editor has focus - button.focus(); - is(gFM.focusedElement, button, - description + "The button doesn't get focus"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - description + "IME is enabled on the button"); - container.setAttribute("contenteditable", "true"); - is(gFM.focusedElement, button, - description + "The button loses focus, the container is editable now"); - todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "IME is still disabled on the button, the container is editable now"); - editor = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - flags = editor.flags; - editor.flags = flags | kReadonly; - is(gFM.focusedElement, button, - description + "The button loses focus by changing editor flags"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - description + "IME is still enabled on the button, the container is readonly now"); - editor.flags = flags; - is(gFM.focusedElement, button, - description + "The button loses focus by changing editor flags #2"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "IME is still disabled on the button, the container isn't readonly now"); - container.removeAttribute("contenteditable"); - is(gFM.focusedElement, button, - description + "The button loses focus, the container has been no editable"); - todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED, - description + "IME is still enabled on the button, the container has been no editable"); - - description = "testOnIndependentEditor: "; - function testOnIndependentEditor(aEditor, aEditorDescription) - { - var isReadonly = aEditor.readOnly; - var expectedState = - aEditor.readOnly ? gUtils.IME_STATUS_DISABLED : gUtils.IME_STATUS_ENABLED; - var unexpectedStateDescription = - expectedState != gUtils.IME_STATUS_ENABLED ? "enabled" : "disabled"; - aEditor.focus(); - is(gFM.focusedElement, aEditor, - description + "The " + aEditorDescription + " doesn't get focus"); - is(gUtils.IMEStatus, expectedState, - description + "IME is " + unexpectedStateDescription + - " on the " + aEditorDescription); - container.setAttribute("contenteditable", "true"); - is(gFM.focusedElement, aEditor, - description + "The " + aEditorDescription + - " loses focus, the container is editable now"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + - " on the " + aEditorDescription + ", the container is editable now"); - editor = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - flags = editor.flags; - editor.flags = flags | kReadonly; - is(gFM.focusedElement, aEditor, - description + "The " + aEditorDescription + - " loses focus by changing editor flags"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on the " + - aEditorDescription + ", the container is readonly now"); - editor.flags = flags; - is(gFM.focusedElement, aEditor, - description + "The " + aEditorDescription + - " loses focus by changing editor flags #2"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on the " + - aEditorDescription + ", the container isn't readonly now"); - container.removeAttribute("contenteditable"); - is(gFM.focusedElement, aEditor, - description + "The " + aEditorDescription + - " loses focus, the container has been no editable"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on the " + - aEditorDescription + ", the container has been no editable"); - } - - // a textarea which is in the editor has focus - testOnIndependentEditor(document.getElementById("textarea"), - "textarea"); - // a readonly textarea which is in the editor has focus - testOnIndependentEditor(document.getElementById("textarea_readonly"), - "textarea[readonly]"); - // an input field which is in the editor has focus - testOnIndependentEditor(document.getElementById("text"), - "input[type=\"text\"]"); - // a readonly input field which is in the editor has focus - testOnIndependentEditor(document.getElementById("text_readonly"), - "input[type=\"text\"][readonly]"); - - description = "testOnOutsideOfEditor: "; - function testOnOutsideOfEditor(aFocusNode, aFocusNodeDescription, aEditor) - { - if (aFocusNode) { - aFocusNode.focus(); - is(gFM.focusedElement, aFocusNode, - description + "The " + aFocusNodeDescription + " doesn't get focus"); - } else { - if (document.activeElement) { - document.activeElement.blur(); - } - is(gFM.focusedElement, null, - description + "Unexpected element has focus"); - } - var expectedState = - aFocusNode ? gUtils.IMEStatus : gUtils.IME_STATUS_DISABLED; - var unexpectedStateDescription = - expectedState != gUtils.IME_STATUS_ENABLED ? "enabled" : "disabled"; - - aEditor.setAttribute("contenteditable", "true"); - is(gFM.focusedElement, aFocusNode, - description + "The " + aFocusNodeDescription + - " loses focus, a HTML editor is editable now"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + - " on the " + aFocusNodeDescription + - ", the HTML editor is editable now"); - editor = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - flags = editor.flags; - editor.flags = flags | kReadonly; - is(gFM.focusedElement, aFocusNode, - description + aFocusNodeDescription + - " loses focus by changing HTML editor flags"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on " + - aFocusNodeDescription + ", the HTML editor is readonly now"); - editor.flags = flags; - is(gFM.focusedElement, aFocusNode, - description + aFocusNodeDescription + - " loses focus by changing HTML editor flags #2"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on " + - aFocusNodeDescription + ", the HTML editor isn't readonly now"); - container.removeAttribute("contenteditable"); - is(gFM.focusedElement, aFocusNode, - description + aFocusNodeDescription + - " loses focus, the HTML editor has been no editable"); - is(gUtils.IMEStatus, expectedState, - description + "IME becomes " + unexpectedStateDescription + " on " + - aFocusNodeDescription + ", the HTML editor has been no editable"); - } - - var div = document.getElementById("contenteditableEditor"); - // a textarea which is outside of the editor has focus - testOnOutsideOfEditor(document.getElementById("textarea"), "textarea", div); - // a readonly textarea which is outside of the editor has focus - testOnOutsideOfEditor(document.getElementById("textarea_readonly"), - "textarea[readonly]", div); - // an input field which is outside of the editor has focus - testOnOutsideOfEditor(document.getElementById("text"), - "input[type=\"text\"]", div); - // a readonly input field which outside of the editor has focus - testOnOutsideOfEditor(document.getElementById("text_readonly"), - "input[type=\"text\"][readonly]", div); - // a readonly input field which outside of the editor has focus - testOnOutsideOfEditor(document.getElementById("button"), "button", div); - // nobody has focus. - testOnOutsideOfEditor(null, "nobody", div); -} - -function runEditorFlagChangeTests() -{ - if (!kIMEEnabledSupported) { - return; - } - - var description = "runEditorFlagChangeTests: "; - - var container = document.getElementById("display"); - - // Reset selection from previous tests. - window.getSelection().collapse(container, 0); - - // the editor has focus directly. - container.setAttribute("contenteditable", "true"); - container.focus(); - - is(gFM.focusedElement, container, - description + "The editor doesn't get focus"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "IME isn't enabled on HTML editor"); - const kIMEStateChangeFlags = - Components.interfaces.nsIPlaintextEditor.eEditorPasswordMask | - Components.interfaces.nsIPlaintextEditor.eEditorReadonlyMask | - Components.interfaces.nsIPlaintextEditor.eEditorDisabledMask; - var editor = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - var editorIMESupport = - editor.QueryInterface(Components.interfaces.nsIEditorIMESupport); - var flags = editor.flags; - - // input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3078\u3093\u3057\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - editor.flags &= ~kIMEStateChangeFlags; - ok(editorIMESupport.composing, - description + "#1 IME composition was committed unexpectedly"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "#1 IME isn't enabled on HTML editor"); - - editor.flags |= ~kIMEStateChangeFlags; - ok(editorIMESupport.composing, - description + "#2 IME composition was committed unexpectedly"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "#2 IME isn't enabled on HTML editor"); - - editor.flags = flags; - ok(editorIMESupport.composing, - description + "#3 IME composition was committed unexpectedly"); - is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED, - description + "#3 IME isn't enabled on HTML editor"); - - // cancel the composition - synthesizeComposition({ type: "compositioncommit", data: "" }); - - container.removeAttribute("contenteditable"); -} - -function runEditableSubframeTests() -{ - window.open("window_imestate_iframes.html", "_blank", - "width=600,height=600"); -} - -function runTestPasswordFieldOnDialog() -{ - if (!kIMEEnabledSupported) { - return; - } - - if (document.activeElement) { - document.activeElement.blur(); - } - - var dialog; - - function WindowObserver() - { - Components.classes["@mozilla.org/observer-service;1"]. - getService(Components.interfaces.nsIObserverService). - addObserver(this, "domwindowopened", false); - } - - WindowObserver.prototype = { - QueryInterface: function (iid) - { - if (iid.equals(Components.interfaces.nsIObserver) || - iid.equals(Components.interfaces.nsISupports)) { - return this; - } - }, - - observe: function (subject, topic, data) - { - if (topic === "domwindowopened") { - ok(true, "dialog window is created"); - dialog = subject.QueryInterface(Components.interfaces.nsIDOMWindow); - dialog.addEventListener("load", onPasswordDialogLoad, false); - } - } - }; - - var observer = new WindowObserver(); - var arg1 = new Object(), arg2 = new Object(); - Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. - getService(Components.interfaces.nsIPromptService). - promptPassword(window, "title", "text", arg1, "msg", arg2); - - ok(true, "password dialog was closed"); - - Components.classes["@mozilla.org/observer-service;1"]. - getService(Components.interfaces.nsIObserverService). - removeObserver(observer, "domwindowopened"); - - var passwordField; - - function onPasswordDialogLoad() - { - ok(true, "onPasswordDialogLoad is called"); - dialog.removeEventListener("load", onPasswordDialogLoad, false); - passwordField = dialog.document.getElementById("password1Textbox"); - passwordField.addEventListener("focus", onPasswordFieldFocus, false); - } - - function onPasswordFieldFocus() - { - ok(true, "onPasswordFieldFocus is called"); - passwordField.removeEventListener("focus", onPasswordFieldFocus, false); - var utils = dialog. - QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - is(utils.IMEStatus, utils.IME_STATUS_PASSWORD, - "IME isn't disabled on a password field of password dialog"); - synthesizeKey("VK_ESCAPE", { }, dialog); - } -} - -// Bug 580388 and bug 808287 -function runEditorReframeTests(aCallback) -{ - if (document.activeElement) { - document.activeElement.blur(); - } - - var IMEFocus = 0; - var IMEBlur = 0; - var IMEHasFocus = false; - var TIPCallback = function(aTIP, aNotification) { - switch (aNotification.type) { - case "request-to-commit": - aTIP.commitComposition(); - break; - case "request-to-cancel": - aTIP.cancelComposition(); - break; - case "notify-focus": - IMEFocus++; - IMEHasFocus = true; - break; - case "notify-blur": - IMEBlur++; - IMEHasFocus = false; - break; - } - return true; - }; - - var TIP = Components.classes["@mozilla.org/text-input-processor;1"] - .createInstance(Components.interfaces.nsITextInputProcessor); - if (!TIP.beginInputTransactionForTests(window, TIPCallback)) { - ok(false, "runEditorReframeTests(): failed to begin input transaction"); - return; - } - - var input = document.getElementById("text"); - input.focus(); - - is(IMEFocus, 1, "runEditorReframeTests(): IME should receive a focus notification by a call of <input>.focus()"); - is(IMEBlur, 0, "runEditorReframeTests(): IME shouldn't receive a blur notification by a call of <input>.focus()"); - ok(IMEHasFocus, "runEditorReframeTests(): IME should have focus because <input>.focus() is called"); - - IMEFocus = IMEBlur = 0; - - input.style.overflow = "visible"; - - var onInput = function (aEvent) { - aEvent.target.style.overflow = "hidden"; - } - input.addEventListener("input", onInput, true); - - var AKey = new KeyboardEvent("", { key: "a", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }); - TIP.keydown(AKey); - TIP.keyup(AKey); - - hitEventLoop(function () { - is(IMEFocus, 0, "runEditorReframeTests(): IME shouldn't receive a focus notification during reframing"); - is(IMEBlur, 0, "runEditorReframeTests(): IME shouldn't receive a blur notification during reframing"); - ok(IMEHasFocus, "runEditorReframeTests(): IME must have focus even after reframing"); - - var onFocus = function(aEvent) { - // Perform a style change and query during focus to trigger reframing - input.style.overflow = "visible"; - synthesizeQuerySelectedText(); - }; - input.addEventListener("focus", onFocus); - IMEFocus = IMEBlur = 0; - - input.blur(); - input.focus(); - TIP.keydown(AKey); - TIP.keyup(AKey); - - hitEventLoop(function() { - is(IMEFocus, 1, "runEditorReframeTests(): IME should receive a focus notification at focus but shouldn't receive it during reframing"); - is(IMEBlur, 1, "runEditorReframeTests(): IME should receive a blur notification at blur but shouldn't receive it during reframing"); - ok(IMEHasFocus, "runEditorReframeTests(): IME sould have focus after reframing during focus"); - - input.removeEventListener("input", onInput, true); - input.removeEventListener("focus", onFocus); - - input.style.overflow = "visible"; - input.value = ""; - - TIP = null; - - hitEventLoop(aCallback, 20); - }, 20); - }, 20); -} - -function runTests() -{ - if (!kIMEEnabledSupported && !kIMEOpenSupported) - return; - - // test for normal contents. - runBasicTest(false, false, "Testing of normal contents"); - - // test for plugin contents - runPluginTest(); - - var container = document.getElementById("display"); - // test for contentEditable="true" - container.setAttribute("contenteditable", "true"); - runBasicTest(true, false, "Testing [contentEditable=\"true\"]"); - - // test for contentEditable="false" - container.setAttribute("contenteditable", "false"); - runBasicTest(false, false, "Testing [contentEditable=\"false\"]"); - - // test for removing contentEditable - container.setAttribute("contenteditable", "true"); - container.removeAttribute("contenteditable"); - runBasicTest(false, false, "Testing after contentEditable to be removed"); - - // test designMode - document.designMode = "on"; - runBasicTest(true, true, "Testing designMode=\"on\""); - document.designMode = "off"; - document.getElementById("text").focus(); - runBasicTest(false, false, "Testing designMode=\"off\""); - - // changing input[type] values - // XXX currently, type attribute changing doesn't work fine. bug 559728. - // runTypeChangingTest(); - - // changing readonly attribute - runReadonlyChangingTest(); - - // complex contenteditable editor's tests - runComplexContenteditableTests(); - - // test whether the IME state and composition are not changed unexpectedly - runEditorFlagChangeTests(); - - // test password field on dialog - // XXX temporary disable against failure - //runTestPasswordFieldOnDialog(); - - // Asynchronous tests - runEditorReframeTests(function () { - // This will call onFinish(), so, this test must be the last. - runEditableSubframeTests(); - }); -} - -function onFinish() -{ - SimpleTest.finish(); -} - -</script> -</body> - -</html> diff --git a/widget/tests/test_input_events_on_deactive_window.xul b/widget/tests/test_input_events_on_deactive_window.xul deleted file mode 100644 index a85646266..000000000 --- a/widget/tests/test_input_events_on_deactive_window.xul +++ /dev/null @@ -1,236 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Testing composition, text and query content events" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> -</div> -<p id="display"> - <textarea id="textarea"></textarea> -</p> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -SimpleTest.waitForFocus(runTests, window); - -var fm = Components.classes["@mozilla.org/focus-manager;1"]. - getService(Components.interfaces.nsIFocusManager); -var textarea = document.getElementById("textarea"); -var otherWindow; -var timer; - -function runTests() -{ - textarea.focus(); - is(fm.focusedElement, textarea, "we're deactive"); - if (fm.focusedElement != textarea) { - SimpleTest.finish(); - return; - } - - otherWindow = - window.open("data:text/plain,this is an active window.", "_blank", - "chrome,width=100,height=100"); - ok(otherWindow, "failed to open other window"); - if (!otherWindow) { - SimpleTest.finish(); - return; - } - - SimpleTest.waitForFocus(startTests, otherWindow); - otherWindow.focus(); -} - -function startTests() -{ - clearTimeout(timer); - isnot(fm.focusedWindow, window, "we're not deactive"); - if (fm.focusedWindow == window) { - otherWindow.close(); - SimpleTest.finish(); - return; - } - - var keydownHandled, keypressHandled, keyupHandled, compositionstartHandled, - compositionendHandled, compositionupdateHandled, inputHandled; - - function clear() - { - keydownHandled = false; - keypressHandled = false; - keyupHandled = false; - compositionstartHandled = false; - compositionendHandled = false; - compositionupdateHandled = false; - inputHandled = false; - } - - function onEvent(aEvent) - { - if (aEvent.type == "keydown") { - keydownHandled = true; - } else if (aEvent.type == "keypress") { - keypressHandled = true; - } else if (aEvent.type == "keyup") { - keyupHandled = true; - } else if (aEvent.type == "compositionstart") { - compositionstartHandled = true; - } else if (aEvent.type == "compositionend") { - compositionendHandled = true; - } else if (aEvent.type == "compositionupdate") { - compositionupdateHandled = true; - } else if (aEvent.type == "input") { - inputHandled = true; - } else { - ok(false, "handled unknown event: " + aEvent.type); - } - } - - textarea.addEventListener("keydown", onEvent, false); - textarea.addEventListener("keypress", onEvent, false); - textarea.addEventListener("keyup", onEvent, false); - textarea.addEventListener("compositionstart", onEvent, false); - textarea.addEventListener("compositionend", onEvent, false); - textarea.addEventListener("compositionupdate", onEvent, false); - textarea.addEventListener("input", onEvent, false); - - startTestsInternal(); - - function startTestsInternal() - { - // key events - function checkKeyEvents(aKeydown, aKeypress, aKeyup, aInput, aDescription) - { - is(keydownHandled, aKeydown, - "keydown event is (not) handled: " + aDescription); - is(keypressHandled, aKeypress, - "keypress event is (not) handled: " + aDescription); - is(keyupHandled, aKeyup, - "keyup event is (not) handled: " + aDescription); - is(inputHandled, aInput, - "input event is (not) handled: " + aDescription); - } - - function checkCompositionEvents(aStart, aEnd, aUpdate, aInput, aDescription) - { - is(compositionstartHandled, aStart, - "compositionstart event is (not) handled: " + aDescription); - is(compositionendHandled, aEnd, - "compositionend event is (not) handled: " + aDescription); - is(compositionupdateHandled, aUpdate, - "compositionupdate event is (not) handled: " + aDescription); - is(inputHandled, aInput, - "input event is (not) handled: " + aDescription); - } - - clear(); - synthesizeKey("a", { type: "keydown" }); - checkKeyEvents(true, true, false, true, "a keydown and a keypress"); - is(textarea.value, "a", "textarea value isn't 'a'"); - clear(); - synthesizeKey("a", { type: "keyup" }); - checkKeyEvents(false, false, true, false, "a keyup"); - clear(); - synthesizeKey("VK_BACK_SPACE", {}); - checkKeyEvents(true, true, true, true, "VK_BACK_SPACE key events"); - is(textarea.value, "", "textarea value isn't empty"); - - // IME events - clear(); - // input first character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - checkCompositionEvents(true, false, true, true, "starting to compose"); - var queryText = synthesizeQueryTextContent(0, 100); - ok(queryText, "query text event result is null"); - if (!queryText) { - return; - } - ok(queryText.succeeded, "query text event failed"); - if (!queryText.succeeded) { - return; - } - is(queryText.text, "\u3089", "composing text is incorrect"); - var querySelectedText = synthesizeQuerySelectedText(); - ok(querySelectedText, "query selected text event result is null"); - if (!querySelectedText) { - return; - } - ok(querySelectedText.succeeded, "query selected text event failed"); - if (!querySelectedText.succeeded) { - return; - } - is(querySelectedText.offset, 1, - "query selected text event returns wrong offset"); - is(querySelectedText.text, "", - "query selected text event returns wrong selected text"); - clear(); - // commit composition - synthesizeComposition({ type: "compositioncommitasis" }); - checkCompositionEvents(false, true, false, true, "commit composition as is"); - queryText = synthesizeQueryTextContent(0, 100); - ok(queryText, "query text event result is null after commit"); - if (!queryText) { - return; - } - ok(queryText.succeeded, "query text event failed after commit"); - if (!queryText.succeeded) { - return; - } - is(queryText.text, "\u3089", "composing text is incorrect after commit"); - querySelectedText = synthesizeQuerySelectedText(); - ok(querySelectedText, - "query selected text event result is null after commit"); - if (!querySelectedText) { - return; - } - ok(querySelectedText.succeeded, - "query selected text event failed after commit"); - if (!querySelectedText.succeeded) { - return; - } - is(querySelectedText.offset, 1, - "query selected text event returns wrong offset after commit"); - is(querySelectedText.text, "", - "query selected text event returns wrong selected text after commit"); - clear(); - } - - textarea.removeEventListener("keydown", onEvent, false); - textarea.removeEventListener("keypress", onEvent, false); - textarea.removeEventListener("keyup", onEvent, false); - textarea.removeEventListener("compositionstart", onEvent, false); - textarea.removeEventListener("compositionupdate", onEvent, false); - textarea.removeEventListener("compositionend", onEvent, false); - textarea.removeEventListener("input", onEvent, false); - - otherWindow.close(); - - SimpleTest.finish(); -} - - -]]> -</script> -</window> diff --git a/widget/tests/test_key_event_counts.xul b/widget/tests/test_key_event_counts.xul deleted file mode 100644 index 4dd4b83da..000000000 --- a/widget/tests/test_key_event_counts.xul +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> - -<!-- We've had issues on Mac OS X where native key events either don't get processed - or they get processed twice. This test tests some of those scenarios. --> - -<window id="window1" title="Test Key Event Counts" onload="runTest()" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> - <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"/> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - - <script type="application/javascript"><![CDATA[ - var gKeyPressEventCount = 0; - var gKeyDownEventCound = 0; - - function onKeyDown(e) - { - gKeyDownEventCount++; - } - - function onKeyPress(e) - { - gKeyPressEventCount++; - e.preventDefault(); - } - - function* testBody() - { - window.addEventListener("keydown", onKeyDown, false); - window.addEventListener("keypress", onKeyPress, false); - - // Test ctrl-tab - gKeyDownEventCount = 0; - gKeyPressEventCount = 0; - yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t", continueTest); - is(gKeyDownEventCount, 1); - is(gKeyPressEventCount, 0, "ctrl-tab should be consumed by tabbox of tabbrowser at keydown"); - - // Test cmd+shift+a - gKeyDownEventCount = 0; - gKeyPressEventCount = 0; - yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A", continueTest); - is(gKeyDownEventCount, 1); - is(gKeyPressEventCount, 1); - - // Test cmd-; - gKeyDownEventCount = 0; - gKeyPressEventCount = 0; - yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";", continueTest); - is(gKeyDownEventCount, 1); - is(gKeyPressEventCount, 1); - - window.removeEventListener("keydown", onKeyDown, false); - window.removeEventListener("keypress", onKeyPress, false); - } - - var gTestContinuation = null; - - function continueTest() - { - if (!gTestContinuation) { - gTestContinuation = testBody(); - } - var ret = gTestContinuation.next(); - if (ret.done) { - SimpleTest.finish(); - } else { - is(ret.value, true, "Key synthesized successfully"); - } - } - - function runTest() - { - SimpleTest.waitForExplicitFinish(); - continueTest(); - } - ]]></script> - -</window> diff --git a/widget/tests/test_keycodes.xul b/widget/tests/test_keycodes.xul deleted file mode 100644 index 3ec460ecb..000000000 --- a/widget/tests/test_keycodes.xul +++ /dev/null @@ -1,4361 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Key event tests" - onload="runTest()" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<commandset> - <command id="expectedCommand" oncommand="this.activeCount++" disabled="true"/> - <command id="unexpectedCommand" oncommand="this.activeCount++" disabled="true"/> - <command id="expectedReservedCommand" oncommand="this.activeCount++" reserved="true" disabled="true"/> -</commandset> -<keyset> - <key id="unshiftedKey" key=";" modifiers="accel" command="unexpectedCommand"/> - <key id="shiftedKey" key=":" modifiers="accel" command="unexpectedCommand"/> - <key id="commandOptionF" key='f' modifiers="accel,alt" command="unexpectedCommand"/> - <key id="question" key='?' modifiers="accel" command="unexpectedCommand"/> - <key id="unshiftedX" key="x" modifiers="accel" command="unexpectedCommand"/> - <key id="shiftedX" key="X" modifiers="accel,shift" command="unexpectedCommand"/> - <key id="unshiftedPlus" key="+" modifiers="accel" command="unexpectedCommand"/> - <key id="reservedUnshiftedKey" key="'" modifiers="accel" command="unexpectedCommand"/> - <key id="reservedShiftedKey" key='"' modifiers="accel" command="unexpectedCommand"/> -</keyset> - -<browser id="browser" type="content" src="data:text/html;charset=utf-8,<button id='content_button'>button</button>" width="200" height="32"/> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"> - <!-- for some reason, if we don't have 'accesskey' here, adding it dynamically later - doesn't work! --> - <button id="button" accesskey="z">Hello</button> - <input type="text" id="textbox" value=""/> -</p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -const IS_MAC = navigator.platform.indexOf("Mac") == 0; -const IS_WIN = navigator.platform.indexOf("Win") == 0; -const OS_VERSION = - IS_WIN ? parseFloat(Components.classes["@mozilla.org/system-info;1"] - .getService(Components.interfaces.nsIPropertyBag2) - .getProperty("version")) : 0; -const WIN7 = 6.1; -const WIN8 = 6.2; - -function isModifierKeyEvent(aEvent) -{ - switch (aEvent.key) { - case "Alt": - case "AltGraph": - case "CapsLock": - case "Control": - case "Fn": - case "FnLock": - case "Hyper": - case "Meta": - case "NumLock": - case "ScrollLock": - case "Shift": - case "Super": - case "Symbol": - case "SymbolLock": - return true; - default: - return false; - } -} - -/** - * Firefox infobar UI can have access keys which conflict with this test. Really - * stupid workaround until we can move this test into its own chrome window. - */ -function clearInfobars() -{ - var Ci = Components.interfaces; - - var browser = window.top.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell).chromeEventHandler; - var chromeWin = browser.ownerDocument.defaultView; - var nb = chromeWin.gBrowser.getNotificationBox(browser); - for (let n of nb.allNotifications) { - nb.removeNotification(n, true); - } -} - -function eventToString(aEvent) -{ - var name = aEvent.layout.name + " keyCode=" + - aEvent.keyCode + " (0x" + aEvent.keyCode.toString(16).toUpperCase() + - ") chars='" + aEvent.chars + "'"; - if (typeof aEvent.unmodifiedChars === "string") { - name += " unmodifiedChars='" + aEvent.unmodifiedChars + "'"; - } - if (aEvent.modifiers.shiftKey) { - name += " [Shift]"; - } - if (aEvent.modifiers.shiftRightKey) { - name += " [Right Shift]"; - } - if (aEvent.modifiers.ctrlKey) { - name += " [Ctrl]"; - } - if (aEvent.modifiers.ctrlRightKey) { - name += " [Right Ctrl]"; - } - if (aEvent.modifiers.altKey) { - name += " [Alt]"; - } - if (aEvent.modifiers.altRightKey) { - name += " [Right Alt]"; - } - if (aEvent.modifiers.metaKey) { - name += " [Command]"; - } - if (aEvent.modifiers.metaRightKey) { - name += " [Right Command]"; - } - - return name; -} - -function getPhase(aDOMEvent) -{ - switch (aDOMEvent.eventPhase) { - case aDOMEvent.None: - return "none"; - case aDOMEvent.CAPTURING_PHASE: - return "capture"; - case aDOMEvent.AT_TARGET: - return "target"; - case aDOMEvent.BUBBLING_PHASE: - return "bubble"; - default: - return ""; - } -} - -function eventTargetToString(aEventTarget) -{ - if (aEventTarget.navigator) { - return "window"; - } - switch (aEventTarget.nodeType) { - case Node.ELEMENT_NODE: - return "element (" + aEventTarget.tagName + ")"; - case Node.DOCUMENT_NODE: - return "document"; - default: - return ""; - } -} - -function synthesizeKey(aEvent, aFocusElementId, aCallback) -{ - if (aFocusElementId.startsWith("content_")) { - var browser = document.getElementById("browser"); - browser.contentDocument.getElementById(aFocusElementId).focus(); - } else { - document.getElementById(aFocusElementId).focus(); - } - - return synthesizeNativeKey(aEvent.layout, aEvent.keyCode, - aEvent.modifiers, - aEvent.chars, aEvent.unmodifiedChars, - aCallback); -} - -// Test the charcodes and modifiers being delivered to keypress handlers and -// also keydown/keyup events too. -function* runKeyEventTests() -{ - const nsIDOMKeyEvent = Components.interfaces.nsIDOMKeyEvent; - var eventList, keyDownFlags, keyUpFlags, testingEvent, expectedDOMKeyCode; - const kShiftFlag = 0x1; - const kCtrlFlag = 0x2; - const kAltFlag = 0x4; - const kMetaFlag = 0x8; - const kNumLockFlag = 0x10; - const kCapsLockFlag = 0x20; - - function onKeyEvent(e) - { - function removeFlag(e, aFlag) - { - if (e.type == "keydown") { - var oldValue = keyDownFlags; - keyDownFlags &= ~aFlag; - return oldValue != keyDownFlags; - } else if (e.type == "keyup") { - var oldValue = keyUpFlags; - keyUpFlags &= ~aFlag; - return oldValue != keyUpFlags; - } - return false; - } - - function isStateChangingModifierKeyEvent(e) - { - var flags = 0; - if (e.type == "keydown") { - flags = keyDownFlags ^ keyUpFlags; - } else if (e.type == "keyup") { - flags = keyUpFlags; - } - switch (e.keyCode) { - case e.DOM_VK_SHIFT: - is(e.ctrlKey, (flags & kCtrlFlag) != 0, name + ", Ctrl of Shift " + e.type + " event mismatch"); - is(e.metaKey, (flags & kMetaFlag) != 0, name + ", Command of Shift " + e.type + " event mismatch"); - is(e.altKey, (flags & kAltFlag) != 0, name + ", Alt of Shift " + e.type + " event mismatch"); - is(e.shiftKey, e.type == "keydown", name + ", Shift of Shift " + e.type + " event mismatch"); - return (testingEvent.modifiers.shiftKey || testingEvent.modifiers.shiftRightKey) && - removeFlag(e, kShiftFlag) && expectedDOMKeyCode != e.keyCode; - case e.DOM_VK_CONTROL: - is(e.ctrlKey, e.type == "keydown", name + ", Ctrl of Ctrl " + e.type + " event mismatch"); - is(e.metaKey, (flags & kMetaFlag) != 0, name + ", Command of Ctrl " + e.type + " event mismatch"); - is(e.altKey, (flags & kAltFlag) != 0, name + ", Alt of Ctrl " + e.type + " event mismatch"); - is(e.shiftKey, (flags & kShiftFlag) != 0, name + ", Shift of Ctrl " + e.type + " event mismatch"); - return (testingEvent.modifiers.ctrlKey || testingEvent.modifiers.ctrlRightKey || (IS_WIN && testingEvent.modifiers.altGrKey)) && - removeFlag(e, kCtrlFlag) && expectedDOMKeyCode != e.keyCode; - case e.DOM_VK_ALT: - is(e.ctrlKey, (flags & kCtrlFlag) != 0, name + ", Ctrl of Alt " + e.type + " event mismatch"); - is(e.metaKey, (flags & kMetaFlag) != 0, name + ", Command of Alt " + e.type + " event mismatch"); - is(e.altKey, e.type == "keydown", name + ", Alt of Alt " + e.type + " event mismatch"); - is(e.shiftKey, (flags & kShiftFlag) != 0, name + ", Shift of Alt " + e.type + " event mismatch"); - return (testingEvent.modifiers.altKey || testingEvent.modifiers.altRightKey || (IS_WIN && testingEvent.modifiers.altGrKey)) && - removeFlag(e, kAltFlag) && expectedDOMKeyCode != e.keyCode; - case e.DOM_VK_META: - is(e.ctrlKey, (flags & kCtrlFlag) != 0, name + ", Ctrl of Command " + e.type + " evnet mismatch"); - is(e.metaKey, e.type == "keydown", name + ", Command of Command " + e.type + " evnet mismatch"); - is(e.altKey, (flags & kAltFlag) != 0, name + ", Alt of Command " + e.type + " evnet mismatch"); - is(e.shiftKey, (flags & kShiftFlag) != 0, name + ", Shift of Command " + e.type + " evnet mismatch"); - return (testingEvent.modifiers.metaKey || testingEvent.modifiers.metaRightKey) && - removeFlag(e, kMetaFlag) && expectedDOMKeyCode != e.keyCode; - case e.DOM_VK_NUM_LOCK: - is(e.ctrlKey, (flags & kCtrlFlag) != 0, name + ", Ctrl of NumLock " + e.type + " event mismatch"); - is(e.metaKey, (flags & kMetaFlag) != 0, name + ", Command of NumLock " + e.type + " event mismatch"); - is(e.altKey, (flags & kAltFlag) != 0, name + ", Alt of NumLock " + e.type + " event mismatch"); - is(e.shiftKey, (flags & kShiftFlag) != 0, name + ", Shift of NumLock " + e.type + " event mismatch"); - return (testingEvent.modifiers.numLockKey || testingEvent.modifiers.numericKeyPadKey) && - removeFlag(e, kNumLockFlag) && expectedDOMKeyCode != e.keyCode; - case e.DOM_VK_CAPS_LOCK: - is(e.ctrlKey, (flags & kCtrlFlag) != 0, name + ", Ctrl of CapsLock " + e.type + " event mismatch"); - is(e.metaKey, (flags & kMetaFlag) != 0, name + ", Command of CapsLock " + e.type + " event mismatch"); - is(e.altKey, (flags & kAltFlag) != 0, name + ", Alt of CapsLock " + e.type + " event mismatch"); - is(e.shiftKey, (flags & kShiftFlag) != 0, name + ", Shift of CapsLock " + e.type + " event mismatch"); - return testingEvent.modifiers.capsLockKey && - removeFlag(e, kCapsLockFlag) && expectedDOMKeyCode != e.keyCode; - } - return false; - } - - // Ignore the state changing key events which is fired by the testing event. - if (!isStateChangingModifierKeyEvent(e)) - eventList.push(e); - } - - function consumer(aEvent) - { - aEvent.preventDefault(); - } - - const SHOULD_DELIVER_NONE = 0x0; - const SHOULD_DELIVER_KEYDOWN = 0x1; - const SHOULD_DELIVER_KEYPRESS = 0x2; - const SHOULD_DELIVER_KEYUP = 0x4; - const SHOULD_DELIVER_ALL = SHOULD_DELIVER_KEYDOWN | - SHOULD_DELIVER_KEYPRESS | - SHOULD_DELIVER_KEYUP; - const SHOULD_DELIVER_KEYDOWN_KEYUP = SHOULD_DELIVER_KEYDOWN | - SHOULD_DELIVER_KEYUP; - const SHOULD_DELIVER_KEYDOWN_KEYPRESS = SHOULD_DELIVER_KEYDOWN | - SHOULD_DELIVER_KEYPRESS; - - // The first parameter is the complete input event. The second parameter is - // what to test against. The third parameter is which key events should be - // delived for the event. - // @param aExpectedKeyValues Can be string or array of string. - // If all keyboard events have same key value, - // specify it as string. Otherwise, specify - // each key value in array. - function testKey(aEvent, aExpectedKeyValues, aExpectedCodeValue, - aExpectedGeckoKeyCode, aExpectGeckoChar, - aShouldDelivedEvent, aExpectLocation) - { - ok(aExpectedGeckoKeyCode != undefined, "keycode is undefined"); - eventList = []; - - // The modifier key events which are fired for state changing are har to - // test. We should ignore them for now. - keyDownFlags = keyUpFlags = 0; - if (!IS_MAC) { - // On Mac, nsChildView doesn't generate modifier keydown/keyup events for - // state changing for synthesizeNativeKeyEvent. - if (aEvent.modifiers.shiftKey || aEvent.modifiers.shiftRightKey) { - keyDownFlags |= kShiftFlag; - } - if (aEvent.modifiers.ctrlKey || aEvent.modifiers.ctrlRightKey || - (IS_WIN && aEvent.modifiers.altGrKey)) { - keyDownFlags |= kCtrlFlag; - } - if (aEvent.modifiers.altKey || aEvent.modifiers.altRightKey || - (IS_WIN && aEvent.modifiers.altGrKey)) { - keyDownFlags |= kAltFlag; - } - if (aEvent.modifiers.metaKey || aEvent.modifiers.metaRightKey) { - keyDownFlags |= kMetaFlag; - } - if (aEvent.modifiers.numLockKey || aEvent.modifiers.numericKeyPadKey) { - keyDownFlags |= kNumLockFlag; - } - if (aEvent.modifiers.capsLockKey) { - keyDownFlags |= kCapsLockFlag; - } - keyUpFlags = keyDownFlags; - } - - testingEvent = aEvent; - expectedDOMKeyCode = aExpectedGeckoKeyCode; - - var name = eventToString(aEvent); - ok(true, "Starting: " + name); - - return synthesizeKey(aEvent, "button", function() { - - var expectEventTypeList = []; - if (aShouldDelivedEvent & SHOULD_DELIVER_KEYDOWN) - expectEventTypeList.push("keydown"); - if (aShouldDelivedEvent & SHOULD_DELIVER_KEYPRESS) { - expectEventTypeList.push("keypress"); - for (var i = 1; i < aExpectGeckoChar.length; i++) { - expectEventTypeList.push("keypress"); - } - } - if (aShouldDelivedEvent & SHOULD_DELIVER_KEYUP) - expectEventTypeList.push("keyup"); - is(eventList.length, expectEventTypeList.length, name + ", wrong number of key events"); - - var longerLength = Math.max(eventList.length, expectEventTypeList.length); - var keypressCount = 0; - for (var i = 0; i < longerLength; i++) { - var firedEventType = i < eventList.length ? eventList[i].type : ""; - var expectEventType = i < expectEventTypeList.length ? expectEventTypeList[i] : ""; - if (firedEventType != "") - is(firedEventType, expectEventType, name + ", " + expectEventType + " should be fired"); - else - is(firedEventType, expectEventType, name + ", a needed event is not fired"); - - if (firedEventType != "") { - var e = eventList[i]; - if (e.type == "keypress") { - var isCtrlExpected = - !!(aEvent.modifiers.ctrlKey || aEvent.modifiers.ctrlRightKey) && !aEvent.isInputtingCharacters; - var isAltExpected = - !!(aEvent.modifiers.altKey || aEvent.modifiers.altRightKey) && !aEvent.isInputtingCharacters; - if (IS_WIN && (aEvent.modifiers.altGrKey || isCtrlExpected && isAltExpected)) { - isCtrlExpected = isAltExpected = (aEvent.chars == ""); - } - is(e.ctrlKey, isCtrlExpected, name + ", Ctrl mismatch"); - is(e.metaKey, !!(aEvent.modifiers.metaKey || aEvent.modifiers.metaRightKey), name + ", Command mismatch"); - is(e.altKey, isAltExpected, name + ", Alt mismatch"); - is(e.shiftKey, !!(aEvent.modifiers.shiftKey || aEvent.modifiers.shiftRightKey), name + ", Shift mismatch"); - } - - var expectedKeyValue = - typeof aExpectedKeyValues === "string" ? aExpectedKeyValues : - i < aExpectedKeyValues.length ? aExpectedKeyValues[i] : - undefined; - is(e.key, expectedKeyValue, name + ", wrong key value"); - is(e.code, aExpectedCodeValue, name + ", wrong code value"); - - if (aExpectGeckoChar.length > 0 && e.type == "keypress") { - is(e.charCode, aExpectGeckoChar.charCodeAt(keypressCount++), name + ", charcode"); - if (aExpectedGeckoKeyCode >= 0) { - if (aExpectGeckoChar) { - is(e.keyCode, 0, name + ", wrong keycode"); - } else { - is(e.keyCode, aExpectedGeckoKeyCode, name + ", wrong keycode"); - } - } - } else { - is(e.charCode, 0, name + ", no charcode"); - if (aExpectedGeckoKeyCode >= 0) { - is(e.keyCode, aExpectedGeckoKeyCode, name + ", wrong keycode"); - } - } - is(e.location, aExpectLocation, name + ", wrong location"); - } - } - - continueTest(); - }); - } - - // These tests have to be per-plaform. - document.addEventListener("keydown", onKeyEvent, false); - document.addEventListener("keypress", onKeyEvent, false); - document.addEventListener("keyup", onKeyEvent, false); - // Prevent almost all shortcut key handlers. - SpecialPowers.addSystemEventListener(document, "keypress", consumer, true); - - function cleanup() - { - document.removeEventListener("keydown", onKeyEvent, false); - document.removeEventListener("keypress", onKeyEvent, false); - document.removeEventListener("keyup", onKeyEvent, false); - SpecialPowers.removeSystemEventListener(document, "keypress", consumer, true); - } - - function testKeysOnMac() - { - // On Mac, you can produce event records for any desired keyboard input - // by running with NSPR_LOG_MODULES=TextInputHandlerWidgets:5 and typing - // into the browser. We will dump the key event fields to the console - // (Find TextInputHandler::HandleKeyDownEvent or - // TextInputHandler::HandleKeyUpEvent in the log). Use the International system - // preferences widget to enable other keyboard layouts and select them from the - // input menu to see what keyboard events they generate. - // Note that it's possible to send bogus key events here, e.g. - // {keyCode:0, chars:"z", unmodifiedChars:"P"} --- sendNativeKeyEvent - // makes no attempt to verify that the keyCode matches the characters. So only - // test key event records that you saw Cocoa send. - - // Ctrl keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001", unmodifiedChars:"A"}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Alt keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{altKey:1}, chars:"\u00e5", unmodifiedChars:"a"}, - "\u00e5", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00e5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{altKey:1, shiftKey:1}, chars:"\u00c5", unmodifiedChars:"A"}, - "\u00c5", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00c5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Command keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1}, chars:"a", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Shift-cmd gives us the shifted character - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, shiftKey:1}, chars:"a", unmodifiedChars:"A"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Ctrl-cmd gives us the unshifted character - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, ctrlKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Alt-cmd gives us the shifted character - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, altKey:1}, chars:"\u00e5", unmodifiedChars:"a"}, - "\u00e5", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00e5", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, altKey:1, shiftKey:1}, chars:"\u00c5", unmodifiedChars:"a"}, - "\u00c5", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00c5", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Greek ctrl keys produce Latin charcodes - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "\u03b1", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001", unmodifiedChars:"\u0391"}, - "\u0391", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Greek command keys - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1}, chars:"a", unmodifiedChars:"\u03b1"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Shift-cmd gives us the shifted character - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, shiftKey:1}, chars:"a", unmodifiedChars:"\u0391"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Ctrl-cmd gives us the unshifted character - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, ctrlKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "\u03b1", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Alt-cmd gives us the shifted character - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, altKey:1}, chars:"\u00a8", unmodifiedChars:"\u03b1"}, - "\u00a8", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00a8", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1, altKey:1, shiftKey:1}, chars:"\u00b9", unmodifiedChars:"\u0391"}, - "\u00b9", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00b9", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // German - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_A, - modifiers: {}, chars:"a", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers: {}, chars:"\u00fc", unmodifiedChars:"\u00fc"}, - "\u00fc", "BracketLeft", 0, "\u00fc", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_Minus, - modifiers: {}, chars:"\u00df", unmodifiedChars:"\u00df"}, - "\u00df", "Minus", nsIDOMKeyEvent.DOM_VK_QUESTION_MARK, "\u00df", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_Minus, - modifiers:{shiftKey:1}, chars:"?", unmodifiedChars:"?"}, - "?", "Minus", nsIDOMKeyEvent.DOM_VK_QUESTION_MARK, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Note that Shift+SS is '?' but Cmd+Shift+SS is '/' on German layout. - // Therefore, when Cmd key is pressed, the SS key's keycode is changed. - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_Minus, - modifiers:{metaKey:1}, chars:"\u00df", unmodifiedChars:"\u00df"}, - "\u00df", "Minus", nsIDOMKeyEvent.DOM_VK_SLASH, "\u00df", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_Minus, - modifiers:{metaKey:1, shiftKey:1}, chars:"/", unmodifiedChars:"?"}, - "/", "Minus", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Caps Lock key event - // XXX keyup event of Caps Lock key is not fired. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_CapsLock, - modifiers:{capsLockKey:1}, chars:"", unmodifiedChars:""}, - "CapsLock", "CapsLock", nsIDOMKeyEvent.DOM_VK_CAPS_LOCK, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_CapsLock, - modifiers:{capsLockKey:0}, chars:"", unmodifiedChars:""}, - "CapsLock", "CapsLock", nsIDOMKeyEvent.DOM_VK_CAPS_LOCK, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Shift/RightShift key event - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Shift, - modifiers:{shiftKey:1}, chars:"", unmodifiedChars:""}, - "Shift", "ShiftLeft", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Shift, - modifiers:{shiftKey:0}, chars:"", unmodifiedChars:""}, - "Shift", "ShiftLeft", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightShift, - modifiers:{shiftRightKey:1}, chars:"", unmodifiedChars:""}, - "Shift", "ShiftRight", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightShift, - modifiers:{shiftRightKey:0}, chars:"", unmodifiedChars:""}, - "Shift", "ShiftRight", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Control/RightControl key event - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Control, - modifiers:{ctrlKey:1}, chars:"", unmodifiedChars:""}, - "Control", "ControlLeft", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Control, - modifiers:{ctrlKey:0}, chars:"", unmodifiedChars:""}, - "Control", "ControlLeft", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightControl, - modifiers:{ctrlRightKey:1}, chars:"", unmodifiedChars:""}, - "Control", "ControlRight", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightControl, - modifiers:{ctrlRightKey:0}, chars:"", unmodifiedChars:""}, - "Control", "ControlRight", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Option/RightOption key event - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Option, - modifiers:{altKey:1}, chars:"", unmodifiedChars:""}, - "Alt", "AltLeft", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Option, - modifiers:{altKey:0}, chars:"", unmodifiedChars:""}, - "Alt", "AltLeft", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightOption, - modifiers:{altRightKey:1}, chars:"", unmodifiedChars:""}, - "Alt", "AltRight", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightOption, - modifiers:{altRightKey:0}, chars:"", unmodifiedChars:""}, - "Alt", "AltRight", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Command/RightCommand key event - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Command, - modifiers:{metaKey:1}, chars:"", unmodifiedChars:""}, - "Meta", "OSLeft", nsIDOMKeyEvent.DOM_VK_META, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Command, - modifiers:{metaKey:0}, chars:"", unmodifiedChars:""}, - "Meta", "OSLeft", nsIDOMKeyEvent.DOM_VK_META, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightCommand, - modifiers:{metaRightKey:1}, chars:"", unmodifiedChars:""}, - "Meta", "OSRight", nsIDOMKeyEvent.DOM_VK_META, "", SHOULD_DELIVER_KEYDOWN, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightCommand, - modifiers:{metaRightKey:0}, chars:"", unmodifiedChars:""}, - "Meta", "OSRight", nsIDOMKeyEvent.DOM_VK_META, "", SHOULD_DELIVER_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // all keys on keyboard (keyCode test) - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Tab, - modifiers: {}, chars:"\t", unmodifiedChars:"\t"}, - "Tab", "Tab", nsIDOMKeyEvent.DOM_VK_TAB, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadClear, - modifiers: {}, chars:"\uF739", unmodifiedChars:"\uF739"}, - "Clear", "NumLock", nsIDOMKeyEvent.DOM_VK_CLEAR, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Return, - modifiers: {}, chars:"\u000D", unmodifiedChars:"\u000D"}, - "Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PC_Pause, - modifiers: {}, chars:"\uF712", unmodifiedChars:"\uF712"}, - "F15", "F15", nsIDOMKeyEvent.DOM_VK_PAUSE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Escape, - modifiers: {}, chars:"\u001B", unmodifiedChars:"\u001B"}, - "Escape", "Escape", nsIDOMKeyEvent.DOM_VK_ESCAPE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Space, - modifiers: {}, chars:" ", unmodifiedChars:" "}, - " ", "Space", nsIDOMKeyEvent.DOM_VK_SPACE, " ", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PageUp, - modifiers: {}, chars:"\uF72C", unmodifiedChars:"\uF72C"}, - "PageUp", "PageUp", nsIDOMKeyEvent.DOM_VK_PAGE_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PageDown, - modifiers: {}, chars:"\uF72D", unmodifiedChars:"\uF72D"}, - "PageDown", "PageDown", nsIDOMKeyEvent.DOM_VK_PAGE_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_End, - modifiers: {}, chars:"\uF72B", unmodifiedChars:"\uF72B"}, - "End", "End", nsIDOMKeyEvent.DOM_VK_END, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_Home, - modifiers: {}, chars:"\uF729", unmodifiedChars:"\uF729"}, - "Home", "Home", nsIDOMKeyEvent.DOM_VK_HOME, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_LeftArrow, - modifiers: {}, chars:"\uF702", unmodifiedChars:"\uF702"}, - "ArrowLeft", "ArrowLeft", nsIDOMKeyEvent.DOM_VK_LEFT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_UpArrow, - modifiers: {}, chars:"\uF700", unmodifiedChars:"\uF700"}, - "ArrowUp", "ArrowUp", nsIDOMKeyEvent.DOM_VK_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_RightArrow, - modifiers: {}, chars:"\uF703", unmodifiedChars:"\uF703"}, - "ArrowRight", "ArrowRight", nsIDOMKeyEvent.DOM_VK_RIGHT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_DownArrow, - modifiers: {}, chars:"\uF701", unmodifiedChars:"\uF701"}, - "ArrowDown", "ArrowDown", nsIDOMKeyEvent.DOM_VK_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PC_PrintScreen, - modifiers: {}, chars:"\uF710", unmodifiedChars:"\uF710"}, - "F13", "F13", nsIDOMKeyEvent.DOM_VK_PRINTSCREEN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PC_Delete, - modifiers: {}, chars:"\uF728", unmodifiedChars:"\uF728"}, - "Delete", "Delete", nsIDOMKeyEvent.DOM_VK_DELETE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PC_ScrollLock, - modifiers: {}, chars:"\uF711", unmodifiedChars:"\uF711"}, - "F14", "F14", nsIDOMKeyEvent.DOM_VK_SCROLL_LOCK, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_PC_ContextMenu, - modifiers: {}, chars:"\u0010", unmodifiedChars:"\u0010"}, - "ContextMenu", "ContextMenu", nsIDOMKeyEvent.DOM_VK_CONTEXT_MENU, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F1, - modifiers:{fnKey:1}, chars:"\uF704", unmodifiedChars:"\uF704"}, - "F1", "F1", nsIDOMKeyEvent.DOM_VK_F1, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F2, - modifiers:{fnKey:1}, chars:"\uF705", unmodifiedChars:"\uF705"}, - "F2", "F2", nsIDOMKeyEvent.DOM_VK_F2, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F3, - modifiers:{fnKey:1}, chars:"\uF706", unmodifiedChars:"\uF706"}, - "F3", "F3", nsIDOMKeyEvent.DOM_VK_F3, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F4, - modifiers:{fnKey:1}, chars:"\uF707", unmodifiedChars:"\uF707"}, - "F4", "F4", nsIDOMKeyEvent.DOM_VK_F4, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F5, - modifiers:{fnKey:1}, chars:"\uF708", unmodifiedChars:"\uF708"}, - "F5", "F5", nsIDOMKeyEvent.DOM_VK_F5, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F6, - modifiers:{fnKey:1}, chars:"\uF709", unmodifiedChars:"\uF709"}, - "F6", "F6", nsIDOMKeyEvent.DOM_VK_F6, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F7, - modifiers:{fnKey:1}, chars:"\uF70A", unmodifiedChars:"\uF70A"}, - "F7", "F7", nsIDOMKeyEvent.DOM_VK_F7, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F8, - modifiers:{fnKey:1}, chars:"\uF70B", unmodifiedChars:"\uF70B"}, - "F8", "F8", nsIDOMKeyEvent.DOM_VK_F8, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F9, - modifiers:{fnKey:1}, chars:"\uF70C", unmodifiedChars:"\uF70C"}, - "F9", "F9", nsIDOMKeyEvent.DOM_VK_F9, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F10, - modifiers:{fnKey:1}, chars:"\uF70D", unmodifiedChars:"\uF70D"}, - "F10", "F10", nsIDOMKeyEvent.DOM_VK_F10, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F11, - modifiers:{fnKey:1}, chars:"\uF70E", unmodifiedChars:"\uF70E"}, - "F11", "F11", nsIDOMKeyEvent.DOM_VK_F11, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F12, - modifiers:{fnKey:1}, chars:"\uF70F", unmodifiedChars:"\uF70F"}, - "F12", "F12", nsIDOMKeyEvent.DOM_VK_F12, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F16, - modifiers:{fnKey:1}, chars:"\uF713", unmodifiedChars:"\uF713"}, - "F16", "F16", nsIDOMKeyEvent.DOM_VK_F16, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F17, - modifiers:{fnKey:1}, chars:"\uF714", unmodifiedChars:"\uF714"}, - "F17", "F17", nsIDOMKeyEvent.DOM_VK_F17, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F18, - modifiers:{fnKey:1}, chars:"\uF715", unmodifiedChars:"\uF715"}, - "F18", "F18", nsIDOMKeyEvent.DOM_VK_F18, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_F19, - modifiers:{fnKey:1}, chars:"\uF716", unmodifiedChars:"\uF716"}, - "F19", "F19", nsIDOMKeyEvent.DOM_VK_F19, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // US - // Alphabet - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers: {}, chars:"a", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{shiftKey:1}, chars:"A", unmodifiedChars:"A"}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{altKey:1}, chars:"\u00E5", unmodifiedChars:"a"}, - "\u00E5", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{metaKey:1}, chars:"a", unmodifiedChars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_B, - modifiers:{}, chars:"b", unmodifiedChars:"b"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_B, - modifiers:{shiftKey:1}, chars:"B", unmodifiedChars:"B"}, - "B", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "B", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_B, - modifiers:{ctrlKey:1}, chars:"\u0002", unmodifiedChars:"b"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_B, - modifiers:{altKey:1}, chars:"\u222B", unmodifiedChars:"b"}, - "\u222B", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "\u222B", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_B, - modifiers:{metaKey:1}, chars:"b", unmodifiedChars:"b"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_C, - modifiers:{}, chars:"c", unmodifiedChars:"c"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_C, - modifiers:{shiftKey:1}, chars:"C", unmodifiedChars:"C"}, - "C", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "C", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_C, - modifiers:{ctrlKey:1}, chars:"\u0003", unmodifiedChars:"c"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_C, - modifiers:{altKey:1}, chars:"\u00E7", unmodifiedChars:"c"}, - "\u00E7", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "\u00E7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_C, - modifiers:{metaKey:1}, chars:"c", unmodifiedChars:"c"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_D, - modifiers:{}, chars:"d", unmodifiedChars:"d"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_D, - modifiers:{shiftKey:1}, chars:"D", unmodifiedChars:"D"}, - "D", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "D", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_D, - modifiers:{ctrlKey:1}, chars:"\u0004", unmodifiedChars:"d"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_D, - modifiers:{altKey:1}, chars:"\u2202", unmodifiedChars:"d"}, - "\u2202", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "\u2202", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_D, - modifiers:{metaKey:1}, chars:"d", unmodifiedChars:"d"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_E, - modifiers:{}, chars:"e", unmodifiedChars:"e"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_E, - modifiers:{shiftKey:1}, chars:"E", unmodifiedChars:"E"}, - "E", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_E, - modifiers:{ctrlKey:1}, chars:"\u0005", unmodifiedChars:"e"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_E, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"e"}, - "Dead", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "\u00B4", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_E, - modifiers:{metaKey:1}, chars:"e", unmodifiedChars:"e"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - modifiers:{}, chars:"f", unmodifiedChars:"f"}, - "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - modifiers:{shiftKey:1}, chars:"F", unmodifiedChars:"F"}, - "F", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "F", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - modifiers:{ctrlKey:1}, chars:"\u0006", unmodifiedChars:"f"}, - "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - modifiers:{altKey:1}, chars:"\u0192", unmodifiedChars:"f"}, - "\u0192", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "\u0192", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // XXX This test starts fullscreen mode. - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - // modifiers:{metaKey:1}, chars:"f", unmodifiedChars:"f"}, - // "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_G, - modifiers:{}, chars:"g", unmodifiedChars:"g"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_G, - modifiers:{shiftKey:1}, chars:"G", unmodifiedChars:"G"}, - "G", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "G", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_G, - modifiers:{ctrlKey:1}, chars:"\u0007", unmodifiedChars:"g"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_G, - modifiers:{altKey:1}, chars:"\u00A9", unmodifiedChars:"g"}, - "\u00A9", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "\u00A9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_G, - modifiers:{metaKey:1}, chars:"g", unmodifiedChars:"g"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_H, - modifiers:{}, chars:"h", unmodifiedChars:"h"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_H, - modifiers:{shiftKey:1}, chars:"H", unmodifiedChars:"H"}, - "H", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "H", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_H, - modifiers:{ctrlKey:1}, chars:"\u0008", unmodifiedChars:"h"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_H, - modifiers:{altKey:1}, chars:"\u02D9", unmodifiedChars:"h"}, - "\u02D9", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "\u02D9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_H, - modifiers:{metaKey:1}, chars:"h", unmodifiedChars:"h"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_I, - modifiers:{}, chars:"i", unmodifiedChars:"i"}, - "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_I, - modifiers:{shiftKey:1}, chars:"I", unmodifiedChars:"I"}, - "I", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "I", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_I, - modifiers:{ctrlKey:1}, chars:"\u0009", unmodifiedChars:"i"}, - "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_I, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"i"}, - "Dead", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "\u02C6", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - // XXX This test causes memory leak. - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_I, - // modifiers:{metaKey:1}, chars:"i", unmodifiedChars:"i"}, - // "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_J, - modifiers:{}, chars:"j", unmodifiedChars:"j"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_J, - modifiers:{shiftKey:1}, chars:"J", unmodifiedChars:"J"}, - "J", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "J", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_J, - modifiers:{ctrlKey:1}, chars:"\u000A", unmodifiedChars:"j"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_J, - modifiers:{altKey:1}, chars:"\u2206", unmodifiedChars:"j"}, - "\u2206", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "\u2206", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_J, - modifiers:{metaKey:1}, chars:"j", unmodifiedChars:"j"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_K, - modifiers:{}, chars:"k", unmodifiedChars:"k"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_K, - modifiers:{shiftKey:1}, chars:"K", unmodifiedChars:"K"}, - "K", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "K", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_K, - modifiers:{ctrlKey:1}, chars:"\u000B", unmodifiedChars:"k"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_K, - modifiers:{altKey:1}, chars:"\u02DA", unmodifiedChars:"k"}, - "\u02DA", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "\u02DA", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_K, - modifiers:{metaKey:1}, chars:"k", unmodifiedChars:"k"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_L, - modifiers:{}, chars:"l", unmodifiedChars:"l"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_L, - modifiers:{shiftKey:1}, chars:"L", unmodifiedChars:"L"}, - "L", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "L", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_L, - modifiers:{ctrlKey:1}, chars:"\u000C", unmodifiedChars:"l"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_L, - modifiers:{altKey:1}, chars:"\u00AC", unmodifiedChars:"l"}, - "\u00AC", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "\u00AC", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_L, - modifiers:{metaKey:1}, chars:"l", unmodifiedChars:"l"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_M, - modifiers:{}, chars:"m", unmodifiedChars:"m"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_M, - modifiers:{shiftKey:1}, chars:"M", unmodifiedChars:"M"}, - "M", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "M", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_M, - modifiers:{ctrlKey:1}, chars:"\u000D", unmodifiedChars:"m"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_M, - modifiers:{altKey:1}, chars:"\u00B5", unmodifiedChars:"m"}, - "\u00B5", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "\u00B5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_M, - modifiers:{metaKey:1}, chars:"m", unmodifiedChars:"m"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_N, - modifiers:{}, chars:"n", unmodifiedChars:"n"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_N, - modifiers:{shiftKey:1}, chars:"N", unmodifiedChars:"N"}, - "N", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "N", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_N, - modifiers:{ctrlKey:1}, chars:"\u000E", unmodifiedChars:"n"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_N, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"n"}, - "Dead", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "\u02DC", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_N, - modifiers:{metaKey:1}, chars:"n", unmodifiedChars:"n"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_O, - modifiers:{}, chars:"o", unmodifiedChars:"o"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_O, - modifiers:{shiftKey:1}, chars:"O", unmodifiedChars:"O"}, - "O", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "O", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_O, - modifiers:{ctrlKey:1}, chars:"\u000F", unmodifiedChars:"o"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_O, - modifiers:{altKey:1}, chars:"\u00F8", unmodifiedChars:"o"}, - "\u00F8", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "\u00F8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_O, - modifiers:{metaKey:1}, chars:"o", unmodifiedChars:"o"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_P, - modifiers:{}, chars:"p", unmodifiedChars:"p"}, - "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_P, - modifiers:{shiftKey:1}, chars:"P", unmodifiedChars:"P"}, - "P", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "P", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_P, - modifiers:{ctrlKey:1}, chars:"\u0010", unmodifiedChars:"p"}, - "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_P, - modifiers:{altKey:1}, chars:"\u03C0", unmodifiedChars:"p"}, - "\u03C0", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "\u03C0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // XXX This test starts private browsing mode (stopped at the confirmation dialog) - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_P, - // modifiers:{metaKey:1}, chars:"p", unmodifiedChars:"p"}, - // "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Q, - modifiers:{}, chars:"q", unmodifiedChars:"q"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Q, - modifiers:{shiftKey:1}, chars:"Q", unmodifiedChars:"Q"}, - "Q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Q, - modifiers:{ctrlKey:1}, chars:"\u0011", unmodifiedChars:"q"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Q, - modifiers:{altKey:1}, chars:"\u0153", unmodifiedChars:"q"}, - "\u0153", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "\u0153", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Q, - modifiers:{metaKey:1}, chars:"q", unmodifiedChars:"q"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_R, - modifiers:{}, chars:"r", unmodifiedChars:"r"}, - "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_R, - modifiers:{shiftKey:1}, chars:"R", unmodifiedChars:"R"}, - "R", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "R", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_R, - modifiers:{ctrlKey:1}, chars:"\u0012", unmodifiedChars:"r"}, - "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_R, - modifiers:{altKey:1}, chars:"\u00AE", unmodifiedChars:"r"}, - "\u00AE", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "\u00AE", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // XXX This test makes some tabs and dialogs. - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_R, - // modifiers:{metaKey:1}, chars:"r", unmodifiedChars:"r"}, - // "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_S, - modifiers:{}, chars:"s", unmodifiedChars:"s"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_S, - modifiers:{shiftKey:1}, chars:"S", unmodifiedChars:"S"}, - "S", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "S", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_S, - modifiers:{ctrlKey:1}, chars:"\u0013", unmodifiedChars:"s"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_S, - modifiers:{altKey:1}, chars:"\u00DF", unmodifiedChars:"s"}, - "\u00DF", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "\u00DF", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_S, - modifiers:{metaKey:1}, chars:"s", unmodifiedChars:"s"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{}, chars:"t", unmodifiedChars:"t"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{shiftKey:1}, chars:"T", unmodifiedChars:"T"}, - "T", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "T", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{ctrlKey:1}, chars:"\u0014", unmodifiedChars:"t"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{altKey:1}, chars:"\u2020", unmodifiedChars:"t"}, - "\u2020", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "\u2020", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{metaKey:1}, chars:"t", unmodifiedChars:"t"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_U, - modifiers:{}, chars:"u", unmodifiedChars:"u"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_U, - modifiers:{shiftKey:1}, chars:"U", unmodifiedChars:"U"}, - "U", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "U", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_U, - modifiers:{ctrlKey:1}, chars:"\u0015", unmodifiedChars:"u"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_U, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"u"}, - "Dead", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "\u00A8", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_U, - modifiers:{metaKey:1}, chars:"u", unmodifiedChars:"u"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_V, - modifiers:{}, chars:"v", unmodifiedChars:"v"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_V, - modifiers:{shiftKey:1}, chars:"V", unmodifiedChars:"V"}, - "V", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "V", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_V, - modifiers:{ctrlKey:1}, chars:"\u0016", unmodifiedChars:"v"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_V, - modifiers:{altKey:1}, chars:"\u221A", unmodifiedChars:"v"}, - "\u221A", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "\u221A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_V, - modifiers:{metaKey:1}, chars:"v", unmodifiedChars:"v"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_W, - modifiers:{}, chars:"w", unmodifiedChars:"w"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_W, - modifiers:{shiftKey:1}, chars:"W", unmodifiedChars:"W"}, - "W", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "W", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_W, - modifiers:{ctrlKey:1}, chars:"\u0017", unmodifiedChars:"w"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_W, - modifiers:{altKey:1}, chars:"\u2211", unmodifiedChars:"w"}, - "\u2211", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "\u2211", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_W, - modifiers:{metaKey:1}, chars:"w", unmodifiedChars:"w"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_X, - modifiers:{}, chars:"x", unmodifiedChars:"x"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_X, - modifiers:{shiftKey:1}, chars:"X", unmodifiedChars:"X"}, - "X", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "X", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_X, - modifiers:{ctrlKey:1}, chars:"\u0018", unmodifiedChars:"x"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_X, - modifiers:{altKey:1}, chars:"\u2248", unmodifiedChars:"x"}, - "\u2248", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "\u2248", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_X, - modifiers:{metaKey:1}, chars:"x", unmodifiedChars:"x"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Y, - modifiers:{}, chars:"y", unmodifiedChars:"y"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Y, - modifiers:{shiftKey:1}, chars:"Y", unmodifiedChars:"Y"}, - "Y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "Y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Y, - modifiers:{ctrlKey:1}, chars:"\u0019", unmodifiedChars:"y"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Y, - modifiers:{altKey:1}, chars:"\u00A5", unmodifiedChars:"y"}, - "\u00A5", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "\u00A5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Y, - modifiers:{metaKey:1}, chars:"y", unmodifiedChars:"y"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Z, - modifiers:{}, chars:"z", unmodifiedChars:"z"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Z, - modifiers:{shiftKey:1}, chars:"Z", unmodifiedChars:"Z"}, - "Z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "Z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Z, - modifiers:{ctrlKey:1}, chars:"\u001A", unmodifiedChars:"z"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Z, - modifiers:{altKey:1}, chars:"\u03A9", unmodifiedChars:"z"}, - "\u03A9", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "\u03A9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Z, - modifiers:{metaKey:1}, chars:"z", unmodifiedChars:"z"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // numeric - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_1, - modifiers:{}, chars:"1", unmodifiedChars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_1, - modifiers:{shiftKey:1}, chars:"!", unmodifiedChars:"!"}, - "!", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_1, - modifiers:{ctrlKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_1, - modifiers:{altKey:1}, chars:"\u00A1", unmodifiedChars:"1"}, - "\u00A1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "\u00A1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_1, - modifiers:{metaKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_2, - modifiers:{}, chars:"2", unmodifiedChars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_2, - modifiers:{shiftKey:1}, chars:"@", unmodifiedChars:"@"}, - "@", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "@", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_2, - modifiers:{ctrlKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_2, - modifiers:{altKey:1}, chars:"\u00A1", unmodifiedChars:"2"}, - "\u00A1", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u00A1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_2, - modifiers:{metaKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_3, - modifiers:{}, chars:"3", unmodifiedChars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_3, - modifiers:{shiftKey:1}, chars:"#", unmodifiedChars:"#"}, - "#", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_3, - modifiers:{ctrlKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_3, - modifiers:{altKey:1}, chars:"\u00A3", unmodifiedChars:"3"}, - "\u00A3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "\u00A3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_3, - modifiers:{metaKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_4, - modifiers:{}, chars:"4", unmodifiedChars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_4, - modifiers:{shiftKey:1}, chars:"$", unmodifiedChars:"$"}, - "$", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_4, - modifiers:{ctrlKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_4, - modifiers:{altKey:1}, chars:"\u00A2", unmodifiedChars:"4"}, - "\u00A2", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "\u00A2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_4, - modifiers:{metaKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_5, - modifiers:{}, chars:"5", unmodifiedChars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_5, - modifiers:{shiftKey:1}, chars:"%", unmodifiedChars:"%"}, - "%", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_5, - modifiers:{ctrlKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_5, - modifiers:{altKey:1}, chars:"\u221E", unmodifiedChars:"5"}, - "\u221E", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "\u221E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_5, - modifiers:{metaKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_6, - modifiers:{}, chars:"6", unmodifiedChars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_6, - modifiers:{shiftKey:1}, chars:"^", unmodifiedChars:"^"}, - "^", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_6, - modifiers:{ctrlKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_6, - modifiers:{altKey:1}, chars:"\u00A7", unmodifiedChars:"6"}, - "\u00A7", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_6, - modifiers:{metaKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_7, - modifiers:{}, chars:"7", unmodifiedChars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_7, - modifiers:{shiftKey:1}, chars:"&", unmodifiedChars:"&"}, - "&", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_7, - modifiers:{ctrlKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_7, - modifiers:{altKey:1}, chars:"\u00B6", unmodifiedChars:"7"}, - "\u00B6", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u00B6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_7, - modifiers:{metaKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_8, - modifiers:{}, chars:"8", unmodifiedChars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_8, - modifiers:{shiftKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_8, - modifiers:{ctrlKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_8, - modifiers:{altKey:1}, chars:"\u2022", unmodifiedChars:"8"}, - "\u2022", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "\u2022", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_8, - modifiers:{metaKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_9, - modifiers:{}, chars:"9", unmodifiedChars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_9, - modifiers:{shiftKey:1}, chars:"(", unmodifiedChars:"("}, - "(", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_9, - modifiers:{ctrlKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_9, - modifiers:{altKey:1}, chars:"\u00AA", unmodifiedChars:"9"}, - "\u00AA", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u00AA", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_9, - modifiers:{metaKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_0, - modifiers:{}, chars:"0", unmodifiedChars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_0, - modifiers:{shiftKey:1}, chars:")", unmodifiedChars:")"}, - ")", "Digit0", nsIDOMKeyEvent.DOM_VK_0, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_0, - modifiers:{ctrlKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_0, - modifiers:{altKey:1}, chars:"\u00BA", unmodifiedChars:"0"}, - "\u00BA", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u00BA", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_0, - modifiers:{metaKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // other chracters - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Grave, - modifiers:{}, chars:"`", unmodifiedChars:"`"}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Grave, - modifiers:{shiftKey:1}, chars:"~", unmodifiedChars:"~"}, - "~", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "~", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Grave, - modifiers:{ctrlKey:1}, chars:"`", unmodifiedChars:"`"}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Grave, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"`"}, - "Dead", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Grave, - modifiers:{metaKey:1}, chars:"`", unmodifiedChars:"`"}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Minus, - modifiers:{}, chars:"-", unmodifiedChars:"-"}, - "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Minus, - modifiers:{shiftKey:1}, chars:"_", unmodifiedChars:"_"}, - "_", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Minus, - // modifiers:{ctrlKey:1}, chars:"\u001F", unmodifiedChars:"-"}, - // "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Minus, - modifiers:{altKey:1}, chars:"\u2013", unmodifiedChars:"-"}, - "\u2013", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "\u2013", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Minus, - modifiers:{metaKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Equal, - modifiers:{}, chars:"=", unmodifiedChars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Equal, - modifiers:{shiftKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Equal, - modifiers:{ctrlKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Equal, - modifiers:{altKey:1}, chars:"\u2260", unmodifiedChars:"="}, - "\u2260", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "\u2260", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Equal, - modifiers:{metaKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{}, chars:"[", unmodifiedChars:"["}, - "[", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{shiftKey:1}, chars:"{", unmodifiedChars:"{"}, - "{", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "{", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_LeftBracket, - // modifiers:{ctrlKey:1}, chars:"\u001B", unmodifiedChars:"["}, - // "[", "LeftBracket", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{altKey:1}, chars:"\u201C", unmodifiedChars:"["}, - "\u201C", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "\u201C", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{metaKey:1}, chars:"[", unmodifiedChars:"["}, - "[", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_RightBracket, - modifiers:{}, chars:"]", unmodifiedChars:"]"}, - "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_RightBracket, - modifiers:{shiftKey:1}, chars:"}", unmodifiedChars:"}"}, - "}", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "}", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_RightBracket, - // modifiers:{ctrlKey:1}, chars:"\u001D", unmodifiedChars:"]"}, - // "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_RightBracket, - modifiers:{altKey:1}, chars:"\u2018", unmodifiedChars:"]"}, - "\u2018", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "\u2018", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_RightBracket, - modifiers:{metaKey:1}, chars:"]", unmodifiedChars:"]"}, - "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Backslash, - modifiers:{}, chars:"\\", unmodifiedChars:"\\"}, - "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Backslash, - modifiers:{shiftKey:1}, chars:"|", unmodifiedChars:"|"}, - "|", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Backslash, - // modifiers:{ctrlKey:1}, chars:"\u001C", unmodifiedChars:"\\"}, - // "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Backslash, - modifiers:{altKey:1}, chars:"\u00AB", unmodifiedChars:"\\"}, - "\u00AB", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\u00AB", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Backslash, - modifiers:{metaKey:1}, chars:"\\", unmodifiedChars:"\\"}, - "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{}, chars:";", unmodifiedChars:";"}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{shiftKey:1}, chars:":", unmodifiedChars:":"}, - ":", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{ctrlKey:1}, chars:";", unmodifiedChars:";"}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{altKey:1}, chars:"\u2026", unmodifiedChars:";"}, - "\u2026", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, "\u2026", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{metaKey:1}, chars:";", unmodifiedChars:";"}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{}, chars:"'", unmodifiedChars:"'"}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{shiftKey:1}, chars:"\"", unmodifiedChars:"\""}, - "\"", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{ctrlKey:1}, chars:"'", unmodifiedChars:"'"}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{altKey:1}, chars:"\u00E6", unmodifiedChars:"'"}, - "\u00E6", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "\u00E6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{metaKey:1}, chars:"'", unmodifiedChars:"'"}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Comma, - modifiers:{}, chars:",", unmodifiedChars:","}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Comma, - modifiers:{shiftKey:1}, chars:"<", unmodifiedChars:"<"}, - "<", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Comma, - modifiers:{ctrlKey:1}, chars:",", unmodifiedChars:","}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Comma, - modifiers:{altKey:1}, chars:"\u2264", unmodifiedChars:","}, - "\u2264", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, "\u2264", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Comma, - modifiers:{metaKey:1}, chars:",", unmodifiedChars:","}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{}, chars:".", unmodifiedChars:"."}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{shiftKey:1}, chars:">", unmodifiedChars:">"}, - ">", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{ctrlKey:1}, chars:".", unmodifiedChars:"."}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{altKey:1}, chars:"\u2265", unmodifiedChars:"."}, - "\u2265", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, "\u2265", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{metaKey:1}, chars:".", unmodifiedChars:"."}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Slash, - modifiers:{}, chars:"/", unmodifiedChars:"/"}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Slash, - modifiers:{shiftKey:1}, chars:"?", unmodifiedChars:"?"}, - "?", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Slash, - modifiers:{ctrlKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Slash, - modifiers:{altKey:1}, chars:"\u00F7", unmodifiedChars:"/"}, - "\u00F7", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "\u00F7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Slash, - modifiers:{metaKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // numpad - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad1, - modifiers:{numericKeyPadKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad1, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad1, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad1, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad1, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad2, - modifiers:{numericKeyPadKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad2, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad2, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad2, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad2, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad3, - modifiers:{numericKeyPadKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad3, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad3, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad3, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad3, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad4, - modifiers:{numericKeyPadKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad4, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad4, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad4, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad4, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad5, - modifiers:{numericKeyPadKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad5, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad5, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad5, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad5, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad6, - modifiers:{numericKeyPadKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad6, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad6, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad6, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad6, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad7, - modifiers:{numericKeyPadKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad7, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad7, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad7, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad7, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad8, - modifiers:{numericKeyPadKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad8, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad8, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad8, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad8, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad9, - modifiers:{numericKeyPadKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad9, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad9, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad9, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad9, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad0, - modifiers:{numericKeyPadKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad0, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad0, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad0, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Keypad0, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEquals, - modifiers:{numericKeyPadKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "NumpadEqual", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEquals, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "NumpadEqual", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEquals, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "NumpadEqual", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEquals, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "NumpadEqual", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEquals, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"=", unmodifiedChars:"="}, - "=", "NumpadEqual", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadDivide, - modifiers:{numericKeyPadKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadDivide, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadDivide, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadDivide, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadDivide, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"/", unmodifiedChars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMultiply, - modifiers:{numericKeyPadKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMultiply, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMultiply, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMultiply, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMultiply, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"*", unmodifiedChars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMinus, - modifiers:{numericKeyPadKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMinus, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMinus, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMinus, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadMinus, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"-", unmodifiedChars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadPlus, - modifiers:{numericKeyPadKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadPlus, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadPlus, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadPlus, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadPlus, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"+", unmodifiedChars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEnter, - modifiers:{numericKeyPadKey:1}, chars:"\u0003", unmodifiedChars:"\u0003"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEnter, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:"\u0003", unmodifiedChars:"\u0003"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEnter, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:"\u0003", unmodifiedChars:"\u0003"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEnter, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:"\u0003", unmodifiedChars:"\u0003"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_KeypadEnter, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:"\u0003", unmodifiedChars:"\u0003"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_JIS_KeypadComma, - modifiers:{numericKeyPadKey:1, shiftKey:1}, chars:",", unmodifiedChars:","}, - ",", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_JIS_KeypadComma, - modifiers:{numericKeyPadKey:1, ctrlKey:1}, chars:",", unmodifiedChars:","}, - ",", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_JIS_KeypadComma, - modifiers:{numericKeyPadKey:1, altKey:1}, chars:",", unmodifiedChars:","}, - ",", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_JIS_KeypadComma, - modifiers:{numericKeyPadKey:1, metaKey:1}, chars:",", unmodifiedChars:","}, - ",", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ",", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - // French, numeric - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_1, - modifiers:{}, chars:"&", unmodifiedChars:"&"}, - "&", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_1, - modifiers:{shiftKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_1, - modifiers:{ctrlKey:1}, chars:"1", unmodifiedChars:"&"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_1, - modifiers:{metaKey:1}, chars:"&", unmodifiedChars:"&"}, - "&", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "&", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_1, - modifiers:{metaKey:1, shiftKey:1}, chars:"1", unmodifiedChars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_2, - modifiers:{}, chars:"\u00E9", unmodifiedChars:"\u00E9"}, - "\u00E9", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u00E9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_2, - modifiers:{shiftKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_2, - modifiers:{ctrlKey:1}, chars:"2", unmodifiedChars:"\u00E9"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_2, - modifiers:{metaKey:1}, chars:"\u00E9", unmodifiedChars:"\u00E9"}, - "\u00E9", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u00E9", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_2, - modifiers:{metaKey:1, shiftKey:1}, chars:"2", unmodifiedChars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_3, - modifiers:{}, chars:"\"", unmodifiedChars:"\""}, - "\"", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_3, - modifiers:{shiftKey:1}, chars:"3", unmodifiedChars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_3, - modifiers:{ctrlKey:1}, chars:"3", unmodifiedChars:"\""}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_3, - modifiers:{metaKey:1}, chars:"\"", unmodifiedChars:"\""}, - "\"", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "\"", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Cmd+Shift+3 is a shortcut key of taking a snapshot - // yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_3, - // modifiers:{metaKey:1, shiftKey:1}, chars:"\"", unmodifiedChars:"\""}, - // "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_4, - modifiers:{}, chars:"'", unmodifiedChars:"'"}, - "'", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_4, - modifiers:{shiftKey:1}, chars:"4", unmodifiedChars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_4, - modifiers:{ctrlKey:1}, chars:"4", unmodifiedChars:"'"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_4, - modifiers:{metaKey:1}, chars:"'", unmodifiedChars:"'"}, - "'", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "'", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Cmd+Shift+4 is a shortcut key of taking a snapshot in specific range - // yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_4, - // modifiers:{metaKey:1, shiftKey:1}, chars:"4", unmodifiedChars:"4"}, - // "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_5, - modifiers:{}, chars:"(", unmodifiedChars:"("}, - "(", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_5, - modifiers:{shiftKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_5, - modifiers:{ctrlKey:1}, chars:"5", unmodifiedChars:"("}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_5, - modifiers:{metaKey:1}, chars:"(", unmodifiedChars:"("}, - "(", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "(", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_5, - modifiers:{metaKey:1, shiftKey:1}, chars:"5", unmodifiedChars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_6, - modifiers:{}, chars:"\u00A7", unmodifiedChars:"\u00A7"}, - "\u00A7", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_6, - modifiers:{shiftKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_6, - // modifiers:{ctrlKey:1}, chars:"\u001D", unmodifiedChars:"\u00A7"}, - // "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Ctrl+6 sets strange char - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_6, - modifiers:{metaKey:1}, chars:"\u00A7", unmodifiedChars:"\u00A7"}, - "\u00A7", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "\u00A7", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_6, - modifiers:{metaKey:1, shiftKey:1}, chars:"6", unmodifiedChars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_7, - modifiers:{}, chars:"\u00E8", unmodifiedChars:"\u00E8"}, - "\u00E8", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u00E8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_7, - modifiers:{shiftKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_7, - modifiers:{ctrlKey:1}, chars:"7", unmodifiedChars:"\u00E8"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_7, - modifiers:{metaKey:1}, chars:"\u00E8", unmodifiedChars:"\u00E8"}, - "\u00E8", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u00E8", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_7, - modifiers:{metaKey:1, shiftKey:1}, chars:"7", unmodifiedChars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_8, - modifiers:{}, chars:"!", unmodifiedChars:"!"}, - "!", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_8, - modifiers:{shiftKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_8, - modifiers:{ctrlKey:1}, chars:"8", unmodifiedChars:"!"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_8, - modifiers:{metaKey:1}, chars:"!", unmodifiedChars:"!"}, - "!", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "!", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_8, - modifiers:{metaKey:1, shiftKey:1}, chars:"8", unmodifiedChars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_9, - modifiers:{}, chars:"\u00E7", unmodifiedChars:"\u00E7"}, - "\u00E7", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u00E7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_9, - modifiers:{shiftKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // TODO: - // yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_9, - // modifiers:{ctrlKey:1}, chars:"\u001C", unmodifiedChars:"\u00E7"}, - // "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Ctrl+9 sets strange char - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_9, - modifiers:{metaKey:1}, chars:"\u00E7", unmodifiedChars:"\u00E7"}, - "\u00E7", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u00E7", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_9, - modifiers:{metaKey:1, shiftKey:1}, chars:"9", unmodifiedChars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_0, - modifiers:{}, chars:"\u00E0", unmodifiedChars:"\u00E0"}, - "\u00E0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u00E0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_0, - modifiers:{shiftKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // XXX No events fired, not sure the reason. - // yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_0, - // modifiers:{ctrlKey:1}, chars:"", unmodifiedChars:"\u00E0"}, - // "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_0, - modifiers:{metaKey:1}, chars:"\u00E0", unmodifiedChars:"\u00E0"}, - "\u00E0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u00E0", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:MAC_VK_ANSI_0, - modifiers:{metaKey:1, shiftKey:1}, chars:"0", unmodifiedChars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Thai - // keycode should be DOM_VK_[A-Z] of the key on the latest ASCII capable keyboard layout is for alphabet - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_A, - modifiers:{}, chars:"\u0E1F", unmodifiedChars:"\u0E1F"}, - "\u0E1F", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u0E1F", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // keycode should be shifted character if unshifted character isn't an ASCII character - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_Quote, - modifiers:{}, chars:"\u0E07", unmodifiedChars:"\u0E07"}, - "\u0E07", "Quote", nsIDOMKeyEvent.DOM_VK_PERIOD, "\u0E07", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // keycode should be zero if the character of the key on the latest ASCII capable keyboard layout isn't for alphabet - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_Period, - modifiers:{}, chars:"\u0E43", unmodifiedChars:"\u0E43"}, - "\u0E43", "Period", 0, "\u0E43", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // keycode should be DOM_VK_[0-9] if the key on the latest ASCII capable keyboard layout is for numeric - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_1, - modifiers:{}, chars:"\u0E45", unmodifiedChars:"\u0E45"}, - "\u0E45", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "\u0E45", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_2, - modifiers:{}, chars:"/", unmodifiedChars:"/"}, - "/", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_3, - modifiers:{}, chars:"_", unmodifiedChars:"_"}, - "_", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_4, - modifiers:{}, chars:"\u0E20", unmodifiedChars:"\u0E20"}, - "\u0E20", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "\u0E20", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_5, - modifiers:{}, chars:"\u0E16", unmodifiedChars:"\u0E16"}, - "\u0E16", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "\u0E16", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_6, - modifiers:{}, chars:"\u0E38", unmodifiedChars:"\u0E38"}, - "\u0E38", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "\u0E38", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_7, - modifiers:{}, chars:"\u0E36", unmodifiedChars:"\u0E36"}, - "\u0E36", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u0E36", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_8, - modifiers:{}, chars:"\u0E04", unmodifiedChars:"\u0E04"}, - "\u0E04", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "\u0E04", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_9, - modifiers:{}, chars:"\u0E15", unmodifiedChars:"\u0E15"}, - "\u0E15", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u0E15", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_THAI, keyCode:MAC_VK_ANSI_0, - modifiers:{}, chars:"\u0E08", unmodifiedChars:"\u0E08"}, - "\u0E08", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u0E08", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Dvorak-Qwerty, layout should be changed when Command key is pressed. - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_S, - modifiers:{}, chars:"o", unmodifiedChars:"o"}, - "o", "KeyS", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_S, - modifiers:{shiftKey:1}, chars:"O", unmodifiedChars:"O"}, - "O", "KeyS", nsIDOMKeyEvent.DOM_VK_O, "O", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_S, - modifiers:{ctrlKey:1}, chars:"\u000F", unmodifiedChars:"o"}, - "o", "KeyS", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_S, - modifiers:{altKey:1}, chars:"\u00F8", unmodifiedChars:"o"}, - "\u00F8", "KeyS", nsIDOMKeyEvent.DOM_VK_O, "\u00F8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_S, - modifiers:{metaKey:1}, chars:"s", unmodifiedChars:"o"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_D, - modifiers:{}, chars:"e", unmodifiedChars:"e"}, - "e", "KeyD", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_D, - modifiers:{shiftKey:1}, chars:"E", unmodifiedChars:"E"}, - "E", "KeyD", nsIDOMKeyEvent.DOM_VK_E, "E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_D, - modifiers:{ctrlKey:1}, chars:"\u0005", unmodifiedChars:"e"}, - "e", "KeyD", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_D, - modifiers:{altKey:1}, chars:"", unmodifiedChars:"e"}, - "Dead", "KeyD", nsIDOMKeyEvent.DOM_VK_E, "\u00B4", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // dead key - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_D, - modifiers:{metaKey:1}, chars:"d", unmodifiedChars:"e"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_I, - modifiers:{metaKey:1, altKey:1}, chars:"^", unmodifiedChars:"c"}, - "^", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "^", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_DVORAK_QWERTY, keyCode:MAC_VK_ANSI_I, - modifiers:{metaKey:1, altKey:1, shiftKey:1}, chars:"\u02C6", unmodifiedChars:"C"}, - "\u02C6", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "\u02C6", SHOULD_DELIVER_KEYDOWN_KEYPRESS, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Arabic - PC keyboard layout inputs 2 or more characters with some key. - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_G, - modifiers:{shiftKey:1}, chars:"\u0644\u0623", unmodifiedChars:"\u0644\u0623"}, - ["\u0644\u0623", "\u0644", "\u0623", "\u0644\u0623"], "KeyG", nsIDOMKeyEvent.DOM_VK_G, "\u0644\u0623", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_T, - modifiers:{shiftKey:1}, chars:"\u0644\u0625", unmodifiedChars:"\u0644\u0625"}, - ["\u0644\u0625", "\u0644", "\u0625", "\u0644\u0625"], "KeyT", nsIDOMKeyEvent.DOM_VK_T, "\u0644\u0625", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B, - modifiers:{shiftKey:1}, chars:"\u0644\u0622", unmodifiedChars:"\u0644\u0622"}, - ["\u0644\u0622", "\u0644", "\u0622", "\u0644\u0622"], "KeyB", nsIDOMKeyEvent.DOM_VK_B, "\u0644\u0622", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B, - modifiers:{}, chars:"\u0644\u0627", unmodifiedChars:"\u0644\u0627"}, - ["\u0644\u0627", "\u0644", "\u0627", "\u0644\u0627"], "KeyB", nsIDOMKeyEvent.DOM_VK_B, "\u0644\u0627", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - cleanup(); - } - - function testKeysOnWindows() - { - // On Windows, you can use Spy++ or Winspector (free) to watch window messages. - // The keyCode is given by the wParam of the last WM_KEYDOWN message. The - // chars string is given by the wParam of the WM_CHAR message. unmodifiedChars - // is not needed on Windows. - - // Shift-ctrl-alt generates no WM_CHAR, but we still get a keypress - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{altKey:1, ctrlKey:1, shiftKey:1}, chars:""}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Greek plain text - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u03b1"}, - "\u03b1", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u03b1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u0391"}, - "\u0391", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u0391", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Greek ctrl keys produce Latin charcodes - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1}, chars:"\u0001"}, - "\u03b1", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001"}, - "\u0391", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Caps Lock key event - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_CAPITAL, - modifiers:{capsLockKey:1}, chars:""}, - "CapsLock", "CapsLock", nsIDOMKeyEvent.DOM_VK_CAPS_LOCK, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_CAPITAL, - modifiers:{capsLockKey:0}, chars:""}, - "CapsLock", "CapsLock", nsIDOMKeyEvent.DOM_VK_CAPS_LOCK, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Shift keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_LSHIFT, - modifiers:{shiftKey:1}, chars:""}, - "Shift", "ShiftLeft", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RSHIFT, - modifiers:{shiftRightKey:1}, chars:""}, - "Shift", "ShiftRight", nsIDOMKeyEvent.DOM_VK_SHIFT, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Ctrl keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_LCONTROL, - modifiers:{ctrlKey:1}, chars:""}, - "Control", "ControlLeft", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RCONTROL, - modifiers:{ctrlRightKey:1}, chars:""}, - "Control", "ControlRight", nsIDOMKeyEvent.DOM_VK_CONTROL, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Alt keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_LMENU, - modifiers:{altKey:1}, chars:""}, - "Alt", "AltLeft", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RMENU, - modifiers:{altRightKey:1}, chars:""}, - "Alt", "AltRight", nsIDOMKeyEvent.DOM_VK_ALT, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // Win keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_LWIN, - modifiers:{}, chars:""}, - "OS" /* bug 1232918 */, "OSLeft", nsIDOMKeyEvent.DOM_VK_WIN, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_LEFT); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RWIN, - modifiers:{}, chars:""}, - "OS" /* bug 1232918 */, "OSRight", nsIDOMKeyEvent.DOM_VK_WIN, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_RIGHT); - - // all keys on keyboard (keyCode test) - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_BACK, - modifiers:{}, chars:"\u0008"}, - "Backspace", "Backspace", nsIDOMKeyEvent.DOM_VK_BACK_SPACE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_TAB, - modifiers:{}, chars:"\t"}, - "Tab", "Tab", nsIDOMKeyEvent.DOM_VK_TAB, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RETURN, - modifiers:{}, chars:"\r"}, - "Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PAUSE, - modifiers:{}, chars:""}, - "Pause", "Pause", nsIDOMKeyEvent.DOM_VK_PAUSE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_KANA, - modifiers:{}, chars:""}, - "Unidentified", "", nsIDOMKeyEvent.DOM_VK_KANA, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_JUNJA, - modifiers:{}, chars:""}, - "JunjaMode", "", nsIDOMKeyEvent.DOM_VK_JUNJA, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_FINAL, - modifiers:{}, chars:""}, - "FinalMode", "", nsIDOMKeyEvent.DOM_VK_FINAL, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_KANJI, - modifiers:{}, chars:""}, - "Unidentified", "", nsIDOMKeyEvent.DOM_VK_KANJI, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_ESCAPE, - modifiers:{}, chars:""}, - "Escape", "Escape", nsIDOMKeyEvent.DOM_VK_ESCAPE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_CONVERT, - modifiers:{}, chars:""}, - "Convert", "", nsIDOMKeyEvent.DOM_VK_CONVERT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NONCONVERT, - modifiers:{}, chars:""}, - "NonConvert", "", nsIDOMKeyEvent.DOM_VK_NONCONVERT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_ACCEPT, - modifiers:{}, chars:""}, - "Accept", "", nsIDOMKeyEvent.DOM_VK_ACCEPT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_MODECHANGE, - modifiers:{}, chars:""}, - "ModeChange", "", nsIDOMKeyEvent.DOM_VK_MODECHANGE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SPACE, - modifiers:{}, chars:" "}, - " ", "Space", nsIDOMKeyEvent.DOM_VK_SPACE, " ", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - // Ctrl+Space causes WM_CHAR with ' '. However, its keypress event's ctrlKey state shouldn't be false. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SPACE, - modifiers:{ctrlKey:1}, chars:" "}, - " ", "Space", nsIDOMKeyEvent.DOM_VK_SPACE, " ", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SELECT, - modifiers:{}, chars:""}, - "Select", "", nsIDOMKeyEvent.DOM_VK_SELECT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PRINT, - modifiers:{}, chars:""}, - "Unidentified", "", nsIDOMKeyEvent.DOM_VK_PRINT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_EXECUTE, - modifiers:{}, chars:""}, - "Execute", "", nsIDOMKeyEvent.DOM_VK_EXECUTE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SNAPSHOT, - modifiers:{}, chars:""}, - "PrintScreen", "PrintScreen", nsIDOMKeyEvent.DOM_VK_PRINTSCREEN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_HELP, - modifiers:{}, chars:""}, - "Help", "", nsIDOMKeyEvent.DOM_VK_HELP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SLEEP, - modifiers:{}, chars:""}, - "Standby", "", nsIDOMKeyEvent.DOM_VK_SLEEP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PRIOR, - modifiers:{}, chars:""}, - "PageUp", "PageUp", nsIDOMKeyEvent.DOM_VK_PAGE_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NEXT, - modifiers:{}, chars:""}, - "PageDown", "PageDown", nsIDOMKeyEvent.DOM_VK_PAGE_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_END, - modifiers:{}, chars:""}, - "End", "End", nsIDOMKeyEvent.DOM_VK_END, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_HOME, - modifiers:{}, chars:""}, - "Home", "Home", nsIDOMKeyEvent.DOM_VK_HOME, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_LEFT, - modifiers:{}, chars:""}, - "ArrowLeft", "ArrowLeft", nsIDOMKeyEvent.DOM_VK_LEFT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_UP, - modifiers:{}, chars:""}, - "ArrowUp", "ArrowUp", nsIDOMKeyEvent.DOM_VK_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RIGHT, - modifiers:{}, chars:""}, - "ArrowRight", "ArrowRight", nsIDOMKeyEvent.DOM_VK_RIGHT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DOWN, - modifiers:{}, chars:""}, - "ArrowDown", "ArrowDown", nsIDOMKeyEvent.DOM_VK_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_INSERT, - modifiers:{}, chars:""}, - "Insert", "Insert", nsIDOMKeyEvent.DOM_VK_INSERT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DELETE, - modifiers:{}, chars:""}, - "Delete", "Delete", nsIDOMKeyEvent.DOM_VK_DELETE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Backspace and Enter are handled with special path in mozilla::widget::NativeKey. So, let's test them with modifiers too. - // Note that when both Ctrl and Alt are pressed, they don't cause WM_(SYS)CHAR message. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_BACK, - modifiers:{ctrlKey:1}, chars:"\u007F"}, - "Backspace", "Backspace", nsIDOMKeyEvent.DOM_VK_BACK_SPACE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_BACK, - modifiers:{altKey:1}, chars:"\u0008"}, - "Backspace", "Backspace", nsIDOMKeyEvent.DOM_VK_BACK_SPACE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_BACK, - modifiers:{ctrl:1, altKey:1}, chars:""}, - "Backspace", "Backspace", nsIDOMKeyEvent.DOM_VK_BACK_SPACE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RETURN, - modifiers:{ctrlKey:1}, chars:"\n"}, - "Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RETURN, - modifiers:{altKey:1}, chars:"\r"}, - "Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_RETURN, - modifiers:{ctrl:1, altKey:1}, chars:""}, - "Enter", "Enter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Even non-printable key could be mapped as a printable key. - // Only "keyup" event cannot know if it *did* cause inputting text. - // Therefore, only "keydown" and "keypress" event's key value should be the character inputted by the key. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F4, - modifiers:{}, chars:"a"}, - ["a", "a", "F4"], "F4", nsIDOMKeyEvent.DOM_VK_F4, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Even if key message is processed by IME, when the key causes inputting text, - // keypress event(s) should be fired. - const WIN_VK_PROCESSKEY_WITH_SC_A = WIN_VK_PROCESSKEY | 0x001E0000; - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PROCESSKEY_WITH_SC_A, - modifiers:{}, chars:"a"}, - ["a", "a", "Unidentified" /* TODO: Process */], "KeyA", 0 /* TODO: 0xE5 */, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PROCESSKEY_WITH_SC_A, - modifiers:{altKey:1}, chars:"a"}, - ["a", "a", "Unidentified" /* TODO: Process */], "KeyA", 0 /* TODO: 0xE5 */, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // US - // Alphabet - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{}, chars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"A"}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1}, chars:"\u0001"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001"}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{altKey:1}, chars:"a"}, - "a", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{altKey:1, shiftKey:1}, chars:"A"}, - "A", "KeyA", nsIDOMKeyEvent.DOM_VK_A, "A", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{}, chars:"b"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{shiftKey:1}, chars:"B"}, - "B", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "B", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{ctrlKey:1}, chars:"\u0002"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0002"}, - "B", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "B", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{altKey:1}, chars:"b"}, - "b", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "b", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_B, - modifiers:{altKey:1, shiftKey:1}, chars:"B"}, - "B", "KeyB", nsIDOMKeyEvent.DOM_VK_B, "B", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{}, chars:"c"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{shiftKey:1}, chars:"C"}, - "C", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "C", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{ctrlKey:1}, chars:"\u0003"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0003"}, - "C", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "C", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{altKey:1}, chars:"c"}, - "c", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "c", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_C, - modifiers:{altKey:1, shiftKey:1}, chars:"C"}, - "C", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "C", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{}, chars:"d"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{shiftKey:1}, chars:"D"}, - "D", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "D", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{ctrlKey:1}, chars:"\u0004"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0004"}, - "D", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "D", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{altKey:1}, chars:"d"}, - "d", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "d", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_D, - modifiers:{altKey:1, shiftKey:1}, chars:"D"}, - "D", "KeyD", nsIDOMKeyEvent.DOM_VK_D, "D", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{}, chars:"e"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{shiftKey:1}, chars:"E"}, - "E", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{ctrlKey:1}, chars:"\u0005"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0005"}, - "E", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{altKey:1}, chars:"e"}, - "e", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "e", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_E, - modifiers:{altKey:1, shiftKey:1}, chars:"E"}, - "E", "KeyE", nsIDOMKeyEvent.DOM_VK_E, "E", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{}, chars:"f"}, - "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{shiftKey:1}, chars:"F"}, - "F", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "F", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{ctrlKey:1}, chars:"\u0006"}, - "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0006"}, - "F", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "F", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{altKey:1}, chars:"f"}, - "f", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "f", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{altKey:1, shiftKey:1}, chars:"F"}, - "F", "KeyF", nsIDOMKeyEvent.DOM_VK_F, "F", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{}, chars:"g"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{shiftKey:1}, chars:"G"}, - "G", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "G", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{ctrlKey:1}, chars:"\u0007"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0007"}, - "G", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "G", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{altKey:1}, chars:"g"}, - "g", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "g", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_G, - modifiers:{altKey:1, shiftKey:1}, chars:"G"}, - "G", "KeyG", nsIDOMKeyEvent.DOM_VK_G, "G", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{}, chars:"h"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{shiftKey:1}, chars:"H"}, - "H", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "H", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{ctrlKey:1}, chars:"\u0008"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0008"}, - "H", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "H", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{altKey:1}, chars:"h"}, - "h", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "h", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_H, - modifiers:{altKey:1, shiftKey:1}, chars:"H"}, - "H", "KeyH", nsIDOMKeyEvent.DOM_VK_H, "H", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{}, chars:"i"}, - "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{shiftKey:1}, chars:"I"}, - "I", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "I", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{ctrlKey:1}, chars:"\u0009"}, - "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0009"}, - "I", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "I", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{altKey:1}, chars:"i"}, - "i", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "i", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_I, - modifiers:{altKey:1, shiftKey:1}, chars:"I"}, - "I", "KeyI", nsIDOMKeyEvent.DOM_VK_I, "I", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{}, chars:"j"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{shiftKey:1}, chars:"J"}, - "J", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "J", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{ctrlKey:1}, chars:"\u000A"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000A"}, - "J", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "J", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{altKey:1}, chars:"j"}, - "j", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "j", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_J, - modifiers:{altKey:1, shiftKey:1}, chars:"J"}, - "J", "KeyJ", nsIDOMKeyEvent.DOM_VK_J, "J", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{}, chars:"k"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{shiftKey:1}, chars:"K"}, - "K", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "K", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{ctrlKey:1}, chars:"\u000B"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000B"}, - "K", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "K", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{altKey:1}, chars:"k"}, - "k", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "k", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_K, - modifiers:{altKey:1, shiftKey:1}, chars:"K"}, - "K", "KeyK", nsIDOMKeyEvent.DOM_VK_K, "K", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{}, chars:"l"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{shiftKey:1}, chars:"L"}, - "L", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "L", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{ctrlKey:1}, chars:"\u000C"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000C"}, - "L", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "L", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{altKey:1}, chars:"l"}, - "l", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "l", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_L, - modifiers:{altKey:1, shiftKey:1}, chars:"L"}, - "L", "KeyL", nsIDOMKeyEvent.DOM_VK_L, "L", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{}, chars:"m"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{shiftKey:1}, chars:"M"}, - "M", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "M", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{ctrlKey:1}, chars:"\u000D"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000D"}, - "M", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "M", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{altKey:1}, chars:"m"}, - "m", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "m", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_M, - modifiers:{altKey:1, shiftKey:1}, chars:"M"}, - "M", "KeyM", nsIDOMKeyEvent.DOM_VK_M, "M", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{}, chars:"n"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{shiftKey:1}, chars:"N"}, - "N", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "N", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{ctrlKey:1}, chars:"\u000E"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000E"}, - "N", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "N", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{altKey:1}, chars:"n"}, - "n", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "n", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_N, - modifiers:{altKey:1, shiftKey:1}, chars:"N"}, - "N", "KeyN", nsIDOMKeyEvent.DOM_VK_N, "N", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{}, chars:"o"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{shiftKey:1}, chars:"O"}, - "O", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "O", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{ctrlKey:1}, chars:"\u000F"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u000F"}, - "O", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "O", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{altKey:1}, chars:"o"}, - "o", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "o", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_O, - modifiers:{altKey:1, shiftKey:1}, chars:"O"}, - "O", "KeyO", nsIDOMKeyEvent.DOM_VK_O, "O", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{}, chars:"p"}, - "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{shiftKey:1}, chars:"P"}, - "P", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "P", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{ctrlKey:1}, chars:"\u0010"}, - "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0010"}, - "P", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "P", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{altKey:1}, chars:"p"}, - "p", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "p", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_P, - modifiers:{altKey:1, shiftKey:1}, chars:"P"}, - "P", "KeyP", nsIDOMKeyEvent.DOM_VK_P, "P", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{}, chars:"q"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{shiftKey:1}, chars:"Q"}, - "Q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{ctrlKey:1}, chars:"\u0011"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0011"}, - "Q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{altKey:1}, chars:"q"}, - "q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Q, - modifiers:{altKey:1, shiftKey:1}, chars:"Q"}, - "Q", "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{}, chars:"r"}, - "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{shiftKey:1}, chars:"R"}, - "R", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "R", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{ctrlKey:1}, chars:"\u0012"}, - "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0012"}, - "R", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "R", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{altKey:1}, chars:"r"}, - "r", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "r", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_R, - modifiers:{altKey:1, shiftKey:1}, chars:"R"}, - "R", "KeyR", nsIDOMKeyEvent.DOM_VK_R, "R", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{}, chars:"s"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{shiftKey:1}, chars:"S"}, - "S", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "S", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{ctrlKey:1}, chars:"\u0013"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0013"}, - "S", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "S", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{altKey:1}, chars:"s"}, - "s", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "s", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_S, - modifiers:{altKey:1, shiftKey:1}, chars:"S"}, - "S", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "S", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{}, chars:"t"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{shiftKey:1}, chars:"T"}, - "T", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "T", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{ctrlKey:1}, chars:"\u0014"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0014"}, - "T", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "T", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{altKey:1}, chars:"t"}, - "t", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "t", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{altKey:1, shiftKey:1}, chars:"T"}, - "T", "KeyT", nsIDOMKeyEvent.DOM_VK_T, "T", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{}, chars:"u"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{shiftKey:1}, chars:"U"}, - "U", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "U", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{ctrlKey:1}, chars:"\u0015"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0015"}, - "U", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "U", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{altKey:1}, chars:"u"}, - "u", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "u", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_U, - modifiers:{altKey:1, shiftKey:1}, chars:"U"}, - "U", "KeyU", nsIDOMKeyEvent.DOM_VK_U, "U", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{}, chars:"v"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{shiftKey:1}, chars:"V"}, - "V", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "V", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{ctrlKey:1}, chars:"\u0016"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0016"}, - "V", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "V", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{altKey:1}, chars:"v"}, - "v", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "v", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_V, - modifiers:{altKey:1, shiftKey:1}, chars:"V"}, - "V", "KeyV", nsIDOMKeyEvent.DOM_VK_V, "V", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{}, chars:"w"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{shiftKey:1}, chars:"W"}, - "W", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "W", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{ctrlKey:1}, chars:"\u0017"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0017"}, - "W", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "W", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{altKey:1}, chars:"w"}, - "w", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "w", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_W, - modifiers:{altKey:1, shiftKey:1}, chars:"W"}, - "W", "KeyW", nsIDOMKeyEvent.DOM_VK_W, "W", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{}, chars:"x"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{shiftKey:1}, chars:"X"}, - "X", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "X", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1}, chars:"\u0018"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0018"}, - "X", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "X", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{altKey:1}, chars:"x"}, - "x", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "x", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{altKey:1, shiftKey:1}, chars:"X"}, - "X", "KeyX", nsIDOMKeyEvent.DOM_VK_X, "X", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{}, chars:"y"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{shiftKey:1}, chars:"Y"}, - "Y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "Y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{ctrlKey:1}, chars:"\u0019"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0019"}, - "Y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "Y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{altKey:1}, chars:"y"}, - "y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Y, - modifiers:{altKey:1, shiftKey:1}, chars:"Y"}, - "Y", "KeyY", nsIDOMKeyEvent.DOM_VK_Y, "Y", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{}, chars:"z"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{shiftKey:1}, chars:"Z"}, - "Z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "Z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{ctrlKey:1}, chars:"\u001A"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u001A"}, - "Z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "Z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{altKey:1}, chars:"z"}, - "z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_Z, - modifiers:{altKey:1, shiftKey:1}, chars:"Z"}, - "Z", "KeyZ", nsIDOMKeyEvent.DOM_VK_Z, "Z", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Numeric - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{}, chars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{shiftKey:1}, chars:")"}, - ")", "Digit0", nsIDOMKeyEvent.DOM_VK_0, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{ctrlKey:1}, chars:""}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - ")", "Digit0", nsIDOMKeyEvent.DOM_VK_0, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{altKey:1}, chars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_0, - modifiers:{altKey:1, shiftKey:1}, chars:")"}, - ")", "Digit0", nsIDOMKeyEvent.DOM_VK_0, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{}, chars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{shiftKey:1}, chars:"!"}, - "!", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{ctrlKey:1}, chars:""}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "!", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{altKey:1}, chars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_1, - modifiers:{altKey:1, shiftKey:1}, chars:"!"}, - "!", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{}, chars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{shiftKey:1}, chars:"@"}, - "@", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "@", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{ctrlKey:1}, chars:""}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "@", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "@", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{altKey:1}, chars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_2, - modifiers:{altKey:1, shiftKey:1}, chars:"@"}, - "@", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "@", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{}, chars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{shiftKey:1}, chars:"#"}, - "#", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{ctrlKey:1}, chars:""}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "#", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{altKey:1}, chars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_3, - modifiers:{altKey:1, shiftKey:1}, chars:"#"}, - "#", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{}, chars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{shiftKey:1}, chars:"$"}, - "$", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{ctrlKey:1}, chars:""}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "$", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{altKey:1}, chars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_4, - modifiers:{altKey:1, shiftKey:1}, chars:"$"}, - "$", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{}, chars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{shiftKey:1}, chars:"%"}, - "%", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{ctrlKey:1}, chars:""}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "%", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{altKey:1}, chars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_5, - modifiers:{altKey:1, shiftKey:1}, chars:"%"}, - "%", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{}, chars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{shiftKey:1}, chars:"^"}, - "^", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{ctrlKey:1}, chars:""}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u001E"}, - "^", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{altKey:1}, chars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_6, - modifiers:{altKey:1, shiftKey:1}, chars:"^"}, - "^", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{}, chars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{shiftKey:1}, chars:"&"}, - "&", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{ctrlKey:1}, chars:""}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "&", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{altKey:1}, chars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_7, - modifiers:{altKey:1, shiftKey:1}, chars:"&"}, - "&", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{}, chars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{shiftKey:1}, chars:"*"}, - "*", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{ctrlKey:1, }, chars:""}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "*", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{altKey:1}, chars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_8, - modifiers:{altKey:1, shiftKey:1}, chars:"*"}, - "*", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{}, chars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{shiftKey:1}, chars:"("}, - "(", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{ctrlKey:1}, chars:""}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "(", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{altKey:1}, chars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_9, - modifiers:{altKey:1, shiftKey:1}, chars:"("}, - "(", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // OEM keys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{}, chars:"-"}, - "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{shiftKey:1}, chars:"_"}, - "_", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{ctrlKey:1}, chars:""}, - "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u001F"}, - "_", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{altKey:1}, chars:"-"}, - "-", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_MINUS, - modifiers:{altKey:1, shiftKey:1}, chars:"_"}, - "_", "Minus", nsIDOMKeyEvent.DOM_VK_HYPHEN_MINUS, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{}, chars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{shiftKey:1}, chars:"+"}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1}, chars:""}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{altKey:1}, chars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PLUS, - modifiers:{altKey:1, shiftKey:1}, chars:"+"}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{}, chars:"["}, - "[", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{shiftKey:1}, chars:"{"}, - "{", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "{", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{ctrlKey:1}, chars:"\u001B"}, - "[", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "{", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "{", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{altKey:1}, chars:"["}, - "[", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_4, - modifiers:{altKey:1, shiftKey:1}, chars:"{"}, - "{", "BracketLeft", nsIDOMKeyEvent.DOM_VK_OPEN_BRACKET, "{", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:"]"}, - "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:"}"}, - "}", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "}", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{ctrlKey:1}, chars:"\u001D"}, - "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "}", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "}", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{altKey:1}, chars:"]"}, - "]", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_6, - modifiers:{altKey:1, shiftKey:1}, chars:"}"}, - "}", "BracketRight", nsIDOMKeyEvent.DOM_VK_CLOSE_BRACKET, "}", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:";"}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:":"}, - ":", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{ctrlKey:1}, chars:""}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - ":", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:";"}, - ";", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:":"}, - ":", "Semicolon", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:"'"}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:"\""}, - "\"", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{ctrlKey:1}, chars:""}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "\"", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{altKey:1}, chars:"'"}, - "'", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{altKey:1, shiftKey:1}, chars:"\""}, - "\"", "Quote", nsIDOMKeyEvent.DOM_VK_QUOTE, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{}, chars:"\\"}, - "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{shiftKey:1}, chars:"|"}, - "|", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{ctrlKey:1}, chars:"\u001C"}, - "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "|", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{altKey:1}, chars:"\\"}, - "\\", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_5, - modifiers:{altKey:1, shiftKey:1}, chars:"|"}, - "|", "Backslash", nsIDOMKeyEvent.DOM_VK_BACK_SLASH, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{}, chars:","}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{shiftKey:1}, chars:"<"}, - "<", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{ctrlKey:1}, chars:""}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "<", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{altKey:1}, chars:","}, - ",", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_COMMA, - modifiers:{altKey:1, shiftKey:1}, chars:"<"}, - "<", "Comma", nsIDOMKeyEvent.DOM_VK_COMMA, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{}, chars:"."}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{shiftKey:1}, chars:">"}, - ">", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{ctrlKey:1}, chars:""}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - ">", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{altKey:1}, chars:"."}, - ".", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{altKey:1, shiftKey:1}, chars:">"}, - ">", "Period", nsIDOMKeyEvent.DOM_VK_PERIOD, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{}, chars:"/"}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{shiftKey:1}, chars:"?"}, - "?", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{ctrlKey:1}, chars:""}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "?", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{altKey:1}, chars:"/"}, - "/", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_2, - modifiers:{altKey:1, shiftKey:1}, chars:"?"}, - "?", "Slash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{}, chars:"`"}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{shiftKey:1}, chars:"~"}, - "~", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "~", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{ctrlKey:1}, chars:""}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "~", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "~", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{altKey:1}, chars:"`"}, - "`", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "`", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_3, - modifiers:{altKey:1, shiftKey:1}, chars:"~"}, - "~", "Backquote", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "~", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Numpad - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD0, - modifiers:{numLockKey:1}, chars:"0"}, - "0", "Numpad0", nsIDOMKeyEvent.DOM_VK_NUMPAD0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD1, - modifiers:{numLockKey:1}, chars:"1"}, - "1", "Numpad1", nsIDOMKeyEvent.DOM_VK_NUMPAD1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD2, - modifiers:{numLockKey:1}, chars:"2"}, - "2", "Numpad2", nsIDOMKeyEvent.DOM_VK_NUMPAD2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD3, - modifiers:{numLockKey:1}, chars:"3"}, - "3", "Numpad3", nsIDOMKeyEvent.DOM_VK_NUMPAD3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD4, - modifiers:{numLockKey:1}, chars:"4"}, - "4", "Numpad4", nsIDOMKeyEvent.DOM_VK_NUMPAD4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD5, - modifiers:{numLockKey:1}, chars:"5"}, - "5", "Numpad5", nsIDOMKeyEvent.DOM_VK_NUMPAD5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD6, - modifiers:{numLockKey:1}, chars:"6"}, - "6", "Numpad6", nsIDOMKeyEvent.DOM_VK_NUMPAD6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD7, - modifiers:{numLockKey:1}, chars:"7"}, - "7", "Numpad7", nsIDOMKeyEvent.DOM_VK_NUMPAD7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD8, - modifiers:{numLockKey:1}, chars:"8"}, - "8", "Numpad8", nsIDOMKeyEvent.DOM_VK_NUMPAD8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD9, - modifiers:{numLockKey:1}, chars:"9"}, - "9", "Numpad9", nsIDOMKeyEvent.DOM_VK_NUMPAD9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_MULTIPLY, - modifiers:{numLockKey:1}, chars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_MULTIPLY, - modifiers:{numLockKey:1, shiftKey:1}, chars:"*"}, - "*", "NumpadMultiply", nsIDOMKeyEvent.DOM_VK_MULTIPLY, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_ADD, - modifiers:{numLockKey:1}, chars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_ADD, - modifiers:{numLockKey:1, shiftKey:1}, chars:"+"}, - "+", "NumpadAdd", nsIDOMKeyEvent.DOM_VK_ADD, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - // VK_SEPARATOR is keycode for NEC's PC-98 series whose keyboard layout was - // different from current PC's keyboard layout and it cannot connect to - // current PC. Note that even if we synthesize WM_KEYDOWN with - // VK_SEPARATOR, it doesn't work on Win7. - //yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SEPARATOR, - // modifiers:{numLockKey:1}, chars:""}, - // "", "", nsIDOMKeyEvent.DOM_VK_SEPARATOR, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - //yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SEPARATOR, - // modifiers:{numLockKey:1, shiftKey:1}, chars:""}, - // "", "", nsIDOMKeyEvent.DOM_VK_SEPARATOR, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SUBTRACT, - modifiers:{numLockKey:1}, chars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_SUBTRACT, - modifiers:{numLockKey:1, shiftKey:1}, chars:"-"}, - "-", "NumpadSubtract", nsIDOMKeyEvent.DOM_VK_SUBTRACT, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DECIMAL, - modifiers:{numLockKey:1}, chars:"."}, - ".", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DECIMAL, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DECIMAL, - modifiers:{numLockKey:1, shiftKey:1}, chars:"."}, - ".", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DECIMAL, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DIVIDE, - modifiers:{numLockKey:1}, chars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_DIVIDE, - modifiers:{numLockKey:1, shiftKey:1}, chars:"/"}, - "/", "NumpadDivide", nsIDOMKeyEvent.DOM_VK_DIVIDE, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_RETURN, - modifiers:{numLockKey:1}, chars:"\r"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_RETURN, - modifiers:{numLockKey:1, shiftKey:1}, chars:"\r"}, - "Enter", "NumpadEnter", nsIDOMKeyEvent.DOM_VK_RETURN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - // Numpad without NumLock - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_PRIOR, - modifiers:{}, chars:""}, - "PageUp", "Numpad9", nsIDOMKeyEvent.DOM_VK_PAGE_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_NEXT, - modifiers:{}, chars:""}, - "PageDown", "Numpad3", nsIDOMKeyEvent.DOM_VK_PAGE_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_END, - modifiers:{}, chars:""}, - "End", "Numpad1", nsIDOMKeyEvent.DOM_VK_END, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_HOME, - modifiers:{}, chars:""}, - "Home", "Numpad7", nsIDOMKeyEvent.DOM_VK_HOME, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_LEFT, - modifiers:{}, chars:""}, - "ArrowLeft", "Numpad4", nsIDOMKeyEvent.DOM_VK_LEFT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_UP, - modifiers:{}, chars:""}, - "ArrowUp", "Numpad8", nsIDOMKeyEvent.DOM_VK_UP, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_RIGHT, - modifiers:{}, chars:""}, - "ArrowRight", "Numpad6", nsIDOMKeyEvent.DOM_VK_RIGHT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_DOWN, - modifiers:{}, chars:""}, - "ArrowDown", "Numpad2", nsIDOMKeyEvent.DOM_VK_DOWN, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_INSERT, - modifiers:{}, chars:""}, - "Insert", "Numpad0", nsIDOMKeyEvent.DOM_VK_INSERT, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_NUMPAD_DELETE, - modifiers:{}, chars:""}, - "Delete", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DELETE, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_CLEAR, - modifiers:{}, chars:""}, - "Clear", "Numpad5", nsIDOMKeyEvent.DOM_VK_CLEAR, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - // Even if widget receives unknown keycode, it should dispatch key events - // whose keycode is 0 rather than native keycode. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:0x3A, - modifiers:{numLockKey:1}, chars:""}, - "Unidentified", "", 0, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // French - // Numeric - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_0, - modifiers:{}, chars:"\u00E0"}, - "\u00E0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u00E0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_0, - modifiers:{shiftKey:1}, chars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_1, - modifiers:{}, chars:"&"}, - "&", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_1, - modifiers:{shiftKey:1}, chars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_2, - modifiers:{}, chars:"\u00E9"}, - "\u00E9", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u00E9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_2, - modifiers:{shiftKey:1}, chars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_3, - modifiers:{}, chars:"\""}, - "\"", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_3, - modifiers:{shiftKey:1}, chars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_4, - modifiers:{}, chars:"'"}, - "'", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_4, - modifiers:{shiftKey:1}, chars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_5, - modifiers:{}, chars:"("}, - "(", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_5, - modifiers:{shiftKey:1}, chars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_6, - modifiers:{}, chars:"-"}, - "-", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_6, - modifiers:{shiftKey:1}, chars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_7, - modifiers:{}, chars:"\u00E8"}, - "\u00E8", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u00E8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_7, - modifiers:{shiftKey:1}, chars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_8, - modifiers:{}, chars:"_"}, - "_", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_8, - modifiers:{shiftKey:1}, chars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_9, - modifiers:{}, chars:"\u00E7"}, - "\u00E7", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u00E7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_9, - modifiers:{shiftKey:1}, chars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Numeric with ShiftLock - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_0, - modifiers:{capsLockKey:1}, chars:"0"}, - "0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_0, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\u00E0"}, - "\u00E0", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "\u00E0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_1, - modifiers:{capsLockKey:1}, chars:"1"}, - "1", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_1, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"&"}, - "&", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_2, - modifiers:{capsLockKey:1}, chars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_2, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\u00E9"}, - "\u00E9", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u00E9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_3, - modifiers:{capsLockKey:1}, chars:"3"}, - "3", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_3, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\""}, - "\"", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "\"", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_4, - modifiers:{capsLockKey:1}, chars:"4"}, - "4", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_4, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"'"}, - "'", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_5, - modifiers:{capsLockKey:1}, chars:"5"}, - "5", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_5, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"("}, - "(", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "(", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_6, - modifiers:{capsLockKey:1}, chars:"6"}, - "6", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "6", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_6, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"-"}, - "-", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "-", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_7, - modifiers:{capsLockKey:1}, chars:"7"}, - "7", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_7, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\u00E8"}, - "\u00E8", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "\u00E8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_8, - modifiers:{capsLockKey:1}, chars:"8"}, - "8", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_8, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"_"}, - "_", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "_", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_9, - modifiers:{capsLockKey:1}, chars:"9"}, - "9", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_9, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\u00E7"}, - "\u00E7", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "\u00E7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // OEM keys - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:"\u00B2"}, - "\u00B2", "Backquote", 0, "\u00B2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:""}, - "", "Backquote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_4, - modifiers:{}, chars:")"}, - ")", "Minus", nsIDOMKeyEvent.DOM_VK_CLOSE_PAREN, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_4, - modifiers:{shiftKey:1}, chars:"\u00B0"}, - "\u00B0", "Minus", nsIDOMKeyEvent.DOM_VK_CLOSE_PAREN, "\u00B0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{}, chars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{shiftKey:1}, chars:"+"}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - // modifiers:{}, chars:""}, - // "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - // modifiers:{shiftKey:1}, chars:""}, - // ["^^", "^", "^", "^"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:"$"}, - "$", "BracketRight", nsIDOMKeyEvent.DOM_VK_DOLLAR, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:"\u00A3"}, - "\u00A3", "BracketRight", nsIDOMKeyEvent.DOM_VK_DOLLAR, "\u00A3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_3, - modifiers:{}, chars:"\u00F9"}, - "\u00F9", "Quote", nsIDOMKeyEvent.DOM_VK_PERCENT, "\u00F9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_3, - modifiers:{shiftKey:1}, chars:"%"}, - "%", "Quote", nsIDOMKeyEvent.DOM_VK_PERCENT, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_5, - modifiers:{}, chars:"*"}, - "*", "Backslash", nsIDOMKeyEvent.DOM_VK_ASTERISK, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_5, - modifiers:{shiftKey:1}, chars:"\u00B5"}, - "\u00B5", "Backslash", nsIDOMKeyEvent.DOM_VK_ASTERISK, "\u00B5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_102, - modifiers:{}, chars:"<"}, - "<", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_LESS_THAN, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_102, - modifiers:{shiftKey:1}, chars:">"}, - ">", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_LESS_THAN, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_COMMA, - modifiers:{}, chars:","}, - ",", "KeyM", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_COMMA, - modifiers:{shiftKey:1}, chars:"?"}, - "?", "KeyM", nsIDOMKeyEvent.DOM_VK_COMMA, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{}, chars:";"}, - ";", "Comma", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{shiftKey:1}, chars:"."}, - ".", "Comma", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_2, - modifiers:{}, chars:":"}, - ":", "Period", nsIDOMKeyEvent.DOM_VK_COLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_2, - modifiers:{shiftKey:1}, chars:"/"}, - "/", "Period", nsIDOMKeyEvent.DOM_VK_COLON, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_8, - modifiers:{}, chars:"!"}, - "!", "Slash", nsIDOMKeyEvent.DOM_VK_EXCLAMATION, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_8, - modifiers:{shiftKey:1}, chars:"\u00A7"}, - "\u00A7", "Slash", nsIDOMKeyEvent.DOM_VK_EXCLAMATION, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // OEM keys with ShiftLock - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_7, - modifiers:{capsLockKey:1}, chars:"\u00B2"}, - "\u00B2", "Backquote", 0, "\u00B2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_7, - modifiers:{capsLockKey:1, shiftKey:1}, chars:""}, - "", "Backquote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_4, - modifiers:{capsLockKey:1}, chars:"\u00B0"}, - "\u00B0", "Minus", nsIDOMKeyEvent.DOM_VK_CLOSE_PAREN, "\u00B0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_4, - modifiers:{capsLockKey:1, shiftKey:1}, chars:")"}, - ")", "Minus", nsIDOMKeyEvent.DOM_VK_CLOSE_PAREN, ")", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{capsLockKey:1}, chars:"+"}, - "+", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "+", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"="}, - "=", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "=", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - // modifiers:{capsLockKey:1}, chars:""}, - // "Dead", "BracketLeft", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - // modifiers:{capsLockKey:1, shiftKey:1}, chars:""}, - // ["\u00A8\u00A8", "\u00A8", "\u00A8", "\u00A8"], "BracketLeft", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_1, - modifiers:{capsLockKey:1}, chars:"\u00A3"}, - "\u00A3", "BracketRight", nsIDOMKeyEvent.DOM_VK_DOLLAR, "\u00A3", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_1, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"$"}, - "$", "BracketRight", nsIDOMKeyEvent.DOM_VK_DOLLAR, "$", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_3, - modifiers:{capsLockKey:1}, chars:"%"}, - "%", "Quote", nsIDOMKeyEvent.DOM_VK_PERCENT, "%", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_3, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"\u00F9"}, - "\u00F9", "Quote", nsIDOMKeyEvent.DOM_VK_PERCENT, "\u00F9", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_5, - modifiers:{capsLockKey:1}, chars:"\u00B5"}, - "\u00B5", "Backslash", nsIDOMKeyEvent.DOM_VK_ASTERISK, "\u00B5", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_5, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"*"}, - "*", "Backslash", nsIDOMKeyEvent.DOM_VK_ASTERISK, "*", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_102, - modifiers:{capsLockKey:1}, chars:"<"}, - "<", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_LESS_THAN, "<", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_102, - modifiers:{capsLockKey:1, shiftKey:1}, chars:">"}, - ">", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_LESS_THAN, ">", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_COMMA, - modifiers:{capsLockKey:1}, chars:"?"}, - "?", "KeyM", nsIDOMKeyEvent.DOM_VK_COMMA, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_COMMA, - modifiers:{capsLockKey:1, shiftKey:1}, chars:","}, - ",", "KeyM", nsIDOMKeyEvent.DOM_VK_COMMA, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{capsLockKey:1}, chars:"."}, - ".", "Comma", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{capsLockKey:1, shiftKey:1}, chars:";"}, - ";", "Comma", nsIDOMKeyEvent.DOM_VK_SEMICOLON, ";", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_2, - modifiers:{capsLockKey:1}, chars:"/"}, - "/", "Period", nsIDOMKeyEvent.DOM_VK_COLON, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_2, - modifiers:{capsLockKey:1, shiftKey:1}, chars:":"}, - ":", "Period", nsIDOMKeyEvent.DOM_VK_COLON, ":", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_8, - modifiers:{capsLockKey:1}, chars:"\u00A7"}, - "\u00A7", "Slash", nsIDOMKeyEvent.DOM_VK_EXCLAMATION, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_8, - modifiers:{capsLockKey:1, shiftKey:1}, chars:"!"}, - "!", "Slash", nsIDOMKeyEvent.DOM_VK_EXCLAMATION, "!", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // AltGr - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_0, - modifiers:{altGrKey:1}, chars:"@"}, - "@", "Digit0", nsIDOMKeyEvent.DOM_VK_0, "@", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_1, - modifiers:{altGrKey:1}, chars:""}, - "&", "Digit1", nsIDOMKeyEvent.DOM_VK_1, "&", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_2, - // modifiers:{altGrKey:1}, chars:""}, - // "Dead", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_3, - modifiers:{altGrKey:1}, chars:"#"}, - "#", "Digit3", nsIDOMKeyEvent.DOM_VK_3, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_4, - modifiers:{altGrKey:1}, chars:"{"}, - "{", "Digit4", nsIDOMKeyEvent.DOM_VK_4, "{", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_5, - modifiers:{altGrKey:1}, chars:"["}, - "[", "Digit5", nsIDOMKeyEvent.DOM_VK_5, "[", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_6, - modifiers:{altGrKey:1}, chars:"|"}, - "|", "Digit6", nsIDOMKeyEvent.DOM_VK_6, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - //yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_7, - // modifiers:{altGrKey:1}, chars:""}, - // "Dead", "Digit7", nsIDOMKeyEvent.DOM_VK_7, "", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); // Dead-key - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_8, - modifiers:{altGrKey:1}, chars:"\\"}, - "\\", "Digit8", nsIDOMKeyEvent.DOM_VK_8, "\\", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_9, - modifiers:{altGrKey:1}, chars:"^"}, - "^", "Digit9", nsIDOMKeyEvent.DOM_VK_9, "^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_4, - modifiers:{altGrKey:1}, chars:"]"}, - "]", "Minus", nsIDOMKeyEvent.DOM_VK_CLOSE_PAREN, "]", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{altGrKey:1}, chars:"}"}, - "}", "Equal", nsIDOMKeyEvent.DOM_VK_EQUALS, "}", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // German - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:WIN_VK_OEM_2, - modifiers:{}, chars:"#"}, - "#", "Backslash", nsIDOMKeyEvent.DOM_VK_HASH, "#", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:WIN_VK_OEM_2, - modifiers:{shiftKey:1}, chars:"'"}, - "'", "Backslash", nsIDOMKeyEvent.DOM_VK_HASH, "'", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Khmer - if (OS_VERSION >= WIN7) { - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{}, chars:"\u17E2"}, - "\u17E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{shiftKey:1}, chars:"\u17D7"}, - "\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, // Ctrl+2 should cause inputting Euro sign. - modifiers:{ctrlKey:1}, chars:"\u20AC", isInputtingCharacters:true}, - "\u20AC", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u20AC", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, // Ctrl+Shift+2 shouldn't cause any input. - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{altKey:1}, chars:"\u17E2"}, - "\u17E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{altKey:1, shiftKey:1}, chars:"\u17D7"}, - "\u17D7", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u17D7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{altGrKey:1}, chars:"2"}, - "2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_KHMER, keyCode:WIN_VK_2, - modifiers:{altGrKey:1, shiftKey:1}, chars:"\u19E2"}, - "\u19E2", "Digit2", nsIDOMKeyEvent.DOM_VK_2, "\u19E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - } - - // Norwegian - yield testKey({layout:KEYBOARD_LAYOUT_NORWEGIAN, keyCode:WIN_VK_OEM_5, - modifiers:{}, chars:"|"}, - "|", "Backquote", nsIDOMKeyEvent.DOM_VK_PIPE, "|", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_NORWEGIAN, keyCode:WIN_VK_OEM_5, - modifiers:{shiftKey:1}, chars:"\u00A7"}, - "\u00A7", "Backquote", nsIDOMKeyEvent.DOM_VK_PIPE, "\u00A7", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - // Brazilian ABNT - yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C1, - modifiers:{}, chars:"/"}, - "/", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_SLASH, "/", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C1, - modifiers:{shiftKey:1}, chars:"?"}, - "?", "IntlBackslash", nsIDOMKeyEvent.DOM_VK_SLASH, "?", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_ABNT_C2, - modifiers:{numLockKey:1}, chars:"."}, - ".", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_BRAZILIAN_ABNT, keyCode:WIN_VK_DECIMAL, - modifiers:{numLockKey:1}, chars:","}, - ",", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DECIMAL, ",", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - // Mac JIS keyboard - // The separator key on JIS keyboard for Mac doesn't cause any character even with Japanese keyboard layout. - yield testKey({layout:KEYBOARD_LAYOUT_JAPANESE, keyCode:WIN_VK_ABNT_C2, - modifiers:{numLockKey:1}, chars:""}, - "", "NumpadComma", nsIDOMKeyEvent.DOM_VK_SEPARATOR, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - yield testKey({layout:KEYBOARD_LAYOUT_JAPANESE, keyCode:WIN_VK_DECIMAL, - modifiers:{numLockKey:1}, chars:"."}, - ".", "NumpadDecimal", nsIDOMKeyEvent.DOM_VK_DECIMAL, ".", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_NUMPAD); - - // Dead keys on any layouts - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:"^^"}, - ["^^", "^", "^", "^"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "^^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E2"}, - ["\u00E2", "\u00E2", "a"], "KeyQ", nsIDOMKeyEvent.DOM_VK_A, "\u00E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C2"}, - ["\u00C2", "\u00C2", "A"], "KeyQ", nsIDOMKeyEvent.DOM_VK_A, "\u00C2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_Q, - modifiers:{}, chars:"^q"}, - ["^q", "^", "q", "q"], "KeyA", nsIDOMKeyEvent.DOM_VK_Q, "^q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:"\u00A8\u00A8"}, - ["\u00A8\u00A8", "\u00A8", "\u00A8", "\u00A8"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "\u00A8\u00A8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C4"}, - ["\u00C4", "\u00C4", "A"], "KeyQ", nsIDOMKeyEvent.DOM_VK_A, "\u00C4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E4"}, - ["\u00E4", "\u00E4", "a"], "KeyQ", nsIDOMKeyEvent.DOM_VK_A, "\u00E4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_OEM_6, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_CIRCUMFLEX, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_FRENCH, keyCode:WIN_VK_Q, - modifiers:{shiftKey:1}, chars:"\u00A8Q"}, - ["\u00A8Q", "\u00A8", "Q", "Q"], "KeyA", nsIDOMKeyEvent.DOM_VK_Q, "\u00A8Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:"``"}, - ["``", "`", "`", "`"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "``", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E0"}, - ["\u00E0", "\u00E0", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C0"}, - ["\u00C0", "\u00C0", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{}, chars:"`q"}, - ["`q", "`", "q", "q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "`q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:"^^"}, - ["^^", "^", "^", "^"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "^^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C2"}, - ["\u00C2", "\u00C2", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E2"}, - ["\u00E2", "\u00E2", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{shiftKey:1}, chars:"^Q"}, - ["^Q", "^", "Q", "Q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "^Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:"\u00B4\u00B4"}, - ["\u00B4\u00B4", "\u00B4", "\u00B4", "\u00B4"], "Quote", 0, "\u00B4\u00B4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E1"}, - ["\u00E1", "\u00E1", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C1"}, - ["\u00C1", "\u00C1", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C1", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{}, chars:"\u00B4q"}, - ["\u00B4q", "\u00B4", "q", "q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "\u00B4q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:"\u00A8\u00A8"}, - ["\u00A8\u00A8", "\u00A8", "\u00A8", "\u00A8"], "Quote", 0, "\u00A8\u00A8", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"\u00C4"}, - ["\u00C4", "\u00C4", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{}, chars:"\u00E4"}, - ["\u00E4", "\u00E4", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E4", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_7, - modifiers:{shiftKey:1}, chars:""}, - "Dead", "Quote", 0, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{shiftKey:1}, chars:"\u00A8Q"}, - ["\u00A8Q", "\u00A8", "Q", "Q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "\u00A8Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - if (OS_VERSION >= WIN8) { - // On Russian Mnemonic layout, both 'KeyS' and 'KeyC' are dead key. However, the sequence 'KeyS' -> 'KeyC' causes a composite character. - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S, - modifiers:{}, chars:""}, - "Dead", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S, - modifiers:{}, chars:"\u0441\u0441"}, - ["\u0441\u0441", "\u0441", "\u0441", "\u0441"], "KeyS", nsIDOMKeyEvent.DOM_VK_S, "\u0441\u0441", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C, - modifiers:{}, chars:""}, - "Dead", "KeyC", nsIDOMKeyEvent.DOM_VK_C, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C, - modifiers:{}, chars:"\u0446\u0446"}, - ["\u0446\u0446", "\u0446", "\u0446", "\u0446"], "KeyC", nsIDOMKeyEvent.DOM_VK_C, "\u0446\u0446", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_S, - modifiers:{}, chars:""}, - "Dead", "KeyS", nsIDOMKeyEvent.DOM_VK_S, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC, keyCode:WIN_VK_C, - modifiers:{}, chars:"\u0449"}, - ["\u0449", "\u0449", "\u0446"], "KeyC", nsIDOMKeyEvent.DOM_VK_C, "\u0449", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - } - - // When Alt key is pressed, dead key sequence is generated with WM_SYSKEYDOWN, WM_SYSDEADCHAR, WM_SYSCHAR and WM_SYSKEYUP. - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:"``"}, - ["``", "`", "`", "`"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "``", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{altKey:1}, chars:"\u00E0"}, - ["\u00E0", "\u00E0", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{altKey:1, shiftKey:1}, chars:"\u00C0"}, - ["\u00C0", "\u00C0", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C0", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{altKey:1}, chars:"`q"}, - ["`q", "`", "q", "q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "`q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:"^^"}, - ["^^", "^", "^", "^"], "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "^^", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{altKey:1, shiftKey:1}, chars:"\u00C2"}, - ["\u00C2", "\u00C2", "A"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00C2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_A, - modifiers:{altKey:1}, chars:"\u00E2"}, - ["\u00E2", "\u00E2", "a"], "KeyA", nsIDOMKeyEvent.DOM_VK_A, "\u00E2", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_OEM_1, - modifiers:{altKey:1, shiftKey:1}, chars:""}, - "Dead", "BracketLeft", nsIDOMKeyEvent.DOM_VK_BACK_QUOTE, "", SHOULD_DELIVER_KEYDOWN_KEYUP, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - yield testKey({layout:KEYBOARD_LAYOUT_SPANISH, keyCode:WIN_VK_Q, - modifiers:{altKey:1, shiftKey:1}, chars:"^Q"}, - ["^Q", "^", "Q", "Q"], "KeyQ", nsIDOMKeyEvent.DOM_VK_Q, "^Q", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD); - - cleanup(); - } - - - if (IS_WIN) { - yield* testKeysOnWindows(); - } else if (IS_MAC) { - yield* testKeysOnMac(); - } else { - cleanup(); - } -} - -// Test the activation (or not) of an HTML accesskey -function* runAccessKeyTests() -{ - var button = document.getElementById("button"); - var activationCount; - - function onClick(e) - { - ++activationCount; - } - - // The first parameter is the complete input event. The second and third parameters are - // what to test against. - function testKey(aEvent, aAccessKey, aShouldActivate) - { - activationCount = 0; - button.setAttribute("accesskey", aAccessKey); - - return synthesizeKey(aEvent, "button", function() { - - var name = eventToString(aEvent); - - is(activationCount, aShouldActivate ? 1 : 0, name + ", activating '" + aAccessKey + "'"); - - continueTest(); - }); - } - - button.addEventListener("click", onClick, false); - - // These tests have to be per-plaform. - if (IS_MAC) { - // Basic sanity checks - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{}, chars:"a", unmodifiedChars:"a"}, - "a", false); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "a", false); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "A", false); - - // Shift-ctrl does not activate accesskeys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001", unmodifiedChars:"A"}, - "a", false); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0001", unmodifiedChars:"A"}, - "A", false); - // Alt-ctrl activate accesskeys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "a", true); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"a"}, - "A", true); - - // Greek layout can activate a Latin accesskey - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "a", true); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "A", true); - // ... and a Greek accesskey! - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "\u03b1", true); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0001", unmodifiedChars:"\u03b1"}, - "\u0391", true); - - // bug 359638 - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Period, - modifiers:{ctrlKey:1, altKey:1}, chars:".", unmodifiedChars:"."}, - ".", true); - - // German (KCHR/KeyTranslate case) - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"a", unmodifiedChars:"a"}, - "a", true); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_A, - modifiers:{ctrlKey:1, altKey:1}, chars:"a", unmodifiedChars:"a"}, - "A", true); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u00fc", unmodifiedChars:"\u00fc"}, - "\u00fc", true); - yield testKey({layout:KEYBOARD_LAYOUT_GERMAN, keyCode:MAC_VK_ANSI_LeftBracket, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u00fc", unmodifiedChars:"\u00fc"}, - "\u00dc", true); - } - else if (IS_WIN) { - // Basic sanity checks - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{}, chars:"a"}, - "a", false); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"A"}, - "a", true); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"A"}, - "A", true); - - // shift-alt-ctrl does not activate accesskeys - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1, shiftKey:1, altKey:1}, chars:""}, - "a", false); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1, shiftKey:1, altKey:1}, chars:""}, - "A", false); - - // Greek layout can activate a Latin accesskey - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"\u0391"}, - "a", true); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"\u0391"}, - "A", true); - // ... and a Greek accesskey! - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"\u0391"}, - "\u03b1", true); - yield testKey({layout:KEYBOARD_LAYOUT_GREEK, keyCode:WIN_VK_A, - modifiers:{shiftKey:1, altKey:1}, chars:"\u0391"}, - "\u0391", true); - - // bug 359638 - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_PERIOD, - modifiers:{shiftKey:1, altKey:1}, chars:".", unmodifiedChars:"."}, - ".", true); - } - - button.removeEventListener("click", onClick, false); -} - -function* runXULKeyTests() -{ - var commandElements = { - expectedCommand: document.getElementById("expectedCommand"), - unexpectedCommand: document.getElementById("unexpectedCommand"), - expectedReservedCommand: document.getElementById("expectedReservedCommand") - }; - // Enable all command elements. - for (var id in commandElements) { - commandElements[id].removeAttribute("disabled"); - } - - var keyEvents = []; - - function onKeyInDefaultEventGroup(aDOMEvent) - { - if (isModifierKeyEvent(aDOMEvent)) { - return; - } - keyEvents.push({ type: aDOMEvent.type, group: "default", phase: getPhase(aDOMEvent), currentTarget: eventTargetToString(aDOMEvent.currentTarget) }); - } - - function onKeyInSystemEventGroup(aDOMEvent) - { - if (isModifierKeyEvent(aDOMEvent)) { - return; - } - keyEvents.push({ type: aDOMEvent.type, group: "system", phase: getPhase(aDOMEvent), currentTarget: eventTargetToString(aDOMEvent.currentTarget) }); - } - - var buttonParent = document.getElementById("button").parentNode; - buttonParent.addEventListener("keydown", onKeyInDefaultEventGroup, true); - buttonParent.addEventListener("keypress", onKeyInDefaultEventGroup, true); - buttonParent.addEventListener("keydown", onKeyInDefaultEventGroup, false); - buttonParent.addEventListener("keypress", onKeyInDefaultEventGroup, false); - SpecialPowers.addSystemEventListener(buttonParent, "keydown", onKeyInSystemEventGroup, true); - SpecialPowers.addSystemEventListener(buttonParent, "keypress", onKeyInSystemEventGroup, true); - SpecialPowers.addSystemEventListener(buttonParent, "keydown", onKeyInSystemEventGroup, false); - SpecialPowers.addSystemEventListener(buttonParent, "keypress", onKeyInSystemEventGroup, false); - - function finializeKeyElementTest() - { - buttonParent.removeEventListener("keydown", onKeyInDefaultEventGroup, true); - buttonParent.removeEventListener("keypress", onKeyInDefaultEventGroup, true); - buttonParent.removeEventListener("keydown", onKeyInDefaultEventGroup, false); - buttonParent.removeEventListener("keypress", onKeyInDefaultEventGroup, false); - SpecialPowers.removeSystemEventListener(buttonParent, "keydown", onKeyInSystemEventGroup, true); - SpecialPowers.removeSystemEventListener(buttonParent, "keypress", onKeyInSystemEventGroup, true); - SpecialPowers.removeSystemEventListener(buttonParent, "keydown", onKeyInSystemEventGroup, false); - SpecialPowers.removeSystemEventListener(buttonParent, "keypress", onKeyInSystemEventGroup, false); - } - - // If aKeyElement is empty string, this function tests if the event kicks - // no key elements. - function testKeyElement(aEvent, aKeyElementId) - { - var testName = "testKeyElement (with non-reserved command element): " + eventToString(aEvent) + " "; - var keyElement = aKeyElementId == "" ? null : document.getElementById(aKeyElementId); - if (keyElement) { - keyElement.setAttribute("command", "expectedCommand"); - } - - for (var id in commandElements) { - commandElements[id].activeCount = 0; - } - - keyEvents = []; - return synthesizeKey(aEvent, "button", function() { - if (keyElement) { - is(commandElements["expectedCommand"].activeCount, 1, testName + "the command element (id='expectedCommand') should be preformed"); - } else { - is(commandElements["expectedCommand"].activeCount, 0, testName + "the command element (id='expectedCommand') shouldn't be preformed"); - } - is(commandElements["unexpectedCommand"].activeCount, 0, testName + "the command element (id='unexpectedCommand') shouldn't be preformed"); - is(commandElements["expectedReservedCommand"].activeCount, 0, testName + "the command element (id='expectedReservedCommand') shouldn't be preformed"); - - function checkFiredEvents() - { - is(keyEvents.length, 8, testName + "wrong number events fired"); - is(JSON.stringify(keyEvents[0]), JSON.stringify({ type: "keydown", group: "default", phase: "capture", currentTarget: eventTargetToString(buttonParent) }), testName + "keydown event should be fired on chrome in the default event group #0"); - is(JSON.stringify(keyEvents[1]), JSON.stringify({ type: "keydown", group: "default", phase: "bubble", currentTarget: eventTargetToString(buttonParent) }), testName + "keydown event should be fired on chrome in the default event group #1"); - - is(JSON.stringify(keyEvents[2]), JSON.stringify({ type: "keydown", group: "system", phase: "capture", currentTarget: eventTargetToString(buttonParent) }), testName + "keydown event should be fired on chrome in the system event group #2"); - is(JSON.stringify(keyEvents[3]), JSON.stringify({ type: "keydown", group: "system", phase: "bubble", currentTarget: eventTargetToString(buttonParent) }), testName + "keydown event should be fired on chrome in the system event group #3"); - - is(JSON.stringify(keyEvents[4]), JSON.stringify({ type: "keypress", group: "default", phase: "capture", currentTarget: eventTargetToString(buttonParent) }), testName + "keypress event should be fired on chrome in the default event group #4"); - is(JSON.stringify(keyEvents[5]), JSON.stringify({ type: "keypress", group: "default", phase: "bubble", currentTarget: eventTargetToString(buttonParent) }), testName + "keypress event should be fired on chrome in the default event group #5"); - - is(JSON.stringify(keyEvents[6]), JSON.stringify({ type: "keypress", group: "system", phase: "capture", currentTarget: eventTargetToString(buttonParent) }), testName + "keypress event should be fired on chrome in the system event group #6"); - is(JSON.stringify(keyEvents[7]), JSON.stringify({ type: "keypress", group: "system", phase: "bubble", currentTarget: eventTargetToString(buttonParent) }), testName + "keypress event should be fired on chrome in the system event group #7"); - } - - checkFiredEvents(); - - if (keyElement) { - testName = "testKeyElement (with reserved command element): " + eventToString(aEvent) + " "; - keyElement.setAttribute("command", "expectedReservedCommand"); - - for (id in commandElements) { - commandElements[id].activeCount = 0; - } - keyEvents = []; - synthesizeKey(aEvent, "button", function() { - is(commandElements["expectedCommand"].activeCount, 0, testName + "the command element (id='expectedCommand') shouldn't be preformed"); - is(commandElements["unexpectedCommand"].activeCount, 0, testName + "the command element (id='unexpectedCommand') shouldn't be preformed"); - is(commandElements["expectedReservedCommand"].activeCount, 1, testName + "the command element (id='expectedReservedCommand') should be preformed"); - - checkFiredEvents(); - - if (keyElement) { - keyElement.setAttribute("command", "unexpectedCommand"); - } - continueTest(); - }); - } else { - if (keyElement) { - keyElement.setAttribute("command", "unexpectedCommand"); - } - continueTest(); - } - }); - } - - if (IS_MAC) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{metaKey:1}, chars:";", unmodifiedChars:";"}, - "unshiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Semicolon, - modifiers:{metaKey:1, shiftKey:1}, chars:";", unmodifiedChars:":"}, - "shiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{metaKey:1}, chars:"'", unmodifiedChars:"'"}, - "reservedUnshiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_Quote, - modifiers:{metaKey:1, shiftKey:1}, chars:"\"", unmodifiedChars:"'"}, - "reservedShiftedKey"); - } - else if (IS_WIN) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{ctrlKey:1}, chars:""}, - "unshiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_1, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "shiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{ctrlKey:1}, chars:""}, - "reservedUnshiftedKey"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_OEM_7, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "reservedShiftedKey"); - } - - // 429160 - if (IS_MAC) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_F, - modifiers:{metaKey:1, altKey:1}, chars:"\u0192", unmodifiedChars:"f"}, - "commandOptionF"); - } - else if (IS_WIN) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_F, - modifiers:{ctrlKey:1, altKey:1}, chars:"\u0006"}, - "commandOptionF"); - } - - // 432112 - if (IS_MAC) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_SWEDISH, keyCode:MAC_VK_ANSI_Minus, - modifiers:{metaKey:1, shiftKey:1}, chars:"+", unmodifiedChars:"?"}, - "question"); - } - else if (IS_WIN) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_SWEDISH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "question"); - // For testing if Ctrl+? is kicked without Shift state, temporarily disable - // Ctrl-+ key element. - var unshiftedPlusKeyElement = document.getElementById("unshiftedPlus"); - unshiftedPlusKeyElement.setAttribute("disabled", "true"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_SWEDISH, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1}, chars:""}, - ""); - unshiftedPlusKeyElement.removeAttribute("disabled"); - } - - // bug 433192 - if (IS_WIN) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1}, chars:"\u0018"}, - "unshiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0018"}, - "shiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_ARABIC, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1}, chars:"\u0018"}, - "unshiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_ARABIC, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0018"}, - "shiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_HEBREW, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1}, chars:"\u0018"}, - "unshiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_HEBREW, keyCode:WIN_VK_X, - modifiers:{ctrlKey:1, shiftKey:1}, chars:"\u0018"}, - "shiftedX"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_JAPANESE, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "unshiftedPlus"); - } - - // bug 759346 - if (IS_WIN) { - yield testKeyElement({layout:KEYBOARD_LAYOUT_THAI, keyCode:WIN_VK_1, - modifiers:{ctrlKey:1}, chars:""}, - ""); - yield testKeyElement({layout:KEYBOARD_LAYOUT_THAI, keyCode:WIN_VK_1, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - "unshiftedPlus"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_THAI, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1}, chars:""}, - "unshiftedPlus"); - yield testKeyElement({layout:KEYBOARD_LAYOUT_THAI, keyCode:WIN_VK_OEM_PLUS, - modifiers:{ctrlKey:1, shiftKey:1}, chars:""}, - ""); - } - - for (id in commandElements) { - commandElements[id].setAttribute("disabled", "true"); - } - finializeKeyElementTest(); -} - -function* runReservedKeyTests() -{ - var browser = document.getElementById("browser"); - var contents = [ - browser.contentWindow, - browser.contentDocument, - browser.contentDocument.documentElement, - browser.contentDocument.body, - browser.contentDocument.getElementById("content_button") - ]; - - for (var i = 0; i < contents.length; i++) { - contents[i].addEventListener("keydown", onKeyInDefaultEventGroup, true); - contents[i].addEventListener("keypress", onKeyInDefaultEventGroup, true); - contents[i].addEventListener("keydown", onKeyInDefaultEventGroup, false); - contents[i].addEventListener("keypress", onKeyInDefaultEventGroup, false); - SpecialPowers.addSystemEventListener(contents[i], "keydown", onKeyInSystemEventGroup, true); - SpecialPowers.addSystemEventListener(contents[i], "keypress", onKeyInSystemEventGroup, true); - SpecialPowers.addSystemEventListener(contents[i], "keydown", onKeyInSystemEventGroup, false); - SpecialPowers.addSystemEventListener(contents[i], "keypress", onKeyInSystemEventGroup, false); - } - - var keyEvents = []; - - function onKeyInDefaultEventGroup(aDOMEvent) - { - if (isModifierKeyEvent(aDOMEvent)) { - return; - } - keyEvents.push({ type: aDOMEvent.type, group: "default", phase: getPhase(aDOMEvent), currentTarget: eventTargetToString(aDOMEvent.currentTarget) }); - } - - function onKeyInSystemEventGroup(aDOMEvent) - { - if (isModifierKeyEvent(aDOMEvent)) { - return; - } - keyEvents.push({ type: aDOMEvent.type, group: "system", phase: getPhase(aDOMEvent), currentTarget: eventTargetToString(aDOMEvent.currentTarget) }); - // prevents reserved default action - if (aDOMEvent.type == "keypress" && - aDOMEvent.eventPhase == aDOMEvent.BUBBLING_PHASE && - aDOMEvent.currentTarget == browser.contentWindow) { - aDOMEvent.preventDefault(); - } - } - - function finializeKeyElementTest() - { - for (var i = 0; i < contents.length; i++) { - contents[i].removeEventListener("keydown", onKeyInDefaultEventGroup, true); - contents[i].removeEventListener("keypress", onKeyInDefaultEventGroup, true); - contents[i].removeEventListener("keydown", onKeyInDefaultEventGroup, false); - contents[i].removeEventListener("keypress", onKeyInDefaultEventGroup, false); - SpecialPowers.removeSystemEventListener(contents[i], "keydown", onKeyInSystemEventGroup, true); - SpecialPowers.removeSystemEventListener(contents[i], "keypress", onKeyInSystemEventGroup, true); - SpecialPowers.removeSystemEventListener(contents[i], "keydown", onKeyInSystemEventGroup, false); - SpecialPowers.removeSystemEventListener(contents[i], "keypress", onKeyInSystemEventGroup, false); - } - } - - function testReservedKey(aEvent) - { - keyEvents = []; - return synthesizeKey(aEvent, "content_button", function() { - testName = "testReservedKey: " + eventToString(aEvent) + " "; - is(keyEvents.length, 20, testName + "wrong number events fired"); - is(JSON.stringify(keyEvents[0]), JSON.stringify({ type: "keydown", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[0]) }), testName + "keydown event should be fired on content only in the system event group #0"); - is(JSON.stringify(keyEvents[1]), JSON.stringify({ type: "keydown", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[1]) }), testName + "keydown event should be fired on content only in the system event group #1"); - is(JSON.stringify(keyEvents[2]), JSON.stringify({ type: "keydown", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[2]) }), testName + "keydown event should be fired on content only in the system event group #2"); - is(JSON.stringify(keyEvents[3]), JSON.stringify({ type: "keydown", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[3]) }), testName + "keydown event should be fired on content only in the system event group #3"); - - is(JSON.stringify(keyEvents[4]), JSON.stringify({ type: "keydown", group: "system", phase: "target", currentTarget: eventTargetToString(contents[4]) }), testName + "keydown event should be fired on content only in the system event group #4"); - is(JSON.stringify(keyEvents[5]), JSON.stringify({ type: "keydown", group: "system", phase: "target", currentTarget: eventTargetToString(contents[4]) }), testName + "keydown event should be fired on content only in the system event group #5"); - - is(JSON.stringify(keyEvents[6]), JSON.stringify({ type: "keydown", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[3]) }), testName + "keydown event should be fired on content only in the system event group #6"); - is(JSON.stringify(keyEvents[7]), JSON.stringify({ type: "keydown", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[2]) }), testName + "keydown event should be fired on content only in the system event group #7"); - is(JSON.stringify(keyEvents[8]), JSON.stringify({ type: "keydown", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[1]) }), testName + "keydown event should be fired on content only in the system event group #8"); - is(JSON.stringify(keyEvents[9]), JSON.stringify({ type: "keydown", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[0]) }), testName + "keydown event should be fired on content only in the system event group #9"); - - is(JSON.stringify(keyEvents[10]), JSON.stringify({ type: "keypress", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[0]) }), testName + "keypress event should be fired on content only in the system event group #10"); - is(JSON.stringify(keyEvents[11]), JSON.stringify({ type: "keypress", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[1]) }), testName + "keypress event should be fired on content only in the system event group #11"); - is(JSON.stringify(keyEvents[12]), JSON.stringify({ type: "keypress", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[2]) }), testName + "keypress event should be fired on content only in the system event group #12"); - is(JSON.stringify(keyEvents[13]), JSON.stringify({ type: "keypress", group: "system", phase: "capture", currentTarget: eventTargetToString(contents[3]) }), testName + "keypress event should be fired on content only in the system event group #13"); - - is(JSON.stringify(keyEvents[14]), JSON.stringify({ type: "keypress", group: "system", phase: "target", currentTarget: eventTargetToString(contents[4]) }), testName + "keypress event should be fired on content only in the system event group #14"); - is(JSON.stringify(keyEvents[15]), JSON.stringify({ type: "keypress", group: "system", phase: "target", currentTarget: eventTargetToString(contents[4]) }), testName + "keypress event should be fired on content only in the system event group #15"); - - is(JSON.stringify(keyEvents[16]), JSON.stringify({ type: "keypress", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[3]) }), testName + "keypress event should be fired on content only in the system event group #16"); - is(JSON.stringify(keyEvents[17]), JSON.stringify({ type: "keypress", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[2]) }), testName + "keypress event should be fired on content only in the system event group #17"); - is(JSON.stringify(keyEvents[18]), JSON.stringify({ type: "keypress", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[1]) }), testName + "keypress event should be fired on content only in the system event group #18"); - is(JSON.stringify(keyEvents[19]), JSON.stringify({ type: "keypress", group: "system", phase: "bubble", currentTarget: eventTargetToString(contents[0]) }), testName + "keypress event should be fired on content only in the system event group #19"); - - continueTest(); - }); - } - - if (IS_MAC) { - // Cmd+T is reserved for opening new tab. - yield testReservedKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:MAC_VK_ANSI_T, - modifiers:{metaKey:1}, chars:"t", unmodifiedChars:"t"}); - } else if (IS_WIN) { - // Ctrl+T is reserved for opening new tab. - yield testReservedKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_T, - modifiers:{ctrlKey:1}, chars:"\u0014"}); - yield testReservedKey({layout:KEYBOARD_LAYOUT_ARABIC, keyCode:WIN_VK_T, - modifiers:{ctrlKey:1}, chars:"\u0014"}); - } - - finializeKeyElementTest(); -} - -function* runTextInputTests() -{ - var textbox = document.getElementById("textbox"); - - function testKey(aEvent, aExpectText) { - textbox.value = ""; - textbox.focus(); - - var name = eventToString(aEvent); - - // Check if the text comes with keypress events rather than composition events. - var keypress = 0; - function onKeypress(aEvent) { - keypress++; - if (keypress == 1 && aExpectText == "") { - if (!aEvent.ctrlKey && !aEvent.altKey) { - is(aEvent.charCode, 0, name + ", the charCode value should be 0 when it shouldn't cause inputting text"); - } - return; - } - if (keypress > aExpectText.length) { - ok(false, name + " causes too many keypress events"); - return; - } - is(aEvent.key, aExpectText[keypress - 1], - name + ", " + keypress + "th keypress event's key value should be '" + aExpectText[keypress - 1] + "'"); - is(aEvent.charCode, aExpectText.charCodeAt(keypress - 1), - name + ", " + keypress + "th keypress event's charCode value should be 0x" + parseInt(aExpectText.charCodeAt(keypress - 1), 16)); - } - textbox.addEventListener("keypress", onKeypress, true); - - return synthesizeKey(aEvent, "textbox", function() { - textbox.removeEventListener("keypress", onKeypress, true); - if (aExpectText == "") { - is(keypress, 1, name + " should cause one keypress event because it doesn't cause inputting text"); - } else { - is(keypress, aExpectText.length, name + " should cause " + aExpectText.length + " keypress events"); - is(textbox.value, aExpectText, name + " does not input correct text."); - } - - continueTest(); - }); - } - - if (IS_MAC) { - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_G, - modifiers:{shiftKey:1}, chars:"\u0644\u0623", unmodifiedChars:"\u0644\u0623"}, - "\u0644\u0623"); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_T, - modifiers:{shiftKey:1}, chars:"\u0644\u0625", unmodifiedChars:"\u0644\u0625"}, - "\u0644\u0625"); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B, - modifiers:{shiftKey:1}, chars:"\u0644\u0622", unmodifiedChars:"\u0644\u0622"}, - "\u0644\u0622"); - yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B, - modifiers:{}, chars:"\u0644\u0627", unmodifiedChars:"\u0644\u0627"}, - "\u0644\u0627"); - } else if (IS_WIN) { - // Basic sanity checks - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{}, chars:"a"}, - "a"); - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{shiftKey:1}, chars:"A"}, - "A"); - // When Ctrl+Alt are pressed, any text should not be inputted. - yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A, - modifiers:{ctrlKey:1, altKey:1}, chars:""}, - ""); - - // Lithuanian AltGr should be consumed at 9/0 keys pressed - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_8, - modifiers:{}, chars:"\u016B"}, - "\u016B"); - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_9, - modifiers:{}, chars:"9"}, - "9"); - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_0, - modifiers:{}, chars:"0"}, - "0"); - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_8, - modifiers:{ctrlKey:1, altKey:1}, chars:"8"}, - "8"); - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_9, - modifiers:{ctrlKey:1, altKey:1}, chars:"9"}, - "9"); - yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_0, - modifiers:{ctrlKey:1, altKey:1}, chars:"0"}, - "0"); - } - - // XXX We need to move focus for canceling to search the autocomplete - // result. If we don't do here, Fx will crash at end of this tests. - document.getElementById("button").focus(); -} - -function* runAllTests() { - yield* runKeyEventTests(); - yield* runAccessKeyTests(); - yield* runXULKeyTests(); - yield* runReservedKeyTests(); - yield* runTextInputTests(); -} - -var gTestContinuation = null; - -function continueTest() -{ - if (!gTestContinuation) { - gTestContinuation = runAllTests(); - } - var ret = gTestContinuation.next(); - if (ret.done) { - SimpleTest.finish(); - } else { - is(ret.value, true, "Key synthesized successfully"); - } -} - -function runTest() -{ - if (!IS_MAC && !IS_WIN) { - todo(false, "This test is supported on MacOSX and Windows only. (Bug 431503)"); - return; - } - - if (IS_WIN && OS_VERSION >= WIN8) { - // Switching keyboard layout to Russian - Mnemonic causes 2 assertions in KeyboardLayout::LoadLayout(). - SimpleTest.expectAssertions(2, 2); - } - SimpleTest.waitForExplicitFinish(); - - clearInfobars(); - - continueTest(); -} - -]]> -</script> - -</window> diff --git a/widget/tests/test_mouse_scroll.xul b/widget/tests/test_mouse_scroll.xul deleted file mode 100644 index 570b304ea..000000000 --- a/widget/tests/test_mouse_scroll.xul +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Testing composition, text and query content events" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("window_mouse_scroll_win.html", "_blank", - "chrome,width=600,height=600"); - -]]> -</script> -</window> diff --git a/widget/tests/test_native_key_bindings_mac.html b/widget/tests/test_native_key_bindings_mac.html deleted file mode 100644 index dc3872f02..000000000 --- a/widget/tests/test_native_key_bindings_mac.html +++ /dev/null @@ -1,343 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head> - <meta charset='utf-8'/> - <title>Native Key Bindings for Cocoa Test</title> - <!-- Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ --> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script> - </head> - <body> - <div id="editable" contenteditable> - <p>Stretching attack nullam stuck in a tree zzz, suspendisse cras nec - suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the - curtains biting I don't like that food tristique biting sleep on your - keyboard non. Lay down in your way cras nec tempus chase the red dot cras - nec, pharetra pharetra eat the grass leap run orci turpis attack. - Consectetur sleep in the sink eat I don't like that food, knock over the - lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed - everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam - pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis - purr sleep on your face quis nunc bibendum.</p> - - <p>Neque jump on the table bat iaculis, adipiscing sleep on your keyboard - jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus - hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack. - Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on - your keyboard purr knock over the lamp orci turpis. Vestibulum I don't - like that food et chase the red dot, adipiscing neque bibendum rutrum - accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on - your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase - the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking - judging you.</p> - - <p>Claw purr sollicitudin sollicitudin lay down in your way consectetur, - pellentesque vehicula zzz orci turpis consectetur. I don't like that food - rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles - iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum, - bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse - nibh, puking adipiscing sleep on your face sleep on your face zzz catnip. - Judging you rutrum bat sunbathe sleep on your face, jump on the table leap - tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss - in viverra nullam, quis tortor pharetra attack.</p> - </div> - - <textarea id="textarea" cols="80"> - Stretching attack nullam stuck in a tree zzz, suspendisse cras nec - suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the - curtains biting I don't like that food tristique biting sleep on your - keyboard non. Lay down in your way cras nec tempus chase the red dot cras - nec, pharetra pharetra eat the grass leap run orci turpis attack. - Consectetur sleep in the sink eat I don't like that food, knock over the - lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed - everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam - pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis - purr sleep on your face quis nunc bibendum. - - Neque jump on the table bat iaculis, adipiscing sleep on your keyboard - jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus - hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack. - Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on - your keyboard purr knock over the lamp orci turpis. Vestibulum I don't - like that food et chase the red dot, adipiscing neque bibendum rutrum - accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on - your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase - the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking - judging you. - - Claw purr sollicitudin sollicitudin lay down in your way consectetur, - pellentesque vehicula zzz orci turpis consectetur. I don't like that food - rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles - iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum, - bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse - nibh, puking adipiscing sleep on your face sleep on your face zzz catnip. - Judging you rutrum bat sunbathe sleep on your face, jump on the table leap - tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss - in viverra nullam, quis tortor pharetra attack. - </textarea> - - <input id="input" type="text" - value="Stretching attack nullam stuck in a tree zzz, suspendisse cras nec - suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the - curtains biting I don't like that food tristique biting sleep on your - keyboard non. Lay down in your way cras nec tempus chase the red dot cras - nec, pharetra pharetra eat the grass leap run orci turpis attack. - Consectetur sleep in the sink eat I don't like that food, knock over the - lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed - everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. - Nullam pellentesque rip the couch iaculis rhoncus nibh, give me fish orci - turpis purr sleep on your face quis nunc bibendum."> - - <script type="text/javascript;version=1.8"> - SimpleTest.waitForExplicitFinish(); - - let synthesizedKeys = []; - let expectations = []; - - // Move to beginning of line - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow, - {ctrlKey: true}, "\uf702", "\uf702"]); - expectations.push({ - editable: [0, 0], - textarea: [0, 0], - input: [0, 0] - }); - - // Move to end of line - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {ctrlKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [73, 73], - textarea: [72, 72], - input: [732, 732] - }); - - // Move down - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_N, - {ctrlKey: true}, "\u000e", "n"]); - expectations.push({ - editable: [140, 140], - textarea: [145, 145], - input: [732, 732] - }); - - // Move to beginning of line - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow, - {ctrlKey: true}, "\uf702", "\uf702"]); - expectations.push({ - editable: [73, 73], - textarea: [73, 73], - input: [0, 0] - }); - - // Move word right and modify selection - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {altKey: true, shiftKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [73, 84], - textarea: [73, 90], - input: [0, 10] - }); - - // Move word right - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {altKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [84, 84], - textarea: [90, 90], - input: [10, 10] - }); - - // Move word right - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {altKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [89, 89], - textarea: [95, 95], - input: [17, 17] - }); - - // Move down and modify selection - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_DownArrow, - {shiftKey: true}, "\uf701", "\uf701"]); - expectations.push({ - editable: [89, 171], - textarea: [95, 175], - input: [17, 732] - }); - - // Move backward and modify selection - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, - {ctrlKey: true, shiftKey: true}, "\u0002", "B"]); - expectations.push({ - editable: [89, 170], - textarea: [95, 174], - input: [17, 731] - }); - - // Delete forward - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_D, - {ctrlKey: true}, "\u0004", "d"]); - expectations.push({ - editable: [89, 89], - textarea: [95, 95], - input: [17, 17] - }); - - // Delete backward - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_H, - {ctrlKey: true}, "\u0008", "h"]); - expectations.push({ - editable: [88, 88], - textarea: [94, 94], - input: [16, 16] - }); - - // Move backward - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, - {ctrlKey: true}, "\u0002", "b"]); - expectations.push({ - editable: [87, 87], - textarea: [93, 93], - input: [15, 15] - }); - - // Move to beginning of paragraph (line for now) - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, - {ctrlKey: true}, "\u0001", "a"]); - expectations.push({ - editable: [73, 73], - textarea: [73, 73], - input: [0, 0] - }); - - // Move forward - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_F, - {ctrlKey: true}, "\u0006", "f"]); - expectations.push({ - editable: [74, 74], - textarea: [74, 74], - input: [1, 1] - }); - - // Move word right - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {altKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [84, 84], - textarea: [90, 90], - input: [10, 10] - }); - - // Move word right - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, - {altKey: true}, "\uf703", "\uf703"]); - expectations.push({ - editable: [88, 88], - textarea: [94, 94], - input: [17, 17] - }); - - // Delete to end of paragraph (line for now) - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_K, - {ctrlKey: true}, "\u000b", "k"]); - expectations.push({ - editable: [88, 88], - textarea: [94, 94], - input: [17, 17] - }); - - // Move backward and modify selection - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, - {ctrlKey: true, shiftKey: true}, "\u0002", "B"]); - expectations.push({ - editable: [88, 87], - textarea: [93, 94], - input: [16, 17] - }); - - // Move to end of paragraph (line for now) - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_E, - {ctrlKey: true}, "\u0005", "e"]); - expectations.push({ - editable: [139, 139], - textarea: [94, 94], - input: [17, 17] - }); - - // Move up - synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_P, - {ctrlKey: true}, "\u0010", "p"]); - expectations.push({ - editable: [73, 73], - textarea: [21, 21], - input: [0, 0] - }); - - function checkWindowSelection(aElement, aSelection) - { - let selection = window.getSelection(); - - is(selection.anchorOffset, aSelection[aElement.id][0], - aElement.id + ": Incorrect anchor offset"); - is(selection.focusOffset, aSelection[aElement.id][1], - aElement.id + ": Incorrect focus offset"); - } - - function checkElementSelection(aElement, aSelection) - { - is(aElement.selectionStart, aSelection[aElement.id][0], - aElement.id + ": Incorrect selection start"); - is(aElement.selectionEnd, aSelection[aElement.id][1], - aElement.id + ": Incorrect selection end"); - } - - function* testRun(aElement, aSelectionCheck, aCallback) - { - if (document.activeElement) { - document.activeElement.blur(); - } - - aElement.focus(); - - for (let i = 0; i < synthesizedKeys.length; i++) { - synthesizedKeys[i].push(function() { - aSelectionCheck.call(null, aElement, expectations[i]); - continueTest(); - }); - var synthOk = synthesizeNativeKey.apply(null, synthesizedKeys[i]); - synthesizedKeys[i].pop(); - yield synthOk; - } - } - - function* doTest() { - yield* testRun(document.getElementById("editable"), checkWindowSelection); - yield* testRun(document.getElementById("textarea"), checkElementSelection); - yield* testRun(document.getElementById("input"), checkElementSelection); - } - - let gTestContinuation = null; - - function continueTest() - { - if (!gTestContinuation) { - gTestContinuation = doTest(); - } - var ret = gTestContinuation.next(); - if (ret.done) { - SimpleTest.finish(); - } else { - is(ret.value, true, "Successfully synthesized key"); - } - } - - SimpleTest.waitForFocus(continueTest); - </script> - </body> -</html> diff --git a/widget/tests/test_native_menus.xul b/widget/tests/test_native_menus.xul deleted file mode 100644 index cf9bcc881..000000000 --- a/widget/tests/test_native_menus.xul +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Native menu system tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("native_menus_window.xul", "NativeMenuWindow", - "chrome,width=600,height=600"); - -]]> -</script> - -</window> diff --git a/widget/tests/test_native_mouse_mac.xul b/widget/tests/test_native_mouse_mac.xul deleted file mode 100644 index 5d86864b2..000000000 --- a/widget/tests/test_native_mouse_mac.xul +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Native mouse event tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("native_mouse_mac_window.xul", "NativeMouseWindow", - "chrome,width=600,height=600"); - -]]> -</script> - -</window> diff --git a/widget/tests/test_panel_mouse_coords.xul b/widget/tests/test_panel_mouse_coords.xul deleted file mode 100644 index 41ef49044..000000000 --- a/widget/tests/test_panel_mouse_coords.xul +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/css" href="chrome://global/skin"?> -<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=835044 ---> -<window title="Mozilla Bug 835044" - onload="startTest()" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - -<panel id="thepanel" level="parent" - onpopupshown="sendMouseEvent();" - onmousemove="checkCoords(event);" - width="80" height="80"> -</panel> - - <!-- test results are displayed in the html:body --> - <body xmlns="http://www.w3.org/1999/xhtml"> - <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=835044" - id="anchor" - target="_blank">Mozilla Bug 835044</a> - </body> - - <!-- test code goes here --> - <script type="application/javascript"> - <![CDATA[ -SimpleTest.waitForExplicitFinish(); - -var Cc = Components.classes; -var Ci = Components.interfaces; -let utils = window.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIDOMWindowUtils); -let panel = document.getElementById('thepanel'); -let nativeMouseMove; -let rect; - -function startTest() { - let widgetToolkit = Cc["@mozilla.org/xre/app-info;1"]. - getService(Ci.nsIXULRuntime).widgetToolkit; - - if (widgetToolkit == "cocoa") { - nativeMouseMove = 5; // NSMouseMoved - } else if (widgetToolkit == "windows") { - nativeMouseMove = 1; // MOUSEEVENTF_MOVE - } else if (/^gtk/.test(widgetToolkit)) { - nativeMouseMove = 3; // GDK_MOTION_NOTIFY - } else { - todo_is("widgetToolkit", widgetToolkit, "Platform not supported"); - done(); - } - - // This first event is to ensure that the next event will have different - // coordinates to the previous mouse position, and so actually generates - // mouse events. The mouse is not moved off the window, as that might - // move focus to another application. - utils.sendNativeMouseEvent(window.mozInnerScreenX, window.mozInnerScreenY, - nativeMouseMove, 0, window.documentElement); - - panel.openPopup(document.getElementById("anchor"), "after_start"); -} - -function sendMouseEvent() { - rect = panel.getBoundingClientRect(); - let x = window.mozInnerScreenX + rect.left + 1; - let y = window.mozInnerScreenY + rect.top + 2; - utils.sendNativeMouseEvent(x, y, nativeMouseMove, 0, - window.documentElement); -} - -function checkCoords(event) { - is(event.clientX, rect.left + 1, "Motion x coordinate"); - is(event.clientY, rect.top + 2, "Motion y coordinate"); - done(); -} - -function done() { - SimpleTest.finish(); -} - ]]> - </script> -</window> diff --git a/widget/tests/test_picker_no_crash.html b/widget/tests/test_picker_no_crash.html deleted file mode 100644 index 08ba1db12..000000000 --- a/widget/tests/test_picker_no_crash.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for crashes when the parent window of a file picker is closed via script</title> - <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> -</head> - -<script type="application/javascript"> - -SimpleTest.waitForExplicitFinish(); -SimpleTest.requestFlakyTimeout("untriaged"); - -var childWindow; - -function testStepOne() { - childWindow = window.open('window_picker_no_crash_child.html', 'childWindow', 'width=300,height=150'); - SimpleTest.waitForFocus(testStepTwo, childWindow); -} - -function testStepTwo() { - childWindow.document.form1.uploadbox.click(); - // This should not crash the browser - childWindow.close(); - setTimeout("testStepThree();", 5000); -} - -function testStepThree() { - ok(true, "browser didn't crash"); - SimpleTest.finish(); -} - -SimpleTest.waitForFocus(testStepOne); -</script> -</body> -</html> diff --git a/widget/tests/test_platform_colors.xul b/widget/tests/test_platform_colors.xul deleted file mode 100644 index b30b9837f..000000000 --- a/widget/tests/test_platform_colors.xul +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Mac platform colors" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=518395">Mozilla Bug 518395</a> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -<box id="colorbox"></box> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -var colors = { - "activeborder": ["rgb(0, 0, 0)"], - "activecaption": ["rgb(204, 204, 204)"], - "appworkspace": ["rgb(255, 255, 255)"], - "background": ["rgb(99, 99, 206)"], - "buttonface": ["rgb(240, 240, 240)"], - "buttonhighlight": ["rgb(255, 255, 255)"], - "buttonshadow": ["rgb(220, 220, 220)"], - "buttontext": ["rgb(0, 0, 0)"], - "captiontext": ["rgb(0, 0, 0)"], - "graytext": ["rgb(127, 127, 127)"], - "highlight": ["rgb(115, 132, 153)", "rgb(127, 127, 127)", "rgb(56, 117, 215)", "rgb(255, 193, 31)", "rgb(243, 70, 72)", "rgb(255, 138, 34)", "rgb(102, 197, 71)", "rgb(140, 78, 184)"], - "highlighttext": ["rgb(255, 255, 255)", "rgb(255, 254, 254)", "rgb(254, 255, 254)"], - "inactiveborder": ["rgb(255, 255, 255)"], - "inactivecaption": ["rgb(255, 255, 255)"], - "inactivecaptiontext": ["rgb(69, 69, 69)"], - "infobackground": ["rgb(255, 255, 199)"], - "infotext": ["rgb(0, 0, 0)"], - "menu": ["rgb(255, 255, 255)", "rgb(254, 255, 254)", "rgb(255, 254, 254)"], - "menutext": ["rgb(0, 0, 0)"], - "scrollbar": ["rgb(170, 170, 170)"], - "threeddarkshadow": ["rgb(220, 220, 220)"], - "threedface": ["rgb(240, 240, 240)"], - "threedhighlight": ["rgb(255, 255, 255)"], - "threedlightshadow": ["rgb(218, 218, 218)"], - "threedshadow": ["rgb(224, 224, 224)"], - "window": ["rgb(255, 255, 255)"], - "windowframe": ["rgb(204, 204, 204)"], - "windowtext": ["rgb(0, 0, 0)"], - "-moz-activehyperlinktext": ["rgb(238, 0, 0)"], - "-moz-buttondefault": ["rgb(220, 220, 220)"], - "-moz-buttonhoverface": ["rgb(240, 240, 240)"], - "-moz-buttonhovertext": ["rgb(0, 0, 0)"], - "-moz-cellhighlight": ["rgb(212, 212, 212)", "rgb(220, 220, 220)"], - "-moz-cellhighlighttext": ["rgb(0, 0, 0)"], - "-moz-eventreerow": ["rgb(255, 255, 255)"], - "-moz-field": ["rgb(255, 255, 255)"], - "-moz-fieldtext": ["rgb(0, 0, 0)"], - "-moz-dialog": ["rgb(232, 232, 232)"], - "-moz-dialogtext": ["rgb(0, 0, 0)"], - "-moz-dragtargetzone": ["rgb(199, 208, 218)", "rgb(198, 198, 198)", "rgb(180, 213, 255)", "rgb(250, 236, 115)", "rgb(255, 176, 139)", "rgb(255, 209, 129)", "rgb(194, 249, 144)", "rgb(232, 184, 255)"], - "-moz-hyperlinktext": ["rgb(0, 0, 238)"], - "-moz-html-cellhighlight": ["rgb(212, 212, 212)"], - "-moz-html-cellhighlighttext": ["rgb(0, 0, 0)"], - "-moz-mac-buttonactivetext": ["rgb(0, 0, 0)", "rgb(255, 255, 255)"], - "-moz-mac-chrome-active": ["rgb(150, 150, 150)", "rgb(167, 167, 167)", "rgb(178, 178, 178)"], - "-moz-mac-chrome-inactive": ["rgb(202, 202, 202)", "rgb(216, 216, 216)", "rgb(225, 225, 225)"], - "-moz-mac-defaultbuttontext": ["rgb(0, 0, 0)", "rgb(255, 255, 255)"], - //"-moz-mac-focusring": ["rgb(83, 144, 210)", "rgb(95, 112, 130)", "rgb(63, 152, 221)", "rgb(108, 126, 141)"], - "-moz-mac-menuselect": ["rgb(115, 132, 153)", "rgb(127, 127, 127)", "rgb(56, 117, 215)", "rgb(255, 193, 31)", "rgb(243, 70, 72)", "rgb(255, 138, 34)", "rgb(102, 197, 71)", "rgb(140, 78, 184)"], - "-moz-mac-menushadow": ["rgb(163, 163, 163)"], - "-moz-mac-menutextdisable": ["rgb(152, 152, 152)"], - "-moz-mac-menutextselect": ["rgb(255, 255, 255)"], - "-moz-mac-disabledtoolbartext": ["rgb(127, 127, 127)"], - "-moz-mac-secondaryhighlight": ["rgb(212, 212, 212)"], - "-moz-menuhover": ["rgb(115, 132, 153)", "rgb(127, 127, 127)", "rgb(56, 117, 215)", "rgb(255, 193, 31)", "rgb(243, 70, 72)", "rgb(255, 138, 34)", "rgb(102, 197, 71)", "rgb(140, 78, 184)"], - "-moz-menuhovertext": ["rgb(255, 255, 255)", "rgb(255, 254, 254)", "rgb(254, 255, 254)"], - "-moz-menubartext": ["rgb(0, 0, 0)"], - //"-moz-menubarhovertext": ["rgb(255, 255, 255)"], - "-moz-oddtreerow": ["rgb(236, 242, 254)", "rgb(240, 240, 240)", "rgb(243, 245, 250)", "rgb(243, 246, 250)", "rgb(245, 245, 245)"], - "-moz-visitedhyperlinktext": ["rgb(85, 26, 139)"], - "currentcolor": ["rgb(0, 0, 0)"], - //"-moz-win-mediatext": ["rgb(255, 255, 255)"], - //"-moz-win-communicationstext": ["rgb(255, 255, 255)"], - "-moz-nativehyperlinktext": ["rgb(20, 79, 174)"], - "-moz-comboboxtext": ["rgb(0, 0, 0)"], - "-moz-combobox": ["rgb(255, 255, 255)"] -}; - -var colorbox = document.getElementById('colorbox'); - -for (var c in colors) { - dump("testing color " + c + "\n"); - colorbox.style.backgroundColor = c; - var rgb = document.defaultView.getComputedStyle(colorbox, null).getPropertyValue('background-color'); - ok(colors[c].indexOf(rgb) != -1 || colors[c].length == 8, 'platform color ' + c + ' is wrong: ' + rgb); -} - - -]]> -</script> - -</window> diff --git a/widget/tests/test_plugin_input_event.html b/widget/tests/test_plugin_input_event.html deleted file mode 100644 index 6ed2a14c4..000000000 --- a/widget/tests/test_plugin_input_event.html +++ /dev/null @@ -1,74 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for plugin input event</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script> - <script type="text/javascript" src="utils.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body> -<script type="application/javascript"> -setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); -</script> - -<p id="display"> - <embed id="plugin" type="application/x-test" wmode="opaque"> -</p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> - -<script type="application/javascript"> -SimpleTest.waitForExplicitFinish(); - -var gPlugin = document.getElementById("plugin"); - -var gUtils = window. - QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIDOMWindowUtils); - -function* doTest() { - gPlugin.focus(); - - is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN, - "Plugin failed to get focus"); - - is(gPlugin.getLastKeyText(), "", "Must be empty before first key test"); - - yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, WIN_VK_A, {}, "a", "a", continueTest); - is(gPlugin.getLastKeyText(), "a", "Invalid character was inputted"); - - yield synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {}, "+", "+", continueTest); - is(gPlugin.getLastKeyText(), "+", "Invalid character was inputted"); - - yield synthesizeNativeKey(KEYBOARD_LAYOUT_GERMAN, WIN_VK_OEM_PLUS, {altGrKey:1}, "~", "+", continueTest); - is(gPlugin.getLastKeyText(), "~", "Invalid character was inputted"); -} - -var gTestContinuation = null; - -function continueTest() { - if (!gTestContinuation) { - gTestContinuation = doTest(continueTest); - } - var ret = gTestContinuation.next(); - if (ret.done) { - SimpleTest.finish(); - } else { - is(ret.value, true, "Key synthesized successfully"); - } -} - -SimpleTest.waitForFocus(continueTest); - -</script> -</body> -</html> diff --git a/widget/tests/test_plugin_scroll_consistency.html b/widget/tests/test_plugin_scroll_consistency.html deleted file mode 100644 index 76d97f4ef..000000000 --- a/widget/tests/test_plugin_scroll_consistency.html +++ /dev/null @@ -1,61 +0,0 @@ -<html> -<head> - <title>Test for plugin child widgets not being messed up by scrolling</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="utils.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body onload="setTimeout(runTests, 0)"> -<script type="application/javascript"> -setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); -</script> - -<p id="display"> - <div style="overflow:hidden; height:100px;" id="scroll"> - <embed type="application/x-test" wmode="window" width="100" height="800" id="plugin"></object> - <div style="height:1000px;"></div> - </div> -</p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> - -<script class="testbody" type="application/javascript"> -SimpleTest.waitForExplicitFinish(); - -var plugin = document.getElementById("plugin"); - -function consistencyCheck(state) { - var s = plugin.doInternalConsistencyCheck(); - ok(s == "", "Consistency check: " + state + ": " + s); -} - -function runTests() -{ - consistencyCheck("Initial state"); - - var scroll = document.getElementById("scroll"); - scroll.scrollTop = 10; - consistencyCheck("Scrolled down a bit"); - - setTimeout(function() { - consistencyCheck("Before scrolling back to top"); - scroll.scrollTop = 0; - consistencyCheck("Scrolled to top"); - - setTimeout(function() { - consistencyCheck("After scrolling to top"); - - SimpleTest.finish(); - }, 0); - }, 0); -} - -</script> -</body> - -</html> diff --git a/widget/tests/test_position_on_resize.xul b/widget/tests/test_position_on_resize.xul deleted file mode 100644 index e1adfc2b4..000000000 --- a/widget/tests/test_position_on_resize.xul +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> - -<window title="Window Position On Resize Test" - onload="startTest()" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> - -<script class="testbody" type="application/javascript"><![CDATA[ - SimpleTest.waitForExplicitFinish(); - let win, x, y; - - function startTest() { - win = window.openDialog("about:blank", - null, - "chrome,dialog=no,outerHeight=170,outerWidth=200"); - waitForSuccess(function() { return win.mozPaintCount }, - "No paint received", checkInitialSize); - } - - function checkInitialSize() { - let runtime = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Components.interfaces.nsIXULRuntime); - let test = runtime.widgetToolkit == "windows" ? todo_is : is; // bug 602745 - test(win.outerHeight,170, "initial outerHeight"); - test(win.outerWidth, 200, "initial outerWidth"); - x = win.screenX; - y = win.screenY; - shrink(); - } - function shrink() { - win.resizeTo(180, 160); - waitForSuccess(function() { return win.outerHeight == 160 }, - "outerHeight did not change to 160", checkShrink); - } - function checkShrink() { - is(win.outerWidth, 180, "resized outerWidth"); - is(win.screenY, y, "resized window top should not change"); - y = win.screenY; - restore(); - } - function restore() { - win.resizeBy(20, 10); - waitForSuccess(function() { return win.outerHeight == 170 }, - "outerHeight did not change to 170", checkRestore); - } - function checkRestore() { - is(win.outerWidth, 200, "restored outerWidth"); - is(win.screenX, x, "restored window left should not change"); - is(win.screenY, y, "restored window top should not change"); - done(); - } - function done() { - win.close(); - SimpleTest.finish(); - } - - function waitForSuccess(testForSuccess, failureMsg, nextFunc) { - var waitCount = 0; - - function repeatWait() { - ++waitCount; - - if (testForSuccess()) { - nextFunc(); - } - else if (waitCount > 50) { - ok(false, failureMsg); - nextFunc(); - } else { - setTimeout(repeatWait, 100); - } - } - - repeatWait(); - } -]]></script> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"> -</p> -<div id="content" style="display: none"> -</div> -<pre id="test"> -</pre> -</body> - -</window> diff --git a/widget/tests/test_secure_input.html b/widget/tests/test_secure_input.html deleted file mode 100644 index 2c3ee38db..000000000 --- a/widget/tests/test_secure_input.html +++ /dev/null @@ -1,148 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Test for secure input mode</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> - -<p> - <input id="input_text" type="text"><br> - <input id="input_password" type="password"><br> - <input id="input_text_readonly" type="text" readonly><br> - <input id="input_text_ime_mode_disabled" type="text" style="ime-mode: disabled;"><br> - <input id="input_change" type="text"><br> - <textarea id="textarea"></textarea><br> -</p> -<div id="contenteditable" contenteditable style="min-height: 3em;"></div> - -<script class="testbody" type="application/javascript"> - - SimpleTest.waitForExplicitFinish(); - - function sendAKeyEvent() - { - synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {}, "a", "a"); - } - - function isFocused(aElement) - { - return (SpecialPowers.focusManager.focusedElement == aElement); - } - - function runTest() - { - sendAKeyEvent(); - ok(true, "Not crashed: input on the document"); - $("input_text").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"text\">"); - $("input_password").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"password\">"); - $("input_password").blur(); - sendAKeyEvent(); - ok(true, "Not crashed: input on the document after blur() of <input type=\"password\">"); - $("input_password").focus(); - $("input_text_readonly").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"text\" readonly>"); - $("input_password").focus(); - $("input_text_ime_mode_disabled").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"text\" style=\"ime-mode: disabled;\">"); - $("input_password").focus(); - $("textarea").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <textarea>"); - $("input_password").focus(); - $("contenteditable").focus(); - sendAKeyEvent(); - ok(true, "Not crashed: input on <div contenteditable>"); - - $("input_change").focus(); - $("input_change").type = "password"; - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"password\"> changed from type=\"text\""); - $("input_change").type = "text"; - sendAKeyEvent(); - ok(true, "Not crashed: input on <input type=\"text\"> changed from type=\"password\""); - - otherWindow = - window.open("data:text/html,<input id=\"text\" type\"text\"><input id=\"password\" type\"password\">", - "_blank", "chrome,width=100,height=100"); - ok(otherWindow, "failed to open other window"); - if (!otherWindow) { - SimpleTest.finish(); - return; - } - - $("input_text").focus(); - otherWindow.focus(); - - SimpleTest.waitForFocus(function () { - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_text")), "focused element isn't <input type=\"text\">"); - ok(true, "Not crashed: input on <input type=\"text\"> after the other document has focus"); - - $("input_password").focus(); - otherWindow.focus(); - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_password")), "focused element isn't <input type=\"password\">"); - ok(true, "Not crashed: input on <input type=\"password\"> after the other document has focus"); - - $("input_text").focus(); - otherWindow.focus(); - otherWindow.document.getElementById("text").focus(); - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_text")), "focused element isn't <input type=\"text\">"); - ok(true, "Not crashed: input on <input type=\"text\"> after the other document's <input type=\"text\"> has focus"); - - $("input_password").focus(); - otherWindow.focus(); - otherWindow.document.getElementById("text").focus(); - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_password")), "focused element isn't <input type=\"password\">"); - ok(true, "Not crashed: input on <input type=\"password\"> after the other document's <input type=\"text\"> has focus"); - - $("input_text").focus(); - otherWindow.focus(); - otherWindow.document.getElementById("password").focus(); - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_text")), "focused element isn't <input type=\"text\">"); - ok(true, "Not crashed: input on <input type=\"text\"> after the other document's <input type=\"password\"> has focus"); - - $("input_password").focus(); - otherWindow.focus(); - otherWindow.document.getElementById("password").focus(); - window.focus(); - sendAKeyEvent(); - ok(isFocused($("input_password")), "focused element isn't <input type=\"password\">"); - ok(true, "Not crashed: input on <input type=\"password\"> after the other document's <input type=\"password\"> has focus"); - - SimpleTest.finish(); - - }, otherWindow); - } - - SimpleTest.waitForFocus(runTest); -</script> -</body> -</html> diff --git a/widget/tests/test_sizemode_events.xul b/widget/tests/test_sizemode_events.xul deleted file mode 100644 index e6ab940b2..000000000 --- a/widget/tests/test_sizemode_events.xul +++ /dev/null @@ -1,105 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Test for bug 715867" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - -gWindow = null; - -gSizeModeDidChange = false; -gSizeModeDidChangeTo = 0; - -function sizemodeChanged(e) { - gSizeModeDidChange = true; - gSizeModeDidChangeTo = gWindow.windowState; -} - -function expectSizeModeChange(newMode, duringActionCallback) { - gSizeModeDidChange = false; - - duringActionCallback(); - - if (newMode == 0) { - // No change should have taken place, no event should have fired. - ok(!gSizeModeDidChange, "No sizemodechange event should have fired."); - } else { - // Size mode change event was expected to fire. - ok(gSizeModeDidChange, "A sizemodechanged event should have fired."); - is(gSizeModeDidChangeTo, newMode, "The new sizemode should have the expected value."); - } -} - -function startTest() { - if (navigator.platform.indexOf("Lin") != -1) { - ok(true, "This test is disabled on Linux because it expects window sizemode changes to be synchronous (which is not the case on Linux)."); - SimpleTest.finish(); - return; - }; - openWindow(); -} - -function openWindow() { - gWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200,resizable'); - SimpleTest.waitForFocus(runTest, gWindow); -} - -function runTest() { - // Install event handler. - gWindow.addEventListener("sizemodechange", sizemodeChanged, false); - - // Run tests. - expectSizeModeChange(gWindow.STATE_MINIMIZED, function () { - gWindow.minimize(); - }); - - expectSizeModeChange(gWindow.STATE_NORMAL, function () { - gWindow.restore(); - }); - - expectSizeModeChange(gWindow.STATE_MAXIMIZED, function () { - gWindow.maximize(); - }); - - expectSizeModeChange(gWindow.STATE_NORMAL, function () { - gWindow.restore(); - }); - - // Normal window resizing shouldn't fire a sizemodechanged event, bug 715867. - expectSizeModeChange(0, function () { - gWindow.resizeTo(gWindow.outerWidth + 10, gWindow.outerHeight); - }); - - expectSizeModeChange(0, function () { - gWindow.resizeTo(gWindow.outerWidth, gWindow.outerHeight + 10); - }); - - gWindow.removeEventListener("sizemodechange", sizemodeChanged, false); - gWindow.close(); - SimpleTest.finish(); -} - -SimpleTest.waitForExplicitFinish(); -SimpleTest.waitForFocus(startTest); - -]]> -</script> - -</window> diff --git a/widget/tests/test_standalone_native_menu.xul b/widget/tests/test_standalone_native_menu.xul deleted file mode 100644 index bac7a352e..000000000 --- a/widget/tests/test_standalone_native_menu.xul +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Standalone Native Menu tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"></p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("standalone_native_menu_window.xul", "StandaloneNativeMenuWindow", - "chrome,width=600,height=600"); - -]]> -</script> - -</window> diff --git a/widget/tests/test_system_status_bar.xul b/widget/tests/test_system_status_bar.xul deleted file mode 100644 index 784620fc8..000000000 --- a/widget/tests/test_system_status_bar.xul +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Testing composition, text and query content events" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> - -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<menupopup id="menuContainer"> - <menu id="menu1" image="data:image/svg+xml,<svg%20xmlns="http://www.w3.org/2000/svg"%20width="32"%20height="32"><circle%20cx="16"%20cy="16"%20r="16"/></svg>"> - <menupopup> - <menuitem label="Item 1 in menu 1"/> - <menuitem label="Item 2 in menu 1"/> - </menupopup> - </menu> - <menu id="menu2" image="data:image/svg+xml,<svg%20xmlns="http://www.w3.org/2000/svg"%20width="32"%20height="32"><path%20d="M0 16 L 16 0 L 32 16 L 16 32 Z"/></svg>"> - <menupopup> - <menuitem label="Item 1 in menu 2"/> - <menuitem label="Item 2 in menu 2"/> - </menupopup> - </menu> -</menupopup> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - let Cc = Components.classes; - let Ci = Components.interfaces; - - let systemStatusBar = Cc["@mozilla.org/widget/macsystemstatusbar;1"].getService(Ci.nsISystemStatusBar); - ok(systemStatusBar, "should have got an nsISystemStatusBar instance"); - - let menu1 = document.getElementById("menu1"); - let menu2 = document.getElementById("menu2"); - - // Add and remove the item, just to get basic leak testing coverage. - systemStatusBar.addItem(menu1); - systemStatusBar.removeItem(menu1); - - // Make sure that calling addItem twice with the same element doesn't leak. - systemStatusBar.addItem(menu2); - systemStatusBar.addItem(menu2); - systemStatusBar.removeItem(menu2); - -]]> -</script> -</window> diff --git a/widget/tests/test_taskbar_progress.xul b/widget/tests/test_taskbar_progress.xul deleted file mode 100644 index e4ff533a0..000000000 --- a/widget/tests/test_taskbar_progress.xul +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Taskbar Previews Test" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onload="loaded();"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script class="testbody" type="application/javascript"> - <![CDATA[ - let Cc = Components.classes; - let Ci = Components.interfaces; - let Cu = Components.utils; - Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - - let TP = Ci.nsITaskbarProgress; - - function IsWin7OrHigher() { - try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); - var ver = parseFloat(sysInfo.getProperty("version")); - if (ver >= 6.1) - return true; - } catch (ex) { } - return false; - } - - function winProgress() { - let taskbar = Cc["@mozilla.org/windows-taskbar;1"]; - if (!taskbar) { - ok(false, "Taskbar service is always available"); - return null; - } - taskbar = taskbar.getService(Ci.nsIWinTaskbar); - - is(taskbar.available, IsWin7OrHigher(), "Expected availability of taskbar"); - if (!taskbar.available) - return null; - - // HACK from mconnor: - var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - let win = wm.getMostRecentWindow("navigator:browser"); - let docShell = win.document.docShell; - - let progress = taskbar.getTaskbarProgress(docShell); - isnot(progress, null, "Progress is not null"); - - try { - taskbar.getTaskbarProgress(null); - ok(false, "Got progress for null docshell"); - } catch (e) { - ok(true, "Cannot get progress for null docshell"); - } - - return progress; - } - - function macProgress() { - let progress = Cc["@mozilla.org/widget/macdocksupport;1"]; - if (!progress) { - ok(false, "Should have gotten Mac progress service."); - return null; - } - return progress.getService(TP); - } - - SimpleTest.waitForExplicitFinish(); - - function loaded() - { - let isWin = /Win/.test(navigator.platform); - let progress = isWin ? winProgress() : macProgress(); - if (!TP || !progress) { - SimpleTest.finish(); - return; - } - - function shouldThrow(s,c,m) { - try { - progress.setProgressState(s,c,m); - return false; - } catch (e) { - return true; - } - } - - function doesntThrow(s,c,m) { - return !shouldThrow(s,c,m); - } - - ok(doesntThrow(TP.STATE_NO_PROGRESS, 0, 0), "No progress state can be set"); - ok(doesntThrow(TP.STATE_INDETERMINATE, 0, 0), "Indeterminate state can be set"); - ok(doesntThrow(TP.STATE_NORMAL, 0, 0), "Normal state can be set"); - ok(doesntThrow(TP.STATE_ERROR, 0, 0), "Error state can be set"); - ok(doesntThrow(TP.STATE_PAUSED, 0, 0), "Paused state can be set"); - - ok(shouldThrow(TP.STATE_NO_PROGRESS, 1, 1), "Cannot set no progress with values"); - ok(shouldThrow(TP.STATE_INDETERMINATE, 1, 1), "Cannot set indeterminate with values"); - - // Technically passes since unsigned(-1) > 10 - ok(shouldThrow(TP.STATE_NORMAL, -1, 10), "Cannot set negative progress"); - todo(shouldThrow(TP.STATE_NORMAL, 1, -1), "Cannot set negative progress"); - todo(shouldThrow(TP.STATE_NORMAL, -1, -1), "Cannot set negative progress"); - todo(shouldThrow(TP.STATE_NORMAL, -2, -1), "Cannot set negative progress"); - - ok(shouldThrow(TP.STATE_NORMAL, 5, 3), "Cannot set progress greater than max"); - - ok(doesntThrow(TP.STATE_NORMAL, 1, 5), "Normal state can be set with values"); - ok(doesntThrow(TP.STATE_ERROR, 3, 6), "Error state can be set with values"); - ok(doesntThrow(TP.STATE_PAUSED, 2, 9), "Paused state can be set with values"); - - SimpleTest.finish(); - } - ]]> - </script> - - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> - -</window> diff --git a/widget/tests/test_wheeltransaction.xul b/widget/tests/test_wheeltransaction.xul deleted file mode 100644 index dadd46629..000000000 --- a/widget/tests/test_wheeltransaction.xul +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Wheel scroll transaction tests" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -SimpleTest.waitForExplicitFinish(); -window.open("window_wheeltransaction.xul", "_blank", - "chrome,width=600,height=600"); - -]]> -</script> -</window> diff --git a/widget/tests/unit/test_macwebapputils.js b/widget/tests/unit/test_macwebapputils.js deleted file mode 100644 index 0701bedf0..000000000 --- a/widget/tests/unit/test_macwebapputils.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//Basic tests to verify that MacWebAppUtils works - -var Ci = Components.interfaces; -var Cc = Components.classes; -var Cu = Components.utils; -var Cr = Components.results; - -Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -function test_find_app() -{ - var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. - createInstance(Ci.nsIMacWebAppUtils); - let sig = "com.apple.TextEdit"; - - let path; - path = mwaUtils.pathForAppWithIdentifier(sig); - do_print("TextEdit path: " + path + "\n"); - do_check_neq(path, ""); -} - -function test_dont_find_fake_app() -{ - var mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]. - createInstance(Ci.nsIMacWebAppUtils); - let sig = "calliope.penitentiary.dramamine"; - - let path; - path = mwaUtils.pathForAppWithIdentifier(sig); - do_check_eq(path, ""); -} - - -function run_test() -{ - test_find_app(); - test_dont_find_fake_app(); -} diff --git a/widget/tests/unit/test_taskbar_jumplistitems.js b/widget/tests/unit/test_taskbar_jumplistitems.js deleted file mode 100644 index d145683eb..000000000 --- a/widget/tests/unit/test_taskbar_jumplistitems.js +++ /dev/null @@ -1,261 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// This tests taskbar jump list functionality available on win7 and up. - -var Cc = Components.classes; -var Ci = Components.interfaces; - -function test_basics() -{ - var item = Cc["@mozilla.org/windows-jumplistitem;1"]. - createInstance(Ci.nsIJumpListItem); - - var sep = Cc["@mozilla.org/windows-jumplistseparator;1"]. - createInstance(Ci.nsIJumpListSeparator); - - var shortcut = Cc["@mozilla.org/windows-jumplistshortcut;1"]. - createInstance(Ci.nsIJumpListShortcut); - - var link = Cc["@mozilla.org/windows-jumplistlink;1"]. - createInstance(Ci.nsIJumpListLink); - - do_check_false(item.equals(sep)); - do_check_false(item.equals(shortcut)); - do_check_false(item.equals(link)); - - do_check_false(sep.equals(item)); - do_check_false(sep.equals(shortcut)); - do_check_false(sep.equals(link)); - - do_check_false(shortcut.equals(item)); - do_check_false(shortcut.equals(sep)); - do_check_false(shortcut.equals(link)); - - do_check_false(link.equals(item)); - do_check_false(link.equals(sep)); - do_check_false(link.equals(shortcut)); - - do_check_true(item.equals(item)); - do_check_true(sep.equals(sep)); - do_check_true(link.equals(link)); - do_check_true(shortcut.equals(shortcut)); -} - -function test_separator() -{ - // separators: - - var item = Cc["@mozilla.org/windows-jumplistseparator;1"]. - createInstance(Ci.nsIJumpListSeparator); - - do_check_true(item.type == Ci.nsIJumpListItem.JUMPLIST_ITEM_SEPARATOR); -} - -function test_hashes() -{ - var link = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); - var uri1 = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - var uri2 = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - - uri1.spec = "http://www.123.com/"; - uri2.spec = "http://www.123.com/"; - - link.uri = uri1; - - do_check_true(link.compareHash(uri2)) - uri2.spec = "http://www.456.com/"; - do_check_false(link.compareHash(uri2)) - uri2.spec = "http://www.123.com/"; - do_check_true(link.compareHash(uri2)) - uri2.spec = "https://www.123.com/"; - do_check_false(link.compareHash(uri2)) - uri2.spec = "http://www.123.com/test/"; - do_check_false(link.compareHash(uri2)) - uri1.spec = "http://www.123.com/test/"; - uri2.spec = "http://www.123.com/test/"; - do_check_true(link.compareHash(uri2)) - uri1.spec = "https://www.123.com/test/"; - uri2.spec = "https://www.123.com/test/"; - do_check_true(link.compareHash(uri2)) - uri2.spec = "ftp://www.123.com/test/"; - do_check_false(link.compareHash(uri2)) - uri2.spec = "http://123.com/test/"; - do_check_false(link.compareHash(uri2)) - uri1.spec = "https://www.123.com/test/"; - uri2.spec = "https://www.123.com/Test/"; - do_check_false(link.compareHash(uri2)) - - uri1.spec = "http://www.123.com/"; - do_check_eq(link.uriHash, "QGLmWuwuTozr3tOfXSf5mg=="); - uri1.spec = "http://www.123.com/test/"; - do_check_eq(link.uriHash, "AG87Ls+GmaUYSUJFETRr3Q=="); - uri1.spec = "https://www.123.com/"; - do_check_eq(link.uriHash, "iSx6UH1a9enVPzUA9JZ42g=="); - - var uri3 = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - link.uri = uri3; - do_check_eq(link.uriHash, "hTrpDwNRMkvXPqYV5kh1Fw=="); -} - -function test_links() -{ - // links: - var link1 = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); - var link2 = Cc["@mozilla.org/windows-jumplistlink;1"] - .createInstance(Ci.nsIJumpListLink); - - var uri1 = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - var uri2 = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - - uri1.spec = "http://www.test.com/"; - uri2.spec = "http://www.test.com/"; - - link1.uri = uri1; - link1.uriTitle = "Test"; - link2.uri = uri2; - link2.uriTitle = "Test"; - - do_check_true(link1.equals(link2)); - - link2.uriTitle = "Testing"; - - do_check_false(link1.equals(link2)); - - link2.uriTitle = "Test"; - uri2.spec = "http://www.testing.com/"; - - do_check_false(link1.equals(link2)); -} - -function test_shortcuts() -{ - // shortcuts: - var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] - .createInstance(Ci.nsIJumpListShortcut); - - var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] - .createInstance(Ci.nsILocalHandlerApp); - - handlerApp.name = "TestApp"; - handlerApp.detailedDescription = "TestApp detailed description."; - handlerApp.appendParameter("-test"); - - sc.iconIndex = 1; - do_check_eq(sc.iconIndex, 1); - - var faviconPageUri = Cc["@mozilla.org/network/simple-uri;1"] - .createInstance(Ci.nsIURI); - faviconPageUri.spec = "http://www.123.com/"; - sc.faviconPageUri = faviconPageUri; - do_check_eq(sc.faviconPageUri, faviconPageUri); - - var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - QueryInterface(Ci.nsIDirectoryService); - var notepad = dirSvc.get("WinD", Ci.nsIFile); - notepad.append("notepad.exe"); - if (notepad.exists()) { - handlerApp.executable = notepad; - sc.app = handlerApp; - do_check_eq(sc.app.detailedDescription, "TestApp detailed description."); - do_check_eq(sc.app.name, "TestApp"); - do_check_true(sc.app.parameterExists("-test")); - do_check_false(sc.app.parameterExists("-notset")); - } -} - -function test_jumplist() -{ - // Jump lists can't register links unless the application is the default - // protocol handler for the protocol of the link, so we skip off testing - // those in these tests. We'll init the jump list for the xpc shell harness, - // add a task item, and commit it. - - // not compiled in - if (Ci.nsIWinTaskbar == null) - return; - - var taskbar = Cc["@mozilla.org/windows-taskbar;1"] - .getService(Ci.nsIWinTaskbar); - - var builder = taskbar.createJumpListBuilder(); - - do_check_neq(builder, null); - - // Win7 and up only - try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); - var ver = parseFloat(sysInfo.getProperty("version")); - if (ver < 6.1) { - do_check_false(builder.available, false); - return; - } - } catch (ex) { } - - do_check_true(taskbar.available); - - builder.deleteActiveList(); - - var items = Cc["@mozilla.org/array;1"] - .createInstance(Ci.nsIMutableArray); - - var sc = Cc["@mozilla.org/windows-jumplistshortcut;1"] - .createInstance(Ci.nsIJumpListShortcut); - - var handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"] - .createInstance(Ci.nsILocalHandlerApp); - - handlerApp.name = "Notepad"; - handlerApp.detailedDescription = "Testing detailed description."; - - var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties). - QueryInterface(Ci.nsIDirectoryService); - var notepad = dirSvc.get("WinD", Ci.nsIFile); - notepad.append("notepad.exe"); - if (notepad.exists()) { - handlerApp.executable = notepad; - sc.app = handlerApp; - items.appendElement(sc, false); - - var removed = Cc["@mozilla.org/array;1"] - .createInstance(Ci.nsIMutableArray); - do_check_true(builder.initListBuild(removed)); - do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_TASKS, items)); - do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_RECENT)); - do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_FREQUENT)); - do_check_true(builder.commitListBuild()); - - builder.deleteActiveList(); - - do_check_true(builder.initListBuild(removed)); - do_check_true(builder.addListToBuild(builder.JUMPLIST_CATEGORY_CUSTOM, items, "Custom List")); - do_check_true(builder.commitListBuild()); - - builder.deleteActiveList(); - } -} - -function run_test() -{ - if (mozinfo.os != "win") { - return; - } - test_basics(); - test_separator(); - test_hashes(); - test_links(); - test_shortcuts(); - test_jumplist(); -} diff --git a/widget/tests/unit/xpcshell.ini b/widget/tests/unit/xpcshell.ini deleted file mode 100644 index d0e8f8701..000000000 --- a/widget/tests/unit/xpcshell.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -head = -tail = - -[test_taskbar_jumplistitems.js] -[test_macwebapputils.js] -skip-if = os != "mac" diff --git a/widget/tests/utils.js b/widget/tests/utils.js deleted file mode 100644 index 3796c7d2b..000000000 --- a/widget/tests/utils.js +++ /dev/null @@ -1,27 +0,0 @@ - -function getTestPlugin(pluginName) { - var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] - .getService(SpecialPowers.Ci.nsIPluginHost); - var tags = ph.getPluginTags(); - var name = pluginName || "Test Plug-in"; - for (var tag of tags) { - if (tag.name == name) { - return tag; - } - } - - ok(false, "Could not find plugin tag with plugin name '" + name + "'"); - return null; -} - -// call this to set the test plugin(s) initially expected enabled state. -// it will automatically be reset to it's previous value after the test -// ends -function setTestPluginEnabledState(newEnabledState, pluginName) { - var plugin = getTestPlugin(pluginName); - var oldEnabledState = plugin.enabledState; - plugin.enabledState = newEnabledState; - SimpleTest.registerCleanupFunction(function() { - getTestPlugin(pluginName).enabledState = oldEnabledState; - }); -} diff --git a/widget/tests/window_bug429954.xul b/widget/tests/window_bug429954.xul deleted file mode 100644 index 6604e91b4..000000000 --- a/widget/tests/window_bug429954.xul +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Mozilla Bug 478536" - onload="start();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml" id="body"> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -function start() { - var oldWidth = window.outerWidth, oldHeight = window.outerHeight; - window.maximize(); - window.restore(); - is(window.outerWidth, oldWidth, "wrong window width after maximize+restore"); - is(window.outerHeight, oldHeight, "wrong window height after maximize+restore"); - window.opener.wrappedJSObject.SimpleTest.finish(); - window.close(); -} - - -]]> -</script> - -</window> diff --git a/widget/tests/window_bug478536.xul b/widget/tests/window_bug478536.xul deleted file mode 100644 index 0a07777b4..000000000 --- a/widget/tests/window_bug478536.xul +++ /dev/null @@ -1,215 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Mozilla Bug 478536" - width="600" height="600" - onload="onload();" - onunload="onunload();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml" id="body"> -<style type="text/css"> - #view { - overflow: auto; - width: 100px; - height: 100px; - border: 1px solid; - margin: 0; - } -</style> -<pre id="view" onscroll="onScrollView(event);"> -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -var gBody = document.getElementById("body"); -var gView = document.getElementById("view"); - -/** - * Description: - * - * First, lock the wheel scrolling target to "view" at first step. - * Next, scroll back to top most of the "view" at second step. - * Finally, scroll back again at third step. This fails to scroll the "view", - * then, |onMouseScrollFailed| event should be fired. And at that time, we - * can remove the "view". So, in post processing of the event firere, the - * "view" should not be referred. - * - * For suppressing random test failure, all tests will be retried if we handle - * unexpected timeout event. - */ - -var gTests = [ - { scrollToForward: true, shouldScroll: true }, - { scrollToForward: false, shouldScroll: true }, - { scrollToForward: false, shouldScroll: false } -]; -var gCurrentTestIndex = -1; -var gIgnoreScrollEvent = true; - -var gPrefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); -const kPrefSmoothScroll = "general.smoothScroll"; -const kPrefNameTimeout = "mousewheel.transaction.timeout"; -const kDefaultTimeout = gPrefSvc.getIntPref(kPrefNameTimeout); - -gPrefSvc.setBoolPref(kPrefSmoothScroll, false); - -var gTimeout = kDefaultTimeout; - -gBody.addEventListener("MozMouseScrollFailed", onMouseScrollFailed, false); -gBody.addEventListener("MozMouseScrollTransactionTimeout", - onTransactionTimeout, false); - -function setTimeoutPrefs(aTimeout) -{ - gPrefSvc.setIntPref(kPrefNameTimeout, aTimeout); - gTimeout = aTimeout; -} - -function resetTimeoutPrefs() -{ - if (gTimeout == kDefaultTimeout) - return; - setTimeoutPrefs(kDefaultTimeout); -} - -function growUpTimeoutPrefs() -{ - if (gTimeout != kDefaultTimeout) - return; - setTimeoutPrefs(5000); -} - -function onload() -{ - disableNonTestMouseEvents(true); - setTimeout(runNextTest, 0); -} - -function onunload() -{ - resetTimeoutPrefs(); - disableNonTestMouseEvents(false); - gPrefSvc.clearUserPref(kPrefSmoothScroll); - SpecialPowers.DOMWindowUtils.restoreNormalRefresh(); - window.opener.wrappedJSObject.SimpleTest.finish(); -} - -function finish() -{ - window.close(); -} - -// testing code - -var gTimer; -function clearTimer() -{ - clearTimeout(gTimer); - gTimer = 0; -} - -function runNextTest() -{ - clearTimer(); - if (++gCurrentTestIndex >= gTests.length) { - ok(true, "didn't crash, succeeded"); - finish(); - return; - } - fireWheelScrollEvent(gTests[gCurrentTestIndex].scrollToForward); -} - -var gRetryCount = 5; -function retryAllTests() -{ - clearTimer(); - if (--gRetryCount >= 0) { - gView.scrollTop = 0; - gView.scrollLeft = 0; - gCurrentTestIndex = -1; - growUpTimeoutPrefs(); - ok(true, "WARNING: retry current test-list..."); - gTimer = setTimeout(runNextTest, 0); - } else { - ok(false, "Failed by unexpected timeout"); - finish(); - } -} - -function fireWheelScrollEvent(aForward) -{ - gIgnoreScrollEvent = false; - var event = { deltaY: aForward ? 4.0 : -4.0, - deltaMode: WheelEvent.DOM_DELTA_LINE }; - sendWheelAndPaint(gView, 5, 5, event, function() { - // No callback - we're just forcing the refresh driver to tick. - }, window); -} - -function onScrollView(aEvent) -{ - if (gIgnoreScrollEvent) - return; - gIgnoreScrollEvent = true; - clearTimer(); - ok(gTests[gCurrentTestIndex].shouldScroll, "The view is scrolled"); - gTimer = setTimeout(runNextTest, 0); -} - -function onMouseScrollFailed(aEvent) -{ - clearTimer(); - gIgnoreScrollEvent = true; - ok(!gTests[gCurrentTestIndex].shouldScroll, "The view is not scrolled"); - if (!gTests[gCurrentTestIndex].shouldScroll) - gBody.removeChild(gView); - runNextTest(); -} - -function onTransactionTimeout(aEvent) -{ - if (!gTimer) - return; - gIgnoreScrollEvent = true; - retryAllTests(); -} - -]]> -</script> - -</window> diff --git a/widget/tests/window_bug522217.xul b/widget/tests/window_bug522217.xul deleted file mode 100644 index 8fbb21037..000000000 --- a/widget/tests/window_bug522217.xul +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Mozilla Bug 522217" - onload="start();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml" id="body"> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -function executeSoon(aFct) -{ - window.opener.wrappedJSObject.SimpleTest.executeSoon(aFct); -} - -function start() { - window.onfocus = function () { - window.onfocus = null; - var oldOuterWidth = window.outerWidth, oldOuterHeight = window.outerHeight; - var oldInnerWidth = window.innerWidth, oldInnerHeight = window.innerHeight; - document.documentElement.setAttribute("drawintitlebar", "true"); - - executeSoon(function() { - is(window.outerWidth, oldOuterWidth, "drawintitlebar shouldn't change the window's outerWidth"); - is(window.outerHeight, oldOuterHeight, "drawintitlebar shouldn't change the window's outerHeight"); - is(window.innerWidth, oldOuterWidth, "if drawintitlebar is set, innerWidth and outerWidth should be the same"); - is(window.innerHeight, oldOuterHeight, "if drawintitlebar is set, innerHeight and outerHeight should be the same"); - window.fullScreen = true; - window.fullScreen = false; - is(window.outerWidth, oldOuterWidth, "wrong outerWidth after fullscreen mode"); - is(window.outerHeight, oldOuterHeight, "wrong outerHeight after fullscreen mode"); - is(window.innerWidth, oldOuterWidth, "wrong innerWidth after fullscreen mode"); - is(window.innerHeight, oldOuterHeight, "wrong innerHeight after fullscreen mode"); - document.documentElement.removeAttribute("drawintitlebar"); - - executeSoon(function() { - is(window.outerWidth, oldOuterWidth, "wrong outerWidth after removing drawintitlebar"); - is(window.outerHeight, oldOuterHeight, "wrong outerHeight after removing drawintitlebar"); - is(window.innerWidth, oldInnerWidth, "wrong innerWidth after removing drawintitlebar"); - is(window.innerHeight, oldInnerHeight, "wrong innerHeight after removing drawintitlebar"); - window.opener.wrappedJSObject.SimpleTest.finish(); - window.close(); - }); - }); - } -} - - -]]> -</script> - -</window> diff --git a/widget/tests/window_bug538242.xul b/widget/tests/window_bug538242.xul deleted file mode 100644 index fb878b138..000000000 --- a/widget/tests/window_bug538242.xul +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0"?> -<window title="Window for Test for Mozilla Bug 538242" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/> diff --git a/widget/tests/window_bug593307_centerscreen.xul b/widget/tests/window_bug593307_centerscreen.xul deleted file mode 100644 index 24d708760..000000000 --- a/widget/tests/window_bug593307_centerscreen.xul +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Mozilla Bug 593307" - width="100" height="100" - onload="onload();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml" id="body"> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -function onload() -{ - var SimpleTest = window.opener.SimpleTest; - SimpleTest.ok(window.screenX >= 0, "centerscreen window should not start offscreen (X coordinate)"); - SimpleTest.ok(window.screenY >= 0, "centerscreen window should not start offscreen (Y coordinate)"); - window.opener.finished(); -} -]]> -</script> - -</window> diff --git a/widget/tests/window_bug593307_offscreen.xul b/widget/tests/window_bug593307_offscreen.xul deleted file mode 100644 index 0857c73a6..000000000 --- a/widget/tests/window_bug593307_offscreen.xul +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Mozilla Bug 593307" - width="100" height="100" - onload="onLoad();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml" id="body"> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -var centerscreen = null; -var SimpleTest = window.arguments[0]; -var finish = window.arguments[1]; - -function onLoad() -{ - centerscreen = window.openDialog('window_bug593307_centerscreen.xul','', 'chrome,centerscreen,dependent,dialog=no'); -} - -function finished() { - centerscreen.close(); - finish(); -} - -]]> -</script> - -</window> diff --git a/widget/tests/window_composition_text_querycontent.xul b/widget/tests/window_composition_text_querycontent.xul deleted file mode 100644 index a5b9e2655..000000000 --- a/widget/tests/window_composition_text_querycontent.xul +++ /dev/null @@ -1,6992 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" - type="text/css"?> -<window title="Testing composition, text and query content events" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - onunload="onunload();"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - - <panel id="panel" hidden="true" - orient="vertical" - onpopupshown="onPanelShown(event);" - onpopuphidden="onPanelHidden(event);"> - <vbox id="vbox"> - <textbox id="textbox" onfocus="onFocusPanelTextbox(event);" - multiline="true" cols="20" rows="4" style="font-size: 36px;"/> - </vbox> - </panel> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<p id="display"> -<div id="div" style="margin: 0; padding: 0; font-size: 36px;">Here is a text frame.</div> -<textarea style="margin: 0;" id="textarea" cols="20" rows="4"></textarea><br/> -<iframe id="iframe" width="300" height="150" - src="data:text/html,<textarea id='textarea' cols='20' rows='4'></textarea>"></iframe><br/> -<iframe id="iframe2" width="300" height="150" - src="data:text/html,<body onload='document.designMode=%22on%22'>body content</body>"></iframe><br/> -<iframe id="iframe3" width="300" height="150" - src="data:text/html,<body onload='document.designMode=%22on%22'>body content</body>"></iframe><br/> -<iframe id="iframe4" width="300" height="150" - src="data:text/html,<div contenteditable id='contenteditable'></div>"></iframe><br/> -<input id="input" type="text"/><br/> -</p> -<div id="content" style="display: none"> - -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTest, window); - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -function isSimilarTo(aLeft, aRight, aAllowedDifference, aMessage) -{ - if (Math.abs(aLeft - aRight) <= aAllowedDifference) { - ok(true, aMessage); - } else { - ok(false, aMessage + ", got=" + aLeft + ", expected=" + (aRight - aAllowedDifference) + "~" + (aRight + aAllowedDifference)); - } -} - -function isGreaterThan(aLeft, aRight, aMessage) -{ - ok(aLeft > aRight, aMessage + ", got=" + aLeft + ", expected minimum value=" + aRight); -} - -function finish() -{ - window.close(); -} - -function onunload() -{ - window.opener.wrappedJSObject.SimpleTest.finish(); -} - -var div = document.getElementById("div"); -var textarea = document.getElementById("textarea"); -var panel = document.getElementById("panel"); -var textbox = document.getElementById("textbox"); -var iframe = document.getElementById("iframe"); -var iframe2 = document.getElementById("iframe2"); -var iframe3 = document.getElementById("iframe3"); -var contenteditable; -var windowOfContenteditable; -var input = document.getElementById("input"); -var textareaInFrame; - -const nsITextInputProcessorCallback = Components.interfaces.nsITextInputProcessorCallback; -const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement; -const nsIEditorIMESupport = Components.interfaces.nsIEditorIMESupport; -const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor; -const nsIWebNavigation = Components.interfaces.nsIWebNavigation; -const nsIDocShell = Components.interfaces.nsIDocShell; - -function hitEventLoop(aFunc, aTimes) -{ - if (--aTimes) { - setTimeout(hitEventLoop, 0, aFunc, aTimes); - } else { - setTimeout(aFunc, 20); - } -} - -function getEditorIMESupport(aNode) -{ - return aNode.QueryInterface(nsIDOMNSEditableElement). - editor. - QueryInterface(nsIEditorIMESupport); -} - -function getHTMLEditorIMESupport(aWindow) -{ - return aWindow.QueryInterface(nsIInterfaceRequestor). - getInterface(nsIWebNavigation). - QueryInterface(nsIDocShell). - editor; -} - -const kIsWin = (navigator.platform.indexOf("Win") == 0); -const kIsMac = (navigator.platform.indexOf("Mac") == 0); - -const kLFLen = kIsWin ? 2 : 1; -const kLF = kIsWin ? "\r\n" : "\n"; - -function checkQueryContentResult(aResult, aMessage) -{ - ok(aResult, aMessage + ": the result is null"); - if (!aResult) { - return false; - } - ok(aResult.succeeded, aMessage + ": the query content failed"); - return aResult.succeeded; -} - -function checkContent(aExpectedText, aMessage, aID) -{ - if (!aID) { - aID = ""; - } - var textContent = synthesizeQueryTextContent(0, 100); - if (!checkQueryContentResult(textContent, aMessage + - ": synthesizeQueryTextContent " + aID)) { - return false; - } - is(textContent.text, aExpectedText, - aMessage + ": composition string is wrong " + aID); - return textContent.text == aExpectedText; -} - -function checkContentRelativeToSelection(aRelativeOffset, aLength, aExpectedOffset, aExpectedText, aMessage, aID) -{ - if (!aID) { - aID = ""; - } - aMessage += " (aRelativeOffset=" + aRelativeOffset + "): " - var textContent = synthesizeQueryTextContent(aRelativeOffset, aLength, true); - if (!checkQueryContentResult(textContent, aMessage + - "synthesizeQueryTextContent " + aID)) { - return false; - } - is(textContent.offset, aExpectedOffset, - aMessage + "offset is wrong " + aID); - is(textContent.text, aExpectedText, - aMessage + "text is wrong " + aID); - return textContent.offset == aExpectedOffset && - textContent.text == aExpectedText; -} - -function checkSelection(aExpectedOffset, aExpectedText, aMessage, aID) -{ - if (!aID) { - aID = ""; - } - var selectedText = synthesizeQuerySelectedText(); - if (!checkQueryContentResult(selectedText, aMessage + - ": synthesizeQuerySelectedText " + aID)) { - return false; - } - is(selectedText.offset, aExpectedOffset, - aMessage + ": selection offset is wrong " + aID); - is(selectedText.text, aExpectedText, - aMessage + ": selected text is wrong " + aID); - return selectedText.offset == aExpectedOffset && - selectedText.text == aExpectedText; -} - -function checkIMESelection(aSelectionType, aExpectedFound, aExpectedOffset, aExpectedText, aMessage, aID) -{ - if (!aID) { - aID = ""; - } - aMessage += " (" + aSelectionType + ")"; - var selectionType = 0; - switch (aSelectionType) { - case "RawClause": - selectionType = QUERY_CONTENT_FLAG_SELECTION_IME_RAWINPUT; - break; - case "SelectedRawClause": - selectionType = QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDRAWTEXT; - break; - case "ConvertedClause": - selectionType = QUERY_CONTENT_FLAG_SELECTION_IME_CONVERTEDTEXT; - break; - case "SelectedClause": - selectionType = QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDCONVERTEDTEXT; - break; - default: - ok(false, aMessage + ": invalid selection type, " + aSelectionType); - } - isnot(selectionType, 0, aMessage + ": wrong value"); - var selectedText = synthesizeQuerySelectedText(selectionType); - if (!checkQueryContentResult(selectedText, aMessage + - ": synthesizeQuerySelectedText " + aID)) { - return false; - } - is(selectedText.notFound, !aExpectedFound, - aMessage + ": selection should " + (aExpectedFound ? "" : "not") + " be found " + aID); - if (selectedText.notFound) { - return selectedText.notFound == !aExpectedFound; - } - - is(selectedText.offset, aExpectedOffset, - aMessage + ": selection offset is wrong " + aID); - is(selectedText.text, aExpectedText, - aMessage + ": selected text is wrong " + aID); - return selectedText.offset == aExpectedOffset && - selectedText.text == aExpectedText; -} - -function checkRect(aRect, aExpectedRect, aMessage) -{ - is(aRect.left, aExpectedRect.left, aMessage + ": left is wrong"); - is(aRect.top, aExpectedRect.top, aMessage + " top is wrong"); - is(aRect.width, aExpectedRect.width, aMessage + ": width is wrong"); - is(aRect.height, aExpectedRect.height, aMessage + ": height is wrong"); - return aRect.left == aExpectedRect.left && - aRect.top == aExpectedRect.top && - aRect.width == aExpectedRect.width && - aRect.height == aExpectedRect.height; -} - -function checkRectArray(aQueryTextRectArrayResult, aExpectedTextRectArray, aMessage) -{ - for (var i = 1; i < aExpectedTextRectArray.length; ++i) { - var rect = { left: {}, top: {}, width: {}, height: {} }; - try { - aQueryTextRectArrayResult.getCharacterRect(i, rect.left, rect.top, rect.width, rect.height); - } catch (e) { - ok(false, aMessage + ": failed to retrieve " + i + "th rect (" + e + ")"); - return false; - } - function toRect(aRect) - { - return { left: aRect.left.value, top: aRect.top.value, width: aRect.width.value, height: aRect.height.value }; - } - if (!checkRect(toRect(rect), aExpectedTextRectArray[i], aMessage + " " + i + "th rect")) { - return false; - } - } - return true; -} - -function checkRectContainsRect(aRect, aContainer, aMessage) -{ - var container = { left: Math.ceil(aContainer.left), - top: Math.ceil(aContainer.top), - width: Math.floor(aContainer.width), - height: Math.floor(aContainer.height) }; - - var ret = container.left <= aRect.left && - container.top <= aRect.top && - container.left + container.width >= aRect.left + aRect.width && - container.top + container.height >= aRect.top + aRect.height; - ret = ret && aMessage; - ok(ret, aMessage + " container={ left=" + container.left + ", top=" + - container.top + ", width=" + container.width + ", height=" + - container.height + " } rect={ left=" + aRect.left + ", top=" + aRect.top + - ", width=" + aRect.width + ", height=" + aRect.height + " }"); - return ret; -} - -function runUndoRedoTest() -{ - textarea.value = ""; - textarea.focus(); - - // input raw characters - synthesizeCompositionChange( - { "composition": - { "string": "\u306D", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u306D\u3053", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - // convert - synthesizeCompositionChange( - { "composition": - { "string": "\u732B", - "clauses": - [ - { "length": 1, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - // commit - synthesizeComposition({ type: "compositioncommitasis" }); - - // input raw characters - synthesizeCompositionChange( - { "composition": - { "string": "\u307E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - // cancel the composition - synthesizeComposition({ type: "compositioncommit", data: "" }); - - // input raw characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3080", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3080\u3059", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3080\u3059\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - // convert - synthesizeCompositionChange( - { "composition": - { "string": "\u5A18", - "clauses": - [ - { "length": 1, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - // commit - synthesizeComposition({ type: "compositioncommitasis" }); - - synthesizeKey(" ", {}); - synthesizeKey("m", {}); - synthesizeKey("e", {}); - synthesizeKey("a", {}); - synthesizeKey("n", {}); - synthesizeKey("t", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("s", {}); - synthesizeKey(" ", {}); - synthesizeKey("\"", {}); - synthesizeKey("c", {}); - synthesizeKey("a", {}); - synthesizeKey("t", {}); - synthesizeKey("-", {}); - synthesizeKey("g", {}); - synthesizeKey("i", {}); - synthesizeKey("r", {}); - synthesizeKey("l", {}); - synthesizeKey("\"", {}); - synthesizeKey(".", {}); - synthesizeKey(" ", {}); - synthesizeKey("VK_SHIFT", { type: "keydown" }); - synthesizeKey("S", { shiftKey: true }); - synthesizeKey("VK_SHIFT", { type: "keyup" }); - synthesizeKey("h", {}); - synthesizeKey("e", {}); - synthesizeKey(" ", {}); - synthesizeKey("i", {}); - synthesizeKey("s", {}); - synthesizeKey(" ", {}); - synthesizeKey("a", {}); - synthesizeKey(" ", {}); - - // input raw characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3088", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3088\u3046", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3088\u3046\u304b", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3088\u3046\u304b\u3044", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - // convert - synthesizeCompositionChange( - { "composition": - { "string": "\u5996\u602a", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - // commit - synthesizeComposition({ type: "compositioncommitasis" }); - - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - - var i = 0; - if (!checkContent("\u732B\u5A18 means \"cat-girl\".", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(20, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a \u5996\u602A", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(32, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a ", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(30, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B\u5A18 mean", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(7, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B\u5A18 meant", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(8, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B\u5A18", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(2, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("\u732B", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(1, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - // XXX this is unexpected behavior, see bug 258291 - if (!checkContent("\u732B", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(1, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(0, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true}); - - if (!checkContent("", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(0, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(1, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - // XXX this is unexpected behavior, see bug 258291 - if (!checkContent("\u732B", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(1, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(2, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 meant", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(8, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 mean", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(7, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a ", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(30, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\". She is a \u5996\u602A", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(32, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\".", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(20, "", "runUndoRedoTest", "#" + i)) { - return; - } - - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - - if (!checkContent("\u732B\u5A18 means \"cat-girl\".", - "runUndoRedoTest", "#" + ++i) || - !checkSelection(20, "", "runUndoRedoTest", "#" + i)) { - return; - } -} - -function runCompositionCommitAsIsTest() -{ - textarea.focus(); - - var result = {}; - function clearResult() - { - result = { compositionupdate: false, compositionend: false, text: false, input: false } - } - - function handler(aEvent) - { - result[aEvent.type] = true; - } - - textarea.addEventListener("compositionupdate", handler, true); - textarea.addEventListener("compositionend", handler, true); - textarea.addEventListener("input", handler, true); - textarea.addEventListener("text", handler, true); - - // compositioncommitasis with composing string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have composition string #1"); - - clearResult(); - synthesizeComposition({ type: "compositioncommitasis" }); - - is(result.compositionupdate, false, "runCompositionCommitAsIsTest: compositionupdate shouldn't be fired after dispatching compositioncommitasis #1"); - is(result.compositionend, true, "runCompositionCommitAsIsTest: compositionend should be fired after dispatching compositioncommitasis #1"); - is(result.text, true, "runCompositionCommitAsIsTest: text should be fired after dispatching compositioncommitasis because it's dispatched when there is composing string #1"); - is(result.input, true, "runCompositionCommitAsIsTest: input should be fired after dispatching compositioncommitasis #1"); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have committed string #1"); - - // compositioncommitasis with committed string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have composition string #2"); - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have committed string #2"); - - clearResult(); - synthesizeComposition({ type: "compositioncommitasis" }); - - is(result.compositionupdate, false, "runCompositionCommitAsIsTest: compositionupdate shouldn't be fired after dispatching compositioncommitasis #2"); - is(result.compositionend, true, "runCompositionCommitAsIsTest: compositionend should be fired after dispatching compositioncommitasis #2"); - is(result.text, false, "runCompositionCommitAsIsTest: text shouldn't be fired after dispatching compositioncommitasis because it's dispatched when there is already committed string #2"); - is(result.input, true, "runCompositionCommitAsIsTest: input should be fired after dispatching compositioncommitasis #2"); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have committed string #2"); - - // compositioncommitasis with committed string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitAsIsTest: textarea doesn't have composition string #3"); - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - is(textarea.value, "", "runCompositionCommitAsIsTest: textarea has non-empty composition string #3"); - - clearResult(); - synthesizeComposition({ type: "compositioncommitasis" }); - - is(result.compositionupdate, false, "runCompositionCommitAsIsTest: compositionupdate shouldn't be fired after dispatching compositioncommitasis #3"); - is(result.compositionend, true, "runCompositionCommitAsIsTest: compositionend should be fired after dispatching compositioncommitasis #3"); - is(result.text, false, "runCompositionCommitAsIsTest: text shouldn't be fired after dispatching compositioncommitasis because it's dispatched when there is empty composition string #3"); - is(result.input, true, "runCompositionCommitAsIsTest: input should be fired after dispatching compositioncommitasis #3"); - is(textarea.value, "", "runCompositionCommitAsIsTest: textarea doesn't have committed string #3"); - - textarea.removeEventListener("compositionupdate", handler, true); - textarea.removeEventListener("compositionend", handler, true); - textarea.removeEventListener("input", handler, true); - textarea.removeEventListener("text", handler, true); -} - -function runCompositionCommitTest() -{ - textarea.focus(); - - var result = {}; - function clearResult() - { - result = { compositionupdate: false, compositionend: false, text: false, input: false } - } - - function handler(aEvent) - { - result[aEvent.type] = true; - } - - textarea.addEventListener("compositionupdate", handler, true); - textarea.addEventListener("compositionend", handler, true); - textarea.addEventListener("input", handler, true); - textarea.addEventListener("text", handler, true); - - // compositioncommit with different composing string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #1"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3043" }); - - is(result.compositionupdate, true, "runCompositionCommitTest: compositionupdate should be fired after dispatching compositioncommit #1"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #1"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit because it's dispatched when there is compoing string #1"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #1"); - is(textarea.value, "\u3043", "runCompositionCommitTest: textarea doesn't have committed string #1"); - - // compositioncommit with different committed string when there is already committed string - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #2"); - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have committed string #2"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3043" }); - - is(result.compositionupdate, true, "runCompositionCommitTest: compositionupdate should be fired after dispatching compositioncommit #2"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #2"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit #2"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #2"); - is(textarea.value, "\u3043", "runCompositionCommitTest: textarea doesn't have committed string #2"); - - // compositioncommit with empty composition string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #3"); - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - is(textarea.value, "", "runCompositionCommitTest: textarea has non-empty composition string #3"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3043" }); - - is(result.compositionupdate, true, "runCompositionCommitTest: compositionupdate should be fired after dispatching compositioncommit #3"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #3"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit #3"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #3"); - is(textarea.value, "\u3043", "runCompositionCommitTest: textarea doesn't have committed string #3"); - - // compositioncommit with non-empty composition string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #4"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "" }); - - is(result.compositionupdate, true, "runCompositionCommitTest: compositionupdate should be fired after dispatching compositioncommit #4"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #4"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit #4"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #4"); - is(textarea.value, "", "runCompositionCommitTest: textarea should be empty #4"); - - // compositioncommit immediately without compositionstart - textarea.value = ""; - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3042" }); - - is(result.compositionupdate, true, "runCompositionCommitTest: compositionupdate should be fired after dispatching compositioncommit #5"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #5"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit #5"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #5"); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea should be empty #5"); - - // compositioncommit with same composition string. - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #5"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3042" }); - - is(result.compositionupdate, false, "runCompositionCommitTest: compositionupdate shouldn't be fired after dispatching compositioncommit #5"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #5"); - is(result.text, true, "runCompositionCommitTest: text should be fired after dispatching compositioncommit because there was composition string #5"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #5"); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea should have committed string #5"); - - // compositioncommit with same composition string when there is committed string - textarea.value = ""; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #6"); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea doesn't have composition string #6"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "\u3042" }); - - is(result.compositionupdate, false, "runCompositionCommitTest: compositionupdate shouldn't be fired after dispatching compositioncommit #6"); - is(result.compositionend, true, "runCompositionCommitTest: compositionend should be fired after dispatching compositioncommit #6"); - is(result.text, false, "runCompositionCommitTest: text shouldn't be fired after dispatching compositioncommit because there was already committed string #6"); - is(result.input, true, "runCompositionCommitTest: input should be fired after dispatching compositioncommit #6"); - is(textarea.value, "\u3042", "runCompositionCommitTest: textarea should have committed string #6"); - - textarea.removeEventListener("compositionupdate", handler, true); - textarea.removeEventListener("compositionend", handler, true); - textarea.removeEventListener("input", handler, true); - textarea.removeEventListener("text", handler, true); -} - -function runCompositionTest() -{ - textarea.value = ""; - textarea.focus(); - var caretRects = []; - - var caretRect = synthesizeQueryCaretRect(0); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #0")) { - return false; - } - caretRects[0] = caretRect; - - // input first character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u3089", "runCompositionTest", "#1-1") || - !checkSelection(1, "", "runCompositionTest", "#1-1")) { - return; - } - - caretRect = synthesizeQueryCaretRect(1); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #1-1")) { - return false; - } - caretRects[1] = caretRect; - - // input second character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC", "runCompositionTest", "#1-2") || - !checkSelection(2, "", "runCompositionTest", "#1-2")) { - return; - } - - caretRect = synthesizeQueryCaretRect(2); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #1-2")) { - return false; - } - caretRects[2] = caretRect; - - isnot(caretRects[2].left, caretRects[1].left, - "runCompositionTest: caret isn't moved (#1-2)"); - is(caretRects[2].top, caretRects[1].top, - "runCompositionTest: caret is moved to another line (#1-2)"); - is(caretRects[2].width, caretRects[1].width, - "runCompositionTest: caret width is wrong (#1-2)"); - is(caretRects[2].height, caretRects[1].height, - "runCompositionTest: caret width is wrong (#1-2)"); - - // input third character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3") || - !checkSelection(3, "", "runCompositionTest", "#1-3")) { - return; - } - - caretRect = synthesizeQueryCaretRect(3); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #1-3")) { - return false; - } - caretRects[3] = caretRect; - - isnot(caretRects[3].left, caretRects[2].left, - "runCompositionTest: caret isn't moved (#1-3)"); - is(caretRects[3].top, caretRects[2].top, - "runCompositionTest: caret is moved to another line (#1-3)"); - is(caretRects[3].width, caretRects[2].width, - "runCompositionTest: caret width is wrong (#1-3)"); - is(caretRects[3].height, caretRects[2].height, - "runCompositionTest: caret height is wrong (#1-3)"); - - // moves the caret left - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3-1") || - !checkSelection(2, "", "runCompositionTest", "#1-3-1")) { - return; - } - - - caretRect = synthesizeQueryCaretRect(2); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #1-3-1")) { - return false; - } - - is(caretRect.left, caretRects[2].left, - "runCompositionTest: caret rects are different (#1-3-1, left)"); - is(caretRect.top, caretRects[2].top, - "runCompositionTest: caret rects are different (#1-3-1, top)"); - // by bug 335359, the caret width depends on the right side's character. - is(caretRect.width, caretRects[2].width + 1, - "runCompositionTest: caret rects are different (#1-3-1, width)"); - is(caretRect.height, caretRects[2].height, - "runCompositionTest: caret rects are different (#1-3-1, height)"); - - // moves the caret left - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-3-2") || - !checkSelection(1, "", "runCompositionTest", "#1-3-2")) { - return; - } - - - caretRect = synthesizeQueryCaretRect(1); - if (!checkQueryContentResult(caretRect, - "runCompositionTest: synthesizeQueryCaretRect #1-3-2")) { - return false; - } - - is(caretRect.left, caretRects[1].left, - "runCompositionTest: caret rects are different (#1-3-2, left)"); - is(caretRect.top, caretRects[1].top, - "runCompositionTest: caret rects are different (#1-3-2, top)"); - // by bug 335359, the caret width depends on the right side's character. - is(caretRect.width, caretRects[1].width + 1, - "runCompositionTest: caret rects are different (#1-3-2, width)"); - is(caretRect.height, caretRects[1].height, - "runCompositionTest: caret rects are different (#1-3-2, height)"); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093", "runCompositionTest", "#1-4") || - !checkSelection(4, "", "runCompositionTest", "#1-4")) { - return; - } - - - // backspace - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", "runCompositionTest", "#1-5") || - !checkSelection(3, "", "runCompositionTest", "#1-5")) { - return; - } - - // re-input - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093", "runCompositionTest", "#1-6") || - !checkSelection(4, "", "runCompositionTest", "#1-6")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055", - "clauses": - [ - { "length": 5, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055", "runCompositionTest", "#1-7") || - !checkSelection(5, "", "runCompositionTest", "#1-7")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044", - "clauses": - [ - { "length": 6, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 6, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044", "runCompositionTest", "#1-8") || - !checkSelection(6, "", "runCompositionTest", "#1-8")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053", - "clauses": - [ - { "length": 7, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 7, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053", "runCompositionTest", "#1-8") || - !checkSelection(7, "", "runCompositionTest", "#1-8")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046", - "clauses": - [ - { "length": 8, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 8, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046", - "runCompositionTest", "#1-9") || - !checkSelection(8, "", "runCompositionTest", "#1-9")) { - return; - } - - // convert - synthesizeCompositionChange( - { "composition": - { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", - "clauses": - [ - { "length": 4, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 2, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", - "runCompositionTest", "#1-10") || - !checkSelection(4, "", "runCompositionTest", "#1-10")) { - return; - } - - // change the selected clause - synthesizeCompositionChange( - { "composition": - { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", - "clauses": - [ - { "length": 4, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 2, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 6, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", - "runCompositionTest", "#1-11") || - !checkSelection(6, "", "runCompositionTest", "#1-11")) { - return; - } - - // reset clauses - synthesizeCompositionChange( - { "composition": - { "string": "\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046", - "clauses": - [ - { "length": 5, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 3, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046", - "runCompositionTest", "#1-12") || - !checkSelection(5, "", "runCompositionTest", "#1-12")) { - return; - } - - - var textRect1 = synthesizeQueryTextRect(0, 1); - var textRect2 = synthesizeQueryTextRect(1, 1); - if (!checkQueryContentResult(textRect1, - "runCompositionTest: synthesizeQueryTextRect #1-12-1") || - !checkQueryContentResult(textRect2, - "runCompositionTest: synthesizeQueryTextRect #1-12-2")) { - return false; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommitasis" }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046", - "runCompositionTest", "#1-13") || - !checkSelection(8, "", "runCompositionTest", "#1-13")) { - return; - } - - var textRect3 = synthesizeQueryTextRect(0, 1); - var textRect4 = synthesizeQueryTextRect(1, 1); - - if (!checkQueryContentResult(textRect3, - "runCompositionTest: synthesizeQueryTextRect #1-13-1") || - !checkQueryContentResult(textRect4, - "runCompositionTest: synthesizeQueryTextRect #1-13-2")) { - return false; - } - - checkRect(textRect3, textRect1, "runCompositionTest: textRect #1-13-1"); - checkRect(textRect4, textRect2, "runCompositionTest: textRect #1-13-2"); - - // restart composition and input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3057", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3057", - "runCompositionTest", "#2-1") || - !checkSelection(8 + 1, "", "runCompositionTest", "#2-1")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3058", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058", - "runCompositionTest", "#2-2") || - !checkSelection(8 + 1, "", "runCompositionTest", "#2-2")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3058\u3087", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087", - "runCompositionTest", "#2-3") || - !checkSelection(8 + 2, "", "runCompositionTest", "#2-3")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3058\u3087\u3046", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087\u3046", - "runCompositionTest", "#2-4") || - !checkSelection(8 + 3, "", "runCompositionTest", "#2-4")) { - return; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommitasis" }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3055\u884C\u3053\u3046\u3058\u3087\u3046", - "runCompositionTest", "#2-4") || - !checkSelection(8 + 3, "", "runCompositionTest", "#2-4")) { - return; - } - - // set selection - var selectionSetTest = synthesizeSelectionSet(4, 7, false); - ok(selectionSetTest, "runCompositionTest: selectionSetTest failed"); - - if (!checkSelection(4, "\u3055\u884C\u3053\u3046\u3058\u3087\u3046", "runCompositionTest", "#3-1")) { - return; - } - - // start composition with selection - synthesizeCompositionChange( - { "composition": - { "string": "\u304A", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u304A", - "runCompositionTest", "#3-2") || - !checkSelection(4 + 1, "", "runCompositionTest", "#3-2")) { - return; - } - - // remove the composition string - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#3-3") || - !checkSelection(4, "", "runCompositionTest", "#3-3")) { - return; - } - - // re-input the composition string - synthesizeCompositionChange( - { "composition": - { "string": "\u3046", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u3046", - "runCompositionTest", "#3-4") || - !checkSelection(4 + 1, "", "runCompositionTest", "#3-4")) { - return; - } - - // cancel the composition - synthesizeComposition({ type: "compositioncommit", data: "" }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#3-5") || - !checkSelection(4, "", "runCompositionTest", "#3-5")) { - return; - } - - // bug 271815, some Chinese IMEs for Linux make empty composition string - // and compty clause information when it lists up Chinese characters on - // its candidate window. - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#4-1") || - !checkSelection(4, "", "runCompositionTest", "#4-1")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#4-2") || - !checkSelection(4, "", "runCompositionTest", "#4-2")) { - return; - } - - synthesizeComposition({ type: "compositioncommit", data: "\u6700" }); - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#4-3") || - !checkSelection(5, "", "runCompositionTest", "#4-3")) { - return; - } - - // testing the canceling case - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#4-5") || - !checkSelection(5, "", "runCompositionTest", "#4-5")) { - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#4-6") || - !checkSelection(5, "", "runCompositionTest", "#4-6")) { - return; - } - - // testing whether the empty composition string deletes selected string. - synthesizeKey("VK_LEFT", { shiftKey: true }); - - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#4-8") || - !checkSelection(4, "", "runCompositionTest", "#4-8")) { - return; - } - - synthesizeComposition({ type: "compositioncommit", data: "\u9AD8" }); - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8", - "runCompositionTest", "#4-9") || - !checkSelection(5, "", "runCompositionTest", "#4-9")) { - return; - } - - synthesizeKey("VK_BACK_SPACE", {}); - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#4-11") || - !checkSelection(4, "", "runCompositionTest", "#4-11")) { - return; - } - - // bug 23558, ancient Japanese IMEs on Window may send empty text event - // twice at canceling composition. - synthesizeCompositionChange( - { "composition": - { "string": "\u6700", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#5-1") || - !checkSelection(4 + 1, "", "runCompositionTest", "#5-1")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - "caret": { "start": 0, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#5-2") || - !checkSelection(4, "", "runCompositionTest", "#5-2")) { - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#5-3") || - !checkSelection(4, "", "runCompositionTest", "#5-3")) { - return; - } - - // Undo tests for the testcases for bug 23558 and bug 271815 - synthesizeKey("Z", { accelKey: true }); - - // XXX this is unexpected behavior, see bug 258291 - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#6-1") || - !checkSelection(4, "", "runCompositionTest", "#6-1")) { - return; - } - - synthesizeKey("Z", { accelKey: true }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u9AD8", - "runCompositionTest", "#6-2") || - !checkSelection(5, "", "runCompositionTest", "#6-2")) { - return; - } - - synthesizeKey("Z", { accelKey: true }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#6-3") || - !checkSelection(4, "\u6700", "runCompositionTest", "#6-3")) { - return; - } - - synthesizeKey("Z", { accelKey: true }); - - // XXX this is unexpected behavior, see bug 258291 - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700", - "runCompositionTest", "#6-4") || - !checkSelection(5, "", "runCompositionTest", "#6-4")) { - return; - } - - synthesizeKey("Z", { accelKey: true }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3", - "runCompositionTest", "#6-5") || - !checkSelection(4, "", "runCompositionTest", "#6-5")) { - return; - } -} - -function runCompositionEventTest() -{ - const kDescription = "runCompositionEventTest: "; - const kEvents = ["compositionstart", "compositionupdate", "compositionend", - "input"]; - - input.value = ""; - input.focus(); - - var windowEventCounts = [], windowEventData = [], windowEventLocale = []; - var inputEventCounts = [], inputEventData = [], inputEventLocale = []; - var preventDefault = false; - var stopPropagation = false; - - function initResults() - { - for (var i = 0; i < kEvents.length; i++) { - windowEventCounts[kEvents[i]] = 0; - windowEventData[kEvents[i]] = ""; - windowEventLocale[kEvents[i]] = ""; - inputEventCounts[kEvents[i]] = 0; - inputEventData[kEvents[i]] = ""; - inputEventLocale[kEvents[i]] = ""; - } - } - - function compositionEventHandlerForWindow(aEvent) - { - windowEventCounts[aEvent.type]++; - windowEventData[aEvent.type] = aEvent.data; - windowEventLocale[aEvent.type] = aEvent.locale; - if (preventDefault) { - aEvent.preventDefault(); - } - if (stopPropagation) { - aEvent.stopPropagation(); - } - } - - function formEventHandlerForWindow(aEvent) - { - ok(aEvent.isTrusted, "input events must be trusted events"); - windowEventCounts[aEvent.type]++; - windowEventData[aEvent.type] = input.value; - } - - function compositionEventHandlerForInput(aEvent) - { - inputEventCounts[aEvent.type]++; - inputEventData[aEvent.type] = aEvent.data; - inputEventLocale[aEvent.type] = aEvent.locale; - if (preventDefault) { - aEvent.preventDefault(); - } - if (stopPropagation) { - aEvent.stopPropagation(); - } - } - - function formEventHandlerForInput(aEvent) - { - inputEventCounts[aEvent.type]++; - inputEventData[aEvent.type] = input.value; - } - - window.addEventListener("compositionstart", compositionEventHandlerForWindow, - true, true); - window.addEventListener("compositionend", compositionEventHandlerForWindow, - true, true); - window.addEventListener("compositionupdate", compositionEventHandlerForWindow, - true, true); - window.addEventListener("input", formEventHandlerForWindow, - true, true); - - input.addEventListener("compositionstart", compositionEventHandlerForInput, - true, true); - input.addEventListener("compositionend", compositionEventHandlerForInput, - true, true); - input.addEventListener("compositionupdate", compositionEventHandlerForInput, - true, true); - input.addEventListener("input", formEventHandlerForInput, - true, true); - - // test for normal case - initResults(); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by window #1"); - is(windowEventData["compositionstart"], "", - kDescription + "data of compositionstart isn't empty (window) #1"); - is(windowEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (window) #1"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by input #1"); - is(inputEventData["compositionstart"], "", - kDescription + "data of compositionstart isn't empty (input) #1"); - is(inputEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (input) #1"); - - is(windowEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by window #1"); - is(windowEventData["compositionupdate"], "\u3089", - kDescription + "data of compositionupdate doesn't match (window) #1"); - is(windowEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (window) #1"); - is(inputEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by input #1"); - is(inputEventData["compositionupdate"], "\u3089", - kDescription + "data of compositionupdate doesn't match (input) #1"); - is(inputEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (input) #1"); - - is(windowEventCounts["compositionend"], 0, - kDescription + "compositionend has been handled by window #1"); - is(inputEventCounts["compositionend"], 0, - kDescription + "compositionend has been handled by input #1"); - - is(windowEventCounts["input"], 1, - kDescription + "input hasn't been handled by window #1"); - is(windowEventData["input"], "\u3089", - kDescription + "value of input element wasn't modified (window) #1"); - is(inputEventCounts["input"], 1, - kDescription + "input hasn't been handled by input #1"); - is(inputEventData["input"], "\u3089", - kDescription + "value of input element wasn't modified (input) #1"); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart has been handled more than once by window #2"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart has been handled more than once by input #2"); - - is(windowEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate hasn't been handled by window #2"); - is(windowEventData["compositionupdate"], "\u3089\u30FC", - kDescription + "data of compositionupdate doesn't match (window) #2"); - is(windowEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (window) #2"); - is(inputEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate hasn't been handled by input #2"); - is(inputEventData["compositionupdate"], "\u3089\u30FC", - kDescription + "data of compositionupdate doesn't match (input) #2"); - is(inputEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (input) #2"); - - is(windowEventCounts["compositionend"], 0, - kDescription + "compositionend has been handled during composition by window #2"); - is(inputEventCounts["compositionend"], 0, - kDescription + "compositionend has been handled during composition by input #2"); - - is(windowEventCounts["input"], 2, - kDescription + "input hasn't been handled by window #2"); - is(windowEventData["input"], "\u3089\u30FC", - kDescription + "value of input element wasn't modified (window) #2"); - is(inputEventCounts["input"], 2, - kDescription + "input hasn't been handled by input #2"); - is(inputEventData["input"], "\u3089\u30FC", - kDescription + "value of input element wasn't modified (input) #2"); - - // text event shouldn't cause composition update, e.g., at committing. - synthesizeComposition({ type: "compositioncommitasis" }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart has been handled more than once by window #3"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart has been handled more than once by input #3"); - - is(windowEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate has been fired unexpectedly on window #3"); - is(inputEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate has been fired unexpectedly on input #3"); - - is(windowEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by window #3"); - is(windowEventData["compositionend"], "\u3089\u30FC", - kDescription + "data of compositionend doesn't match (window) #3"); - is(windowEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (window) #3"); - is(inputEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by input #3"); - is(inputEventData["compositionend"], "\u3089\u30FC", - kDescription + "data of compositionend doesn't match (input) #3"); - is(inputEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (input) #3"); - - is(windowEventCounts["input"], 3, - kDescription + "input hasn't been handled by window #3"); - is(windowEventData["input"], "\u3089\u30FC", - kDescription + "value of input element wasn't modified (window) #3"); - is(inputEventCounts["input"], 3, - kDescription + "input hasn't been handled by input #3"); - is(inputEventData["input"], "\u3089\u30FC", - kDescription + "value of input element wasn't modified (input) #3"); - - // select the second character, then, data of composition start should be - // the selected character. - initResults(); - synthesizeKey("VK_LEFT", { shiftKey: true }); - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeComposition({ type: "compositioncommitasis" }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by window #4"); - is(windowEventData["compositionstart"], "\u30FC", - kDescription + "data of compositionstart is empty (window) #4"); - is(windowEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (window) #4"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by input #4"); - is(inputEventData["compositionstart"], "\u30FC", - kDescription + "data of compositionstart is empty (input) #4"); - is(inputEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (input) #4"); - - is(windowEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by window #4"); - is(windowEventData["compositionupdate"], "\u3089", - kDescription + "data of compositionupdate doesn't match (window) #4"); - is(windowEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (window) #4"); - is(inputEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by input #4"); - is(inputEventData["compositionupdate"], "\u3089", - kDescription + "data of compositionupdate doesn't match (input) #4"); - is(inputEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (input) #4"); - - is(windowEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by window #4"); - is(windowEventData["compositionend"], "\u3089", - kDescription + "data of compositionend doesn't match (window) #4"); - is(windowEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (window) #4"); - is(inputEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by input #4"); - is(inputEventData["compositionend"], "\u3089", - kDescription + "data of compositionend doesn't match (input) #4"); - is(inputEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (input) #4"); - - is(windowEventCounts["input"], 2, - kDescription + "input hasn't been handled by window #4"); - is(windowEventData["input"], "\u3089\u3089", - kDescription + "value of input element wasn't modified (window) #4"); - is(inputEventCounts["input"], 2, - kDescription + "input hasn't been handled by input #4"); - is(inputEventData["input"], "\u3089\u3089", - kDescription + "value of input element wasn't modified (input) #4"); - - // preventDefault() should effect nothing. - preventDefault = true; - - initResults(); - synthesizeKey("A", { accelKey: true }); // Select All - - synthesizeCompositionChange( - { "composition": - { "string": "\u306D", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeComposition({ type: "compositioncommitasis" }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by window #5"); - is(windowEventData["compositionstart"], "\u3089\u3089", - kDescription + "data of compositionstart is empty (window) #5"); - is(windowEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (window) #5"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by input #5"); - is(inputEventData["compositionstart"], "\u3089\u3089", - kDescription + "data of compositionstart is empty (input) #5"); - is(inputEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty (input) #5"); - - is(windowEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by window #5"); - is(windowEventData["compositionupdate"], "\u306D", - kDescription + "data of compositionupdate doesn't match (window) #5"); - is(windowEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (window) #5"); - is(inputEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by input #5"); - is(inputEventData["compositionupdate"], "\u306D", - kDescription + "data of compositionupdate doesn't match (input) #5"); - is(inputEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty (input) #5"); - - is(windowEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by window #5"); - is(windowEventData["compositionend"], "\u306D", - kDescription + "data of compositionend doesn't match (window) #5"); - is(windowEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (window) #5"); - is(inputEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by input #5"); - is(inputEventData["compositionend"], "\u306D", - kDescription + "data of compositionend doesn't match (input) #5"); - is(inputEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty (input) #5"); - - is(windowEventCounts["input"], 2, - kDescription + "input hasn't been handled by window #5"); - is(windowEventData["input"], "\u306D", - kDescription + "value of input element wasn't modified (window) #5"); - is(inputEventCounts["input"], 2, - kDescription + "input hasn't been handled by input #5"); - is(inputEventData["input"], "\u306D", - kDescription + "value of input element wasn't modified (input) #5"); - - prevnetDefault = false; - - // stopPropagation() should effect nothing (except event count) - stopPropagation = true; - - initResults(); - synthesizeKey("A", { accelKey: true }); // Select All - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - synthesizeComposition({ type: "compositioncommitasis" }); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by window #6"); - is(windowEventData["compositionstart"], "\u306D", - kDescription + "data of compositionstart is empty #6"); - is(windowEventLocale["compositionstart"], "", - kDescription + "locale of compositionstart isn't empty #6"); - is(inputEventCounts["compositionstart"], 0, - kDescription + "compositionstart has been handled by input #6"); - - is(windowEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by window #6"); - is(windowEventData["compositionupdate"], "\u306E", - kDescription + "data of compositionupdate doesn't match #6"); - is(windowEventLocale["compositionupdate"], "", - kDescription + "locale of compositionupdate isn't empty #6"); - is(inputEventCounts["compositionupdate"], 0, - kDescription + "compositionupdate has been handled by input #6"); - - is(windowEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by window #6"); - is(windowEventData["compositionend"], "\u306E", - kDescription + "data of compositionend doesn't match #6"); - is(windowEventLocale["compositionend"], "", - kDescription + "locale of compositionend isn't empty #6"); - is(inputEventCounts["compositionend"], 0, - kDescription + "compositionend has been handled by input #6"); - - is(windowEventCounts["input"], 2, - kDescription + "input hasn't been handled by window #6"); - is(windowEventData["input"], "\u306E", - kDescription + "value of input element wasn't modified (window) #6"); - is(inputEventCounts["input"], 2, - kDescription + "input hasn't been handled by input #6"); - is(inputEventData["input"], "\u306E", - kDescription + "value of input element wasn't modified (input) #6"); - - stopPropagation = false; - - // create event and dispatch it. - initResults(); - - input.value = "value of input"; - synthesizeKey("A", { accelKey: true }); // Select All - - var compositionstart = document.createEvent("CompositionEvent"); - compositionstart.initCompositionEvent("compositionstart", - true, true, document.defaultView, - "start data", "start locale"); - is(compositionstart.type, "compositionstart", - kDescription + "type doesn't match #7"); - is(compositionstart.data, "start data", - kDescription + "data doesn't match #7"); - is(compositionstart.locale, "start locale", - kDescription + "locale doesn't match #7"); - is(compositionstart.detail, 0, - kDescription + "detail isn't 0 #7"); - - input.dispatchEvent(compositionstart); - - is(windowEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by window #7"); - is(windowEventData["compositionstart"], "start data", - kDescription + "data of compositionstart was changed (window) #7"); - is(windowEventLocale["compositionstart"], "start locale", - kDescription + "locale of compositionstart was changed (window) #7"); - is(inputEventCounts["compositionstart"], 1, - kDescription + "compositionstart hasn't been handled by input #7"); - is(inputEventData["compositionstart"], "start data", - kDescription + "data of compositionstart was changed (input) #7"); - is(inputEventLocale["compositionstart"], "start locale", - kDescription + "locale of compositionstart was changed (input) #7"); - - is(input.value, "value of input", - kDescription + "input value was changed #7"); - - var compositionupdate1 = document.createEvent("compositionevent"); - compositionupdate1.initCompositionEvent("compositionupdate", - true, false, document.defaultView, - "composing string", "composing locale"); - is(compositionupdate1.type, "compositionupdate", - kDescription + "type doesn't match #8"); - is(compositionupdate1.data, "composing string", - kDescription + "data doesn't match #8"); - is(compositionupdate1.locale, "composing locale", - kDescription + "locale doesn't match #8"); - is(compositionupdate1.detail, 0, - kDescription + "detail isn't 0 #8"); - - input.dispatchEvent(compositionupdate1); - - is(windowEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by window #8"); - is(windowEventData["compositionupdate"], "composing string", - kDescription + "data of compositionupdate was changed (window) #8"); - is(windowEventLocale["compositionupdate"], "composing locale", - kDescription + "locale of compositionupdate was changed (window) #8"); - is(inputEventCounts["compositionupdate"], 1, - kDescription + "compositionupdate hasn't been handled by input #8"); - is(inputEventData["compositionupdate"], "composing string", - kDescription + "data of compositionupdate was changed (input) #8"); - is(inputEventLocale["compositionupdate"], "composing locale", - kDescription + "locale of compositionupdate was changed (input) #8"); - - is(input.value, "value of input", - kDescription + "input value was changed #8"); - - var compositionupdate2 = document.createEvent("compositionEvent"); - compositionupdate2.initCompositionEvent("compositionupdate", - true, false, document.defaultView, - "commit string", "commit locale"); - is(compositionupdate2.type, "compositionupdate", - kDescription + "type doesn't match #9"); - is(compositionupdate2.data, "commit string", - kDescription + "data doesn't match #9"); - is(compositionupdate2.locale, "commit locale", - kDescription + "locale doesn't match #9"); - is(compositionupdate2.detail, 0, - kDescription + "detail isn't 0 #9"); - - input.dispatchEvent(compositionupdate2); - - is(windowEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate hasn't been handled by window #9"); - is(windowEventData["compositionupdate"], "commit string", - kDescription + "data of compositionupdate was changed (window) #9"); - is(windowEventLocale["compositionupdate"], "commit locale", - kDescription + "locale of compositionupdate was changed (window) #9"); - is(inputEventCounts["compositionupdate"], 2, - kDescription + "compositionupdate hasn't been handled by input #9"); - is(inputEventData["compositionupdate"], "commit string", - kDescription + "data of compositionupdate was changed (input) #9"); - is(inputEventLocale["compositionupdate"], "commit locale", - kDescription + "locale of compositionupdate was changed (input) #9"); - - is(input.value, "value of input", - kDescription + "input value was changed #9"); - - var compositionend = document.createEvent("Compositionevent"); - compositionend.initCompositionEvent("compositionend", - true, false, document.defaultView, - "end data", "end locale"); - is(compositionend.type, "compositionend", - kDescription + "type doesn't match #10"); - is(compositionend.data, "end data", - kDescription + "data doesn't match #10"); - is(compositionend.locale, "end locale", - kDescription + "locale doesn't match #10"); - is(compositionend.detail, 0, - kDescription + "detail isn't 0 #10"); - - input.dispatchEvent(compositionend); - - is(windowEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by window #10"); - is(windowEventData["compositionend"], "end data", - kDescription + "data of compositionend was changed (window) #10"); - is(windowEventLocale["compositionend"], "end locale", - kDescription + "locale of compositionend was changed (window) #10"); - is(inputEventCounts["compositionend"], 1, - kDescription + "compositionend hasn't been handled by input #10"); - is(inputEventData["compositionend"], "end data", - kDescription + "data of compositionend was changed (input) #10"); - is(inputEventLocale["compositionend"], "end locale", - kDescription + "locale of compositionend was changed (input) #10"); - - is(input.value, "value of input", - kDescription + "input value was changed #10"); - - window.removeEventListener("compositionstart", - compositionEventHandlerForWindow, true); - window.removeEventListener("compositionend", - compositionEventHandlerForWindow, true); - window.removeEventListener("compositionupdate", - compositionEventHandlerForWindow, true); - window.removeEventListener("input", - formEventHandlerForWindow, true); - - input.removeEventListener("compositionstart", - compositionEventHandlerForInput, true); - input.removeEventListener("compositionend", - compositionEventHandlerForInput, true); - input.removeEventListener("compositionupdate", - compositionEventHandlerForInput, true); - input.removeEventListener("input", - formEventHandlerForInput, true); -} - -function runQueryTextRectInContentEditableTest() -{ - contenteditable.focus(); - - contenteditable.innerHTML = "<p>abc</p><p>def</p>"; - // \n 0 123 4 567 - // \r\n 01 234 56 789 - - var description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "a" - var a = synthesizeQueryTextRect(kLFLen, 1); - if (!checkQueryContentResult(a, description + "rect for 'a'")) { - return; - } - - // "b" - var b = synthesizeQueryTextRect(kLFLen + 1, 1); - if (!checkQueryContentResult(b, description + "rect for 'b'")) { - return; - } - - is(b.top, a.top, description + "'a' and 'b' should be at same top"); - isSimilarTo(b.left, a.left + a.width, 2, description + "left of 'b' should be at similar to right of 'a'"); - is(b.height, a.height, description + "'a' and 'b' should be same height"); - - // "c" - var c = synthesizeQueryTextRect(kLFLen + 2, 1); - if (!checkQueryContentResult(c, description + "rect for 'c'")) { - return; - } - - is(c.top, b.top, description + "'b' and 'c' should be at same top"); - isSimilarTo(c.left, b.left + b.width, 2, description + "left of 'c' should be at similar to right of 'b'"); - is(c.height, b.height, description + "'b' and 'c' should be same height"); - - // "abc" as array - var abcAsArray = synthesizeQueryTextRectArray(kLFLen, 3); - if (!checkQueryContentResult(abcAsArray, description + "rect array for 'abc'") || - !checkRectArray(abcAsArray, [a, b, c], description + "query text rect array result of 'abc' should match with each query text rect result")) { - return; - } - - // 2nd <p> (can be computed with the rect of 'c') - var p2 = synthesizeQueryTextRect(kLFLen + 3, 1); - if (!checkQueryContentResult(p2, description + "rect for 2nd <p>")) { - return; - } - - is(p2.top, c.top, description + "'c' and a line breaker caused by 2nd <p> should be at same top"); - isSimilarTo(p2.left, c.left + c.width, 2, description + "left of a line breaker caused by 2nd <p> should be at similar to right of 'c'"); - is(p2.height, c.height, description + "'c' and a line breaker caused by 2nd <p> should be same height"); - - // 2nd <p> as array - var p2AsArray = synthesizeQueryTextRectArray(kLFLen + 3, 1); - if (!checkQueryContentResult(p2AsArray, description + "2nd <p>'s line breaker as array") || - !checkRectArray(p2AsArray, [p2], description + "query text rect array result of 2nd <p> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var p2_2 = synthesizeQueryTextRect(kLFLen + 4, 1); - if (!checkQueryContentResult(p2_2, description + "rect for \\n of \\r\\n caused by 2nd <p>")) { - return; - } - - is(p2_2.top, p2.top, description + "'\\r' and '\\n' should be at same top"); - is(p2_2.left, p2.left, description + "'\\r' and '\\n' should be at same top"); - is(p2_2.height, p2.height, description + "'\\r' and '\\n' should be same height"); - is(p2_2.width, p2.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var p2_2AsArray = synthesizeQueryTextRectArray(kLFLen + 4, 1); - if (!checkQueryContentResult(p2_2AsArray, description + "rect array for \\n of \\r\\n caused by 2nd <p>") || - !checkRectArray(p2_2AsArray, [p2_2], description + "query text rect array result of \\n of \\r\\n caused by 2nd <p> should match with each query text rect result")) { - return; - } - } - - // "d" - var d = synthesizeQueryTextRect(kLFLen * 2 + 3, 1); - if (!checkQueryContentResult(d, description + "rect for 'd'")) { - return; - } - - isGreaterThan(d.top, a.top + a.height, description + "top of 'd' should be greater than bottom of 'a'"); - is(d.left, a.left, description + "'a' and 'd' should be same at same left"); - is(d.height, a.height, description + "'a' and 'd' should be same height"); - - // "e" - var e = synthesizeQueryTextRect(kLFLen * 2 + 4, 1); - if (!checkQueryContentResult(e, description + "rect for 'e'")) { - return; - } - - is(e.top, d.top, description + "'d' and 'd' should be at same top"); - isSimilarTo(e.left, d.left + d.width, 2, description + "left of 'e' should be at similar to right of 'd'"); - is(e.height, d.height, description + "'d' and 'e' should be same height"); - - // "f" - var f = synthesizeQueryTextRect(kLFLen * 2 + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - - // "def" as array - var defAsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 3, 3); - if (!checkQueryContentResult(defAsArray, description + "rect array for 'def'") || - !checkRectArray(defAsArray, [d, e, f], description + "query text rect array result of 'def' should match with each query text rect result")) { - return; - } - - // next of "f" (can be computed with rect of 'f') - var next_f = synthesizeQueryTextRect(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(next_f, description + "rect for next of 'f'")) { - return; - } - - is(next_f.top, d.top, 2, description + "'f' and next of 'f' should be at same top"); - isSimilarTo(next_f.left, f.left + f.width, 2, description + "left of next of 'f' should be at similar to right of 'f'"); - is(next_f.height, d.height, description + "'f' and next of 'f' should be same height"); - - // next of "f" as array - var next_fAsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(next_fAsArray, description + "rect array for next of 'f'") || - !checkRectArray(next_fAsArray, [next_f], description + "query text rect array result of next of 'f' should match with each query text rect result")) { - return; - } - - // too big offset for the editor - var tooBigOffset = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_f.top, description + "too big offset and next of 'f' should be at same top"); - is(tooBigOffset.left, next_f.left, description + "too big offset and next of 'f' should be at same left"); - is(tooBigOffset.height, next_f.height, description + "too big offset and next of 'f' should be same height"); - is(tooBigOffset.width, next_f.width, description + "too big offset and next of 'f' should be same width"); - - // too big offset for the editors as array - var tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } - - contenteditable.innerHTML = "<p>abc</p><p>def</p><p><br></p>"; - // \n 0 123 4 567 8 9 - // \r\n 01 234 56 789 01 23 - - description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "f" - f = synthesizeQueryTextRect(kLFLen * 2 + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - - // 3rd <p> (can be computed with rect of 'f') - var p3 = synthesizeQueryTextRect(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(p3, description + "rect for 3rd <p>")) { - return; - } - - is(p3.top, f.top, description + "'f' and a line breaker caused by 3rd <p> should be at same top"); - is(p3.height, f.height, description + "'f' and a line breaker caused by 3rd <p> should be same height"); - isSimilarTo(p3.left, f.left + f.width, 2, description + "left of a line breaker caused by 3rd <p> should be similar to right of 'f'"); - - // 3rd <p> as array - var p3AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(p3AsArray, description + "3rd <p>'s line breaker as array") || - !checkRectArray(p3AsArray, [p3], description + "query text rect array result of 3rd <p> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var p3_2 = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(p3_2, description + "rect for \\n of \\r\\n caused by 3rd <p>")) { - return; - } - - is(p3_2.top, p3.top, description + "'\\r' and '\\n' should be at same top"); - is(p3_2.left, p3.left, description + "'\\r' and '\\n' should be at same top"); - is(p3_2.height, p3.height, description + "'\\r' and '\\n' should be same height"); - is(p3_2.width, p3.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var p3_2AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(p3_2AsArray, description + "rect array for \\n of \\r\\n caused by 3rd <p>") || - !checkRectArray(p3_2AsArray, [p3_2], description + "query text rect array result of \\n of \\r\\n caused by 3rd <p> should match with each query text rect result")) { - return; - } - } - - // <br> in 3rd <p> - var br = synthesizeQueryTextRect(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(br, description + "rect for <br> in 3rd <p>")) { - return; - } - - isGreaterThan(br.top, d.top + d.height, description + "a line breaker caused by <br> in 3rd <p> should be greater than bottom of 'd'"); - isSimilarTo(br.height, d.height, 2, description + "'d' and a line breaker caused by <br> in 3rd <p> should be similar height"); - is(br.left, d.left, description + "left of a line breaker caused by <br> in 3rd <p> should be same left of 'd'"); - - // <br> in 3rd <p> as array - var brAsArray = synthesizeQueryTextRectArray(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(brAsArray, description + "<br> in 3rd <p> as array") || - !checkRectArray(brAsArray, [br], description + "query text rect array result of <br> in 3rd <p> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var br_2 = synthesizeQueryTextRect(kLFLen * 3 + 7, 1); - if (!checkQueryContentResult(br_2, description + "rect for \\n of \\r\\n caused by <br> in 3rd <p>")) { - return; - } - - is(br_2.top, br.top, description + "'\\r' and '\\n' should be at same top"); - is(br_2.left, br.left, description + "'\\r' and '\\n' should be at same top"); - is(br_2.height, br.height, description + "'\\r' and '\\n' should be same height"); - is(br_2.width, br.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var br_2AsArray = synthesizeQueryTextRectArray(kLFLen * 3 + 7, 1); - if (!checkQueryContentResult(br_2AsArray, description + "rect array for \\n of \\r\\n caused by <br> in 3rd <p>") || - !checkRectArray(br_2AsArray, [br_2], description + "query text rect array result of \\n of \\r\\n caused by <br> in 3rd <p> should match with each query text rect result")) { - return; - } - } - - // next of <br> in 3rd <p> - var next_br = synthesizeQueryTextRect(kLFLen * 4 + 6, 1); - if (!checkQueryContentResult(next_br, description + "rect for next of <br> in 3rd <p>")) { - return; - } - - is(next_br.top, br.top, description + "next of <br> and <br> should be at same top"); - is(next_br.left, br.left, description + "next of <br> and <br> should be at same left"); - is(next_br.height, br.height, description + "next of <br> and <br> should be same height"); - is(next_br.width, br.width, description + "next of <br> and <br> should be same width"); - - // next of <br> in 3rd <p> as array - var next_brAsArray = synthesizeQueryTextRectArray(kLFLen * 4 + 6, 1); - if (!checkQueryContentResult(next_brAsArray, description + "rect array for next of <br> in 3rd <p>") || - !checkRectArray(next_brAsArray, [next_br], description + "query text rect array result of next of <br> in 3rd <p> should match with each query text rect result")) { - return; - } - - // too big offset for the editor - tooBigOffset = synthesizeQueryTextRect(kLFLen * 4 + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_br.top, description + "too big offset and next of 3rd <p> should be at same top"); - is(tooBigOffset.left, next_br.left, description + "too big offset and next of 3rd <p> should be at same left"); - is(tooBigOffset.height, next_br.height, description + "too big offset and next of 3rd <p> should be same height"); - is(tooBigOffset.width, next_br.width, description + "too big offset and next of 3rd <p> should be same width"); - - // too big offset for the editors as array - tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen * 4 + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } - - contenteditable.innerHTML = "<p>abc</p><p>def</p><p></p>"; - // \n 0 123 4 567 8 - // \r\n 01 234 56 789 0 - - description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "f" - f = synthesizeQueryTextRect(kLFLen * 2 + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - - // 3rd <p> (can be computed with rect of 'f') - p3 = synthesizeQueryTextRect(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(p3, description + "rect for 3rd <p>")) { - return; - } - - is(p3.top, f.top, description + "'f' and a line breaker caused by 3rd <p> should be at same top"); - is(p3.height, f.height, description + "'f' and a line breaker caused by 3rd <p> should be same height"); - isSimilarTo(p3.left, f.left + f.width, 2, description + "left of a line breaker caused by 3rd <p> should be similar to right of 'f'"); - - // 3rd <p> as array - p3AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(p3AsArray, description + "3rd <p>'s line breaker as array") || - !checkRectArray(p3AsArray, [p3], description + "query text rect array result of 3rd <p> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - p3_2 = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(p3_2, description + "rect for \\n of \\r\\n caused by 3rd <p>")) { - return; - } - - is(p3_2.top, p3.top, description + "'\\r' and '\\n' should be at same top"); - is(p3_2.left, p3.left, description + "'\\r' and '\\n' should be at same top"); - is(p3_2.height, p3.height, description + "'\\r' and '\\n' should be same height"); - is(p3_2.width, p3.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - p3_2AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(p3_2AsArray, description + "rect array for \\n of \\r\\n caused by 3rd <p>") || - !checkRectArray(p3_2AsArray, [p3_2], description + "query text rect array result of \\n of \\r\\n caused by 3rd <p> should match with each query text rect result")) { - return; - } - } - - // next of 3rd <p> - var next_p3 = synthesizeQueryTextRect(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(next_p3, description + "rect for next of 3rd <p>")) { - return; - } - - isGreaterThan(next_p3.top, d.top + d.height, description + "top of next of 3rd <p> should equal to or be bigger than bottom of 'd'"); - isSimilarTo(next_p3.left, d.left, 2, description + "left of next of 3rd <p> should be at similar to left of 'd'"); - isSimilarTo(next_p3.height, d.height, 2, description + "next of 3rd <p> and 'd' should be similar height"); - - // next of 3rd <p> as array - var next_p3AsArray = synthesizeQueryTextRectArray(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(next_p3AsArray, description + "next of 3rd <p> as array") || - !checkRectArray(next_p3AsArray, [next_p3], description + "query text rect array result of next of 3rd <p> should match with each query text rect result")) { - return; - } - - // too big offset for the editor - tooBigOffset = synthesizeQueryTextRect(kLFLen * 3 + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_p3.top, description + "too big offset and next of 3rd <p> should be at same top"); - is(tooBigOffset.left, next_p3.left, description + "too big offset and next of 3rd <p> should be at same left"); - is(tooBigOffset.height, next_p3.height, description + "too big offset and next of 3rd <p> should be same height"); - is(tooBigOffset.width, next_p3.width, description + "too big offset and next of 3rd <p> should be same width"); - - // too big offset for the editors as array - tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen * 3 + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } - - contenteditable.innerHTML = "abc<br>def"; - // \n 0123 456 - // \r\n 01234 567 - - description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "a" - a = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(a, description + "rect for 'a'")) { - return; - } - - // "b" - b = synthesizeQueryTextRect(1, 1); - if (!checkQueryContentResult(b, description + "rect for 'b'")) { - return; - } - - is(b.top, a.top, description + "'a' and 'b' should be at same top"); - isSimilarTo(b.left, a.left + a.width, 2, description + "left of 'b' should be at similar to right of 'a'"); - is(b.height, a.height, description + "'a' and 'b' should be same height"); - - // "c" - c = synthesizeQueryTextRect(2, 1); - if (!checkQueryContentResult(c, description + "rect for 'c'")) { - return; - } - - is(c.top, b.top, description + "'b' and 'c' should be at same top"); - isSimilarTo(c.left, b.left + b.width, 2, description + "left of 'c' should be at similar to right of 'b'"); - is(c.height, b.height, description + "'b' and 'c' should be same height"); - - // "abc" as array - abcAsArray = synthesizeQueryTextRectArray(0, 3); - if (!checkQueryContentResult(abcAsArray, description + "rect array for 'abc'") || - !checkRectArray(abcAsArray, [a, b, c], description + "query text rect array result of 'abc' should match with each query text rect result")) { - return; - } - - // <br> (can be computed with the rect of 'c') - br = synthesizeQueryTextRect(3, 1); - if (!checkQueryContentResult(br, description + "rect for <br>")) { - return; - } - - is(br.top, c.top, description + "'c' and a line breaker caused by <br> should be at same top"); - isSimilarTo(br.left, c.left + c.width, 2, description + "left of a line breaker caused by <br> should be at similar to right of 'c'"); - is(br.height, c.height, description + "'c' and a line breaker caused by <br> should be same height"); - - // <br> as array - brAsArray = synthesizeQueryTextRectArray(3, 1); - if (!checkQueryContentResult(brAsArray, description + "<br>'s line breaker as array") || - !checkRectArray(brAsArray, [br], description + "query text rect array result of <br> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var br_2 = synthesizeQueryTextRect(4, 1); - if (!checkQueryContentResult(br_2, description + "rect for \n of \r\n caused by <br>")) { - return; - } - - is(br_2.top, br.top, description + "'\\r' and '\\n' should be at same top"); - is(br_2.left, br.left, description + "'\\r' and '\\n' should be at same top"); - is(br_2.height, br.height, description + "'\\r' and '\\n' should be same height"); - is(br_2.width, br.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var br_2AsArray = synthesizeQueryTextRectArray(4, 1); - if (!checkQueryContentResult(br_2AsArray, description + "rect array for \\n of \\r\\n caused by <br>") || - !checkRectArray(br_2AsArray, [br_2], description + "query text rect array result of \\n of \\r\\n caused by <br> should match with each query text rect result")) { - return; - } - } - - // "d" - d = synthesizeQueryTextRect(kLFLen + 3, 1); - if (!checkQueryContentResult(d, description + "rect for 'd'")) { - return; - } - - isSimilarTo(d.top, a.top + a.height, 2, description + "top of 'd' should be at similar to bottom of 'a'"); - is(d.left, a.left, description + "'a' and 'd' should be same at same left"); - is(d.height, a.height, description + "'a' and 'd' should be same height"); - - // "e" - e = synthesizeQueryTextRect(kLFLen + 4, 1); - if (!checkQueryContentResult(e, description + "rect for 'e'")) { - return; - } - - is(e.top, d.top, description + "'d' and 'd' should be at same top"); - isSimilarTo(e.left, d.left + d.width, 2, description + "left of 'e' should be at similar to right of 'd'"); - is(e.height, d.height, description + "'d' and 'e' should be same height"); - - // "f" - f = synthesizeQueryTextRect(kLFLen + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - - // "def" as array - defAsArray = synthesizeQueryTextRectArray(kLFLen + 3, 3); - if (!checkQueryContentResult(defAsArray, description + "rect array for 'def'") || - !checkRectArray(defAsArray, [d, e, f], description + "query text rect array result of 'def' should match with each query text rect result")) { - return; - } - - // next of "f" (can be computed with rect of 'f') - next_f = synthesizeQueryTextRect(kLFLen + 6, 1); - if (!checkQueryContentResult(next_f, description + "rect for next of 'f'")) { - return; - } - - is(next_f.top, d.top, 2, description + "'f' and next of 'f' should be at same top"); - isSimilarTo(next_f.left, f.left + f.width, 2, description + "left of next of 'f' should be at similar to right of 'f'"); - is(next_f.height, d.height, description + "'f' and next of 'f' should be same height"); - - // next of "f" as array - next_fAsArray = synthesizeQueryTextRectArray(kLFLen + 6, 1); - if (!checkQueryContentResult(next_fAsArray, description + "rect array for next of 'f'") || - !checkRectArray(next_fAsArray, [next_f], description + "query text rect array result of next of 'f' should match with each query text rect result")) { - return; - } - - // too big offset for the editor - tooBigOffset = synthesizeQueryTextRect(kLFLen + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_f.top, description + "too big offset and next of 'f' should be at same top"); - is(tooBigOffset.left, next_f.left, description + "too big offset and next of 'f' should be at same left"); - is(tooBigOffset.height, next_f.height, description + "too big offset and next of 'f' should be same height"); - is(tooBigOffset.width, next_f.width, description + "too big offset and next of 'f' should be same width"); - - // too big offset for the editors as array - tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } - - // Note that this case does not have an empty line at the end. - contenteditable.innerHTML = "abc<br>def<br>"; - // \n 0123 4567 - // \r\n 01234 56789 - - description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "f" - f = synthesizeQueryTextRect(kLFLen + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - - // 2nd <br> (can be computed with rect of 'f') - var br2 = synthesizeQueryTextRect(kLFLen + 6, 1); - if (!checkQueryContentResult(br2, description + "rect for 2nd <br>")) { - return; - } - - is(br2.top, f.top, description + "'f' and a line breaker caused by 2nd <br> should be at same top"); - is(br2.height, f.height, description + "'f' and a line breaker caused by 2nd <br> should be same height"); - isSimilarTo(br2.left, f.left + f.width, 2, description + "left of a line breaker caused by 2nd <br> should be similar to right of 'f'"); - - // 2nd <br> as array - var br2AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(br2AsArray, description + "2nd <br>'s line breaker as array") || - !checkRectArray(br2AsArray, [br2], description + "query text rect array result of 2nd <br> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var br2_2 = synthesizeQueryTextRect(kLFLen + 7, 1); - if (!checkQueryContentResult(br2_2, description + "rect for \\n of \\r\\n caused by 2nd <br>")) { - return; - } - - is(br2_2.top, br2.top, description + "'\\r' and '\\n' should be at same top"); - is(br2_2.left, br2.left, description + "'\\r' and '\\n' should be at same top"); - is(br2_2.height, br2.height, description + "'\\r' and '\\n' should be same height"); - is(br2_2.width, br2.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var br2_2AsArray = synthesizeQueryTextRectArray(kLFLen + 7, 1); - if (!checkQueryContentResult(br2_2AsArray, description + "rect array for \\n of \\r\\n caused by 2nd <br>") || - !checkRectArray(br2_2AsArray, [br2_2], description + "query text rect array result of \\n of \\r\\n caused by 2nd <br> should match with each query text rect result")) { - return; - } - } - - // next of 2nd <br> - var next_br2 = synthesizeQueryTextRect(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(next_br2, description + "rect for next of 2nd <br>")) { - return; - } - - is(next_br2.top, br2.top, description + "2nd <br> and next of 2nd <br> should be at same top"); - is(next_br2.left, br2.left, description + "2nd <br> and next of 2nd <br> should be at same top"); - is(next_br2.height, br2.height, description + "2nd <br> and next of 2nd <br> should be same height"); - is(next_br2.width, br2.width, description + "2nd <br> and next of 2nd <br> should be same width"); - - // next of 2nd <br> as array - var next_br2AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 6, 1); - if (!checkQueryContentResult(next_br2AsArray, description + "rect array for next of 2nd <br>") || - !checkRectArray(next_br2AsArray, [next_br2], description + "query text rect array result of next of 2nd <br> should match with each query text rect result")) { - return; - } - - // too big offset for the editor - tooBigOffset = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_br2.top, description + "too big offset and next of 2nd <br> should be at same top"); - is(tooBigOffset.left, next_br2.left, description + "too big offset and next of 2nd <br> should be at same left"); - is(tooBigOffset.height, next_br2.height, description + "too big offset and next of 2nd <br> should be same height"); - is(tooBigOffset.width, next_br2.width, description + "too big offset and next of 2nd <br> should be same width"); - - // too big offset for the editors as array - tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } - - contenteditable.innerHTML = "abc<br>def<br><br>"; - // \n 0123 4567 8 - // \r\n 01234 56789 01 - - description = "runTextRectInContentEditableTest: \"" + contenteditable.innerHTML + "\", "; - - // "f" - f = synthesizeQueryTextRect(kLFLen + 5, 1); - if (!checkQueryContentResult(f, description + "rect for 'f'")) { - return; - } - - is(f.top, e.top, description + "'e' and 'f' should be at same top"); - isSimilarTo(f.left, e.left + e.width, 2, description + "left of 'f' should be at similar to right of 'e'"); - is(f.height, e.height, description + "'e' and 'f' should be same height"); - - // 2nd <br> - br2 = synthesizeQueryTextRect(kLFLen + 6, 1); - if (!checkQueryContentResult(br2, description + "rect for 2nd <br>")) { - return; - } - - is(br2.top, f.top, description + "'f' and a line breaker caused by 2nd <br> should be at same top"); - is(br2.height, f.height, description + "'f' and a line breaker caused by 2nd <br> should be same height"); - ok(f.left < br2.left, description + "left of a line breaker caused by 2nd <br> should be bigger than left of 'f', f.left=" + f.left + ", br2.left=" + br2.left); - - // 2nd <br> as array - br2AsArray = synthesizeQueryTextRectArray(kLFLen + 6, 1); - if (!checkQueryContentResult(br2AsArray, description + "2nd <br>'s line breaker as array") || - !checkRectArray(br2AsArray, [br2], description + "query text rect array result of 2nd <br> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - br2_2 = synthesizeQueryTextRect(kLFLen + 7, 1); - if (!checkQueryContentResult(br2_2, description + "rect for \\n of \\r\\n caused by 2nd <br>")) { - return; - } - - is(br2_2.top, br2.top, description + "'\\r' and '\\n' should be at same top"); - is(br2_2.left, br2.left, description + "'\\r' and '\\n' should be at same top"); - is(br2_2.height, br2.height, description + "'\\r' and '\\n' should be same height"); - is(br2_2.width, br2.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var br2_2AsArray = synthesizeQueryTextRectArray(kLFLen + 7, 1); - if (!checkQueryContentResult(br2_2AsArray, description + "rect array for \\n of \\r\\n caused by 2nd <br>") || - !checkRectArray(br2_2AsArray, [br2_2], description + "query text rect array result of \\n of \\r\\n caused by 2nd <br> should match with each query text rect result")) { - return; - } - } - - // 3rd <br> - var br3 = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(br3, description + "rect for next of 3rd <br>")) { - return; - } - - isSimilarTo(br3.top, d.top + d.height, 3, description + "top of next of 3rd <br> should at similar to bottom of 'd'"); - isSimilarTo(br3.left, d.left, 2, description + "left of next of 3rd <br> should be at similar to left of 'd'"); - isSimilarTo(br3.height, d.height, 2, description + "next of 3rd <br> and 'd' should be similar height"); - - // 3rd <br> as array - var br3AsArray = synthesizeQueryTextRectArray(kLFLen + 6, 1); - if (!checkQueryContentResult(br3AsArray, description + "3rd <br>'s line breaker as array") || - !checkRectArray(br3AsArray, [br3], description + "query text rect array result of 3rd <br> should match with each query text rect result")) { - return; - } - - if (kLFLen > 1) { - // \n of \r\n - var br3_2 = synthesizeQueryTextRect(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(br3_2, description + "rect for \\n of \\r\\n caused by 3rd <br>")) { - return; - } - - is(br3_2.top, br3.top, description + "'\\r' and '\\n' should be at same top"); - is(br3_2.left, br3.left, description + "'\\r' and '\\n' should be at same left"); - is(br3_2.height, br3.height, description + "'\\r' and '\\n' should be same height"); - is(br3_2.width, br3.width, description + "'\\r' and '\\n' should be same width"); - - // \n of \r\n as array - var br2_2AsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(br2_2AsArray, description + "rect array for \\n of \\r\\n caused by 3rd <br>") || - !checkRectArray(br2_2AsArray, [br2_2], description + "query text rect array result of \\n of \\r\\n caused by 3rd <br> should match with each query text rect result")) { - return; - } - } - - // next of 3rd <br> - var next_br3 = synthesizeQueryTextRect(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(next_br3, description + "rect for next of 3rd <br>")) { - return; - } - - is(next_br3.top, br3.top, description + "3rd <br> and next of 3rd <br> should be at same top"); - is(next_br3.left, br3.left, description + "3rd <br> and next of 3rd <br> should be at same left"); - is(next_br3.height, br3.height, description + "3rd <br> and next of 3rd <br> should be same height"); - is(next_br3.width, br3.width, description + "3rd <br> and next of 3rd <br> should be same width"); - - // next of 3rd <br> as array - var next_br3AsArray = synthesizeQueryTextRectArray(kLFLen * 3 + 6, 1); - if (!checkQueryContentResult(next_br3AsArray, description + "rect array for next of 3rd <br>") || - !checkRectArray(next_br3AsArray, [next_br3], description + "query text rect array result of next of 3rd <br> should match with each query text rect result")) { - return; - } - - // too big offset for the editor - tooBigOffset = synthesizeQueryTextRect(kLFLen * 3 + 7, 1); - if (!checkQueryContentResult(tooBigOffset, description + "rect for too big offset")) { - return; - } - - is(tooBigOffset.top, next_br3.top, description + "too big offset and next of 3rd <br> should be at same top"); - is(tooBigOffset.left, next_br3.left, description + "too big offset and next of 3rd <br> should be at same left"); - is(tooBigOffset.height, next_br3.height, description + "too big offset and next of 3rd <br> should be same height"); - is(tooBigOffset.width, next_br3.width, description + "too big offset and next of 3rd <br> should be same width"); - - // too big offset for the editors as array - tooBigOffsetAsArray = synthesizeQueryTextRectArray(kLFLen * 2 + 7, 1); - if (!checkQueryContentResult(tooBigOffsetAsArray, description + "rect array for too big offset") || - !checkRectArray(tooBigOffsetAsArray, [tooBigOffset], description + "query text rect array result with too big offset should match with each query text rect result")) { - return; - } -} - -function runCharAtPointTest(aFocusedEditor, aTargetName) -{ - aFocusedEditor.value = "This is a test of the\nContent Events"; - // 012345678901234567890 12345678901234 - // 0 1 2 3 - - aFocusedEditor.focus(); - - const kNone = -1; - const kTestingOffset = [ 0, 10, 20, 21 + kLFLen, 34 + kLFLen]; - const kLeftSideOffset = [ kNone, 9, 19, kNone, 33 + kLFLen]; - const kRightSideOffset = [ 1, 11, kNone, 22 + kLFLen, kNone]; - const kLeftTentativeCaretOffset = [ 0, 10, 20, 21 + kLFLen, 34 + kLFLen]; - const kRightTentativeCaretOffset = [ 1, 11, 21, 22 + kLFLen, 35 + kLFLen]; - - var editorRect = synthesizeQueryEditorRect(); - if (!checkQueryContentResult(editorRect, - "runCharAtPointTest (" + aTargetName + "): editorRect")) { - return; - } - - for (var i = 0; i < kTestingOffset.length; i++) { - var textRect = synthesizeQueryTextRect(kTestingOffset[i], 1); - if (!checkQueryContentResult(textRect, - "runCharAtPointTest (" + aTargetName + "): textRect: i=" + i)) { - continue; - } - - checkRectContainsRect(textRect, editorRect, - "runCharAtPointTest (" + aTargetName + - "): the text rect isn't in the editor"); - - // Test #1, getting same character rect by the point near the top-left. - var charAtPt1 = synthesizeCharAtPoint(textRect.left + 1, - textRect.top + 1); - if (checkQueryContentResult(charAtPt1, - "runCharAtPointTest (" + aTargetName + "): charAtPt1: i=" + i)) { - ok(!charAtPt1.notFound, - "runCharAtPointTest (" + aTargetName + "): charAtPt1 isn't found: i=" + i); - if (!charAtPt1.notFound) { - is(charAtPt1.offset, kTestingOffset[i], - "runCharAtPointTest (" + aTargetName + "): charAtPt1 offset is wrong: i=" + i); - checkRect(charAtPt1, textRect, "runCharAtPointTest (" + aTargetName + - "): charAtPt1 left is wrong: i=" + i); - } - ok(!charAtPt1.tentativeCaretOffsetNotFound, - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt1 isn't found: i=" + i); - if (!charAtPt1.tentativeCaretOffsetNotFound) { - is(charAtPt1.tentativeCaretOffset, kLeftTentativeCaretOffset[i], - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt1 is wrong: i=" + i); - } - } - - // Test #2, getting same character rect by the point near the bottom-right. - var charAtPt2 = synthesizeCharAtPoint(textRect.left + textRect.width - 2, - textRect.top + textRect.height - 2); - if (checkQueryContentResult(charAtPt2, - "runCharAtPointTest (" + aTargetName + "): charAtPt2: i=" + i)) { - ok(!charAtPt2.notFound, - "runCharAtPointTest (" + aTargetName + "): charAtPt2 isn't found: i=" + i); - if (!charAtPt2.notFound) { - is(charAtPt2.offset, kTestingOffset[i], - "runCharAtPointTest (" + aTargetName + "): charAtPt2 offset is wrong: i=" + i); - checkRect(charAtPt2, textRect, "runCharAtPointTest (" + aTargetName + - "): charAtPt1 left is wrong: i=" + i); - } - ok(!charAtPt2.tentativeCaretOffsetNotFound, - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt2 isn't found: i=" + i); - if (!charAtPt2.tentativeCaretOffsetNotFound) { - is(charAtPt2.tentativeCaretOffset, kRightTentativeCaretOffset[i], - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt2 is wrong: i=" + i); - } - } - - // Test #3, getting left character offset. - var charAtPt3 = synthesizeCharAtPoint(textRect.left - 2, - textRect.top + 1); - if (checkQueryContentResult(charAtPt3, - "runCharAtPointTest (" + aTargetName + "): charAtPt3: i=" + i)) { - is(charAtPt3.notFound, kLeftSideOffset[i] == kNone, - kLeftSideOffset[i] == kNone ? - "runCharAtPointTest (" + aTargetName + "): charAtPt3 is found: i=" + i : - "runCharAtPointTest (" + aTargetName + "): charAtPt3 isn't found: i=" + i); - if (!charAtPt3.notFound) { - is(charAtPt3.offset, kLeftSideOffset[i], - "runCharAtPointTest (" + aTargetName + "): charAtPt3 offset is wrong: i=" + i); - } - if (kLeftSideOffset[i] == kNone) { - // There may be no enough padding-left (depends on platform) - todo(false, - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt3 isn't tested: i=" + i); - } else { - ok(!charAtPt3.tentativeCaretOffsetNotFound, - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt3 isn't found: i=" + i); - if (!charAtPt3.tentativeCaretOffsetNotFound) { - is(charAtPt3.tentativeCaretOffset, kLeftTentativeCaretOffset[i], - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt3 is wrong: i=" + i); - } - } - } - - // Test #4, getting right character offset. - var charAtPt4 = synthesizeCharAtPoint(textRect.left + textRect.width + 1, - textRect.top + textRect.height - 2); - if (checkQueryContentResult(charAtPt4, - "runCharAtPointTest (" + aTargetName + "): charAtPt4: i=" + i)) { - is(charAtPt4.notFound, kRightSideOffset[i] == kNone, - kRightSideOffset[i] == kNone ? - "runCharAtPointTest (" + aTargetName + "): charAtPt4 is found: i=" + i : - "runCharAtPointTest (" + aTargetName + "): charAtPt4 isn't found: i=" + i); - if (!charAtPt4.notFound) { - is(charAtPt4.offset, kRightSideOffset[i], - "runCharAtPointTest (" + aTargetName + "): charAtPt4 offset is wrong: i=" + i); - } - ok(!charAtPt4.tentativeCaretOffsetNotFound, - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt4 isn't found: i=" + i); - if (!charAtPt4.tentativeCaretOffsetNotFound) { - is(charAtPt4.tentativeCaretOffset, kRightTentativeCaretOffset[i], - "runCharAtPointTest (" + aTargetName + "): tentative caret offset for charAtPt4 is wrong: i=" + i); - } - } - } -} - -function runCharAtPointAtOutsideTest() -{ - textarea.focus(); - textarea.value = "some text"; - var editorRect = synthesizeQueryEditorRect(); - if (!checkQueryContentResult(editorRect, - "runCharAtPointAtOutsideTest: editorRect")) { - return; - } - // Check on a text node which is at the outside of editor. - var charAtPt = synthesizeCharAtPoint(editorRect.left + 20, - editorRect.top - 10); - if (checkQueryContentResult(charAtPt, - "runCharAtPointAtOutsideTest: charAtPt")) { - ok(charAtPt.notFound, - "runCharAtPointAtOutsideTest: charAtPt is found on outside of editor"); - ok(charAtPt.tentativeCaretOffsetNotFound, - "runCharAtPointAtOutsideTest: tentative caret offset for charAtPt is found on outside of editor"); - } -} - -function runSetSelectionEventTest() -{ - contenteditable.focus(); - - var selection = windowOfContenteditable.getSelection(); - - // #1 - contenteditable.innerHTML = "abc<br>def"; - - synthesizeSelectionSet(0, 100); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node of the editor"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of children"); - checkSelection(0, "abc" + kLF + "def", "runSetSelectionEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(2, 2 + kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 2, - "runSetSelectionEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 2"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(2, "c" + kLF + "d", "runSetSelectionEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(1, 2); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the first text node"); - is(selection.focusOffset, contenteditable.firstChild.wholeText.length, - "runSetSelectionEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the text node"); - checkSelection(1, "bc", "runSetSelectionEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, contenteditable.firstChild.wholeText.length, - "runSetSelectionEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the first text node"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 2, - "runSetSelectionEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be the index of the last text node"); - checkSelection(3, kLF, "runSetSelectionEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(6+kLFLen, 0); - is(selection.anchorNode, contenteditable.lastChild, - "runSetSelectionEventTest #1 (6+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, contenteditable.lastChild.wholeText.length, - "runSetSelectionEventTest #1 (6+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #1 (6+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.anchorOffset, contenteditable.lastChild.wholeText.length, - "runSetSelectionEventTest #1 (6+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(6 + kLFLen, "", "runSetSelectionEventTest #1 (6+kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(100, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #1 (100, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node of the editor"); - is(selection.anchorOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #1 (100, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of children"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #1 (100, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node of the editor"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #1 (100, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of children"); - checkSelection(6 + kLFLen, "", "runSetSelectionEventTest #1 (100, 0), \"" + contenteditable.innerHTML + "\""); - - // #2 - contenteditable.innerHTML = "<p>a<b>b</b>c</p><p>def</p>"; - - synthesizeSelectionSet(kLFLen, 4+kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the first <p> node"); - is(selection.focusNode, contenteditable.lastChild.firstChild, - "runSetSelectionEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the second <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(kLFLen, "abc" + kLF + "d", "runSetSelectionEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 2); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the first <p> node"); - is(selection.focusNode, contenteditable.firstChild.childNodes.item(1).firstChild, - "runSetSelectionEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <b> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.item(1).firstChild.wholeText.length, - "runSetSelectionEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the text node in the <b> node"); - checkSelection(kLFLen, "ab", "runSetSelectionEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(1+kLFLen, 2); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node in the first <p> node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node in the first <p> node"); - checkSelection(1+kLFLen, "bc", "runSetSelectionEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(2+kLFLen, 2+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.childNodes.item(1).firstChild, - "runSetSelectionEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node in the <b> node"); - is(selection.anchorOffset, contenteditable.firstChild.childNodes.item(1).firstChild.wholeText.length, - "runSetSelectionEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the text node in the <b> node"); - is(selection.focusNode, contenteditable.lastChild.firstChild, - "runSetSelectionEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the last <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(2+kLFLen, "c" + kLF + "d", "runSetSelectionEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen*2, 1); - is(selection.anchorNode, contenteditable.lastChild, - "runSetSelectionEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the second <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the second <p> node"); - is(selection.focusNode, contenteditable.lastChild.firstChild, - "runSetSelectionEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the second <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(3+kLFLen*2, "d", "runSetSelectionEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #2 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #2 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #2 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #2 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #2 (0, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the first <p> node"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the first <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, kLF, "runSetSelectionEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(2+kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.childNodes.item(1).firstChild, - "runSetSelectionEventTest #2 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node of the <b> node"); - is(selection.anchorOffset, contenteditable.firstChild.childNodes.item(1).firstChild.wholeText.length, - "runSetSelectionEventTest #2 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node of the first <b> node"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #2 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the second <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #2 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(2+kLFLen, "c" + kLF, "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node of the first <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node of the first <p> node"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the second <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(3+kLFLen, kLF, "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #2 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node of the first <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #2 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node of the first <p> node"); - is(selection.focusNode, contenteditable.lastChild.firstChild, - "runSetSelectionEventTest #2 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node of the second <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #2 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(3+kLFLen, kLF + "d", "runSetSelectionEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #3 - contenteditable.innerHTML = "<div>abc<p>def</p></div>"; - - synthesizeSelectionSet(1+kLFLen, 2); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the first text node"); - is(selection.focusOffset, contenteditable.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the first text node"); - checkSelection(1+kLFLen, "bc", "runSetSelectionEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(1+kLFLen, 3+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(1+kLFLen, "bc" + kLF + "d", "runSetSelectionEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen, 0); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (3+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, contenteditable.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (3+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the first text node"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (3+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the first text node"); - is(selection.focusOffset, contenteditable.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (3+kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the first text node"); - checkSelection(3+kLFLen, "", "runSetSelectionEventTest #3 (3+kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 6+kLFLen*2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(0, kLF + "abc" + kLF + "def", "runSetSelectionEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 100); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(0, kLF + "abc" + kLF + "def", "runSetSelectionEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(4+kLFLen*2, 2); - is(selection.anchorNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(4+kLFLen*2, "ef", "runSetSelectionEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(4+kLFLen*2, 100); - is(selection.anchorNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(4+kLFLen*2, "ef", "runSetSelectionEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(6+kLFLen*2, 0); - is(selection.anchorNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node"); - is(selection.focusNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(6+kLFLen*2, "", "runSetSelectionEventTest #3 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(6+kLFLen*2, 1); - is(selection.anchorNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(6+kLFLen*2, "", "runSetSelectionEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the first text node"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <div> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, kLF, "runSetSelectionEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 1+kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <div> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the first text node of the <div> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(0, kLF + "a", "runSetSelectionEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(2+kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node of the <div> node"); - is(selection.anchorOffset, 2, - "runSetSelectionEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 2"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(2+kLFLen, "c" + kLF, "runSetSelectionEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node of the <div> node"); - is(selection.anchorOffset, contenteditable.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the text node of the <div> node"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(3+kLFLen, kLF, "runSetSelectionEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node of the <div> node"); - is(selection.anchorOffset, contenteditable.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the text node of the <div> node"); - is(selection.focusNode, contenteditable.firstChild.lastChild.firstChild, - "runSetSelectionEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node of the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(3+kLFLen, kLF + "d", "runSetSelectionEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #4 - contenteditable.innerHTML = "<div><p>abc</p>def</div>"; - - synthesizeSelectionSet(1+kLFLen*2, 2); - is(selection.anchorNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node in the <p> node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the text node in the <p> node"); - checkSelection(1+kLFLen*2, "bc", "runSetSelectionEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(1+kLFLen*2, 3); - is(selection.anchorNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node in the <p> node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(1+kLFLen*2, "bcd", "runSetSelectionEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(3+kLFLen*2, 0); - is(selection.anchorNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (3+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node in the <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #4 (3+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the text node in the <p> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (3+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.firstChild.firstChild.wholeText.length, - "runSetSelectionEventTest #4 (3+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the text node in the <p> node"); - checkSelection(3+kLFLen*2, "", "runSetSelectionEventTest #4 (3+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 6+kLFLen*2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(0, kLF + kLF + "abcdef", "runSetSelectionEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 100); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(0, kLF + kLF + "abcdef", "runSetSelectionEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(4+kLFLen*2, 2); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(4+kLFLen*2, "ef", "runSetSelectionEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(4+kLFLen*2, 100); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(4+kLFLen*2, "ef", "runSetSelectionEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(6+kLFLen*2, 0); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #4 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node"); - is(selection.focusNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #4 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(6+kLFLen*2, "", "runSetSelectionEventTest #4 (6+kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(6+kLFLen*2, 1); - is(selection.anchorNode, contenteditable.firstChild.lastChild, - "runSetSelectionEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the last text node"); - is(selection.anchorOffset, contenteditable.firstChild.lastChild.wholeText.length, - "runSetSelectionEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the length of the last text node"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(6+kLFLen*2, "", "runSetSelectionEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <div> node"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <div> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, kLF, "runSetSelectionEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen*2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <div> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, kLF + kLF, "runSetSelectionEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 1+kLFLen*2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #4 (0, 1+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (0, 1+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <div> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (0, 1+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #4 (0, 1+kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(0, kLF + kLF + "a", "runSetSelectionEventTest #4 (0, 1+kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 0); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #4 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <div> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #4 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <div> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #4 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #4 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <div> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <p> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(kLFLen, kLF, "runSetSelectionEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #4 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <div> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #4 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <p> node"); - is(selection.focusNode, contenteditable.firstChild.firstChild.firstChild, - "runSetSelectionEventTest #4 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node in the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #4 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(kLFLen, kLF +"a", "runSetSelectionEventTest #4 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #5 - contenteditable.innerHTML = "<br>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #5 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #5 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #5 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #5 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #5 (0, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(0, kLF, "runSetSelectionEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #5 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #5 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the root's children"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #5 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #5 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #5 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 1); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the root's children"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\""); - - // #6 - contenteditable.innerHTML = "<p><br></p>"; - - synthesizeSelectionSet(kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(kLFLen, kLF, "runSetSelectionEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen*2, 0); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #6 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the <p>'s children"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #6 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(kLFLen*2, "", "runSetSelectionEventTest #6 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen*2, 1); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #6 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the root's children"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #6 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #6 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen*2, "", "runSetSelectionEventTest #6 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, kLF, "runSetSelectionEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen*2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(0, kLF + kLF, "runSetSelectionEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 0); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #6 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #6 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #6 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #6 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - // #7 - contenteditable.innerHTML = "<br><br>"; - - synthesizeSelectionSet(0, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(0, kLF, "runSetSelectionEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, kLFLen * 2); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(0, kLF + kLF, "runSetSelectionEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #7 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #7 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #7 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, kLFLen); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen, kLFLen) selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen, kLF, "runSetSelectionEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen * 2, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #7 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the root's children"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #7 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #7 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen * 2, "", "runSetSelectionEventTest #7 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - // #8 - contenteditable.innerHTML = "<p><br><br></p>"; - - synthesizeSelectionSet(kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #8 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #8 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(kLFLen, kLF, "runSetSelectionEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, kLFLen * 2); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(kLFLen, kLF + kLF, "runSetSelectionEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen*2, 0); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #8 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #8 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 1"); - checkSelection(kLFLen*2, "", "runSetSelectionEventTest #8 (kLFLen*2, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen*2, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*2, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #8 (kLFLen*2, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*2, kLFLen) selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #8 (kLFLen*2, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(kLFLen*2, kLF, "runSetSelectionEventTest #8 (kLFLen*2, kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen*3, 0); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*3, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the <p> node"); - is(selection.anchorOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #8 (kLFLen*3, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the count of the <p>'s children"); - is(selection.focusNode, contenteditable.firstChild, - "runSetSelectionEventTest #8 (kLFLen*3, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, contenteditable.firstChild.childNodes.length, - "runSetSelectionEventTest #8 (kLFLen*3, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the <p>'s children"); - checkSelection(kLFLen*3, "", "runSetSelectionEventTest #8 (kLFLen*3, 0), \"" + contenteditable.innerHTML + "\""); - - // #9 (ContentEventHandler cannot distinguish if <p> can have children, so, the result is same as case #5, "<br>") - contenteditable.innerHTML = "<p></p>"; - - synthesizeSelectionSet(kLFLen, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <p> node + 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the <p> node"); - is(selection.focusOffset, 1, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be the index of the <p> node + 1"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(kLFLen, 1); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be the index of the <p> node + 1"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #9 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #9 (kLFLen, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(kLFLen, "", "runSetSelectionEventTest #9 (kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - // #10 - contenteditable.innerHTML = ""; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #10 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #10 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #10 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #10 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #10 (0, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 1); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #10 (0, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #10 (0, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #10 (0, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #10 (0, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #10 (0, 1), \"" + contenteditable.innerHTML + "\""); - - // #11 - contenteditable.innerHTML = "<span></span><i><u></u></i>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #11 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #11 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #11 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #11 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #11 (0, 0), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(0, 1); - is(selection.anchorNode, contenteditable, - "runSetSelectionEventTest #11 (0, 1), \"" + contenteditable.innerHTML + "\": selection anchor node should be the root node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #11 (0, 1), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable, - "runSetSelectionEventTest #11 (0, 1), \"" + contenteditable.innerHTML + "\": selection focus node should be the root node"); - is(selection.focusOffset, contenteditable.childNodes.length, - "runSetSelectionEventTest #11 (0, 1), \"" + contenteditable.innerHTML + "\": selection focus offset should be the count of the root's children"); - checkSelection(0, "", "runSetSelectionEventTest #11 (0, 1), \"" + contenteditable.innerHTML + "\""); - - // #12 - contenteditable.innerHTML = "<span>abc</span><i><u></u></i>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #12 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #12 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.firstChild.firstChild, - "runSetSelectionEventTest #12 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #12 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #12 (0, 0), \"" + contenteditable.innerHTML + "\""); - - // #13 - contenteditable.innerHTML = "<span></span><i>abc<u></u></i>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable.childNodes.item(1).firstChild, - "runSetSelectionEventTest #13 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #13 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.childNodes.item(1).firstChild, - "runSetSelectionEventTest #13 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #13 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #13 (0, 0), \"" + contenteditable.innerHTML + "\""); - - // #14 - contenteditable.innerHTML = "<span></span><i><u>abc</u></i>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable.childNodes.item(1).firstChild.firstChild, - "runSetSelectionEventTest #14 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #14 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.childNodes.item(1).firstChild.firstChild, - "runSetSelectionEventTest #14 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #14 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #14 (0, 0), \"" + contenteditable.innerHTML + "\""); - - // #15 - contenteditable.innerHTML = "<span></span><i><u></u>abc</i>"; - - synthesizeSelectionSet(0, 0); - is(selection.anchorNode, contenteditable.childNodes.item(1).lastChild, - "runSetSelectionEventTest #15 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #15 (0, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.childNodes.item(1).lastChild, - "runSetSelectionEventTest #15 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the text node"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #15 (0, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(0, "", "runSetSelectionEventTest #15 (0, 0), \"" + contenteditable.innerHTML + "\""); - - // #16 - contenteditable.innerHTML = "a<blink>b</blink>c"; - synthesizeSelectionSet(0, 3); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first text node"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\": selection focus node should be the last text node"); - is(selection.focusOffset, contenteditable.lastChild.wholeText.length, - "runSetSelectionEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\": selection focus offset should be the length of the last text node"); - checkSelection(0, "abc", "runSetSelectionEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\""); - - // #17 (bug 1319660 - incorrect adjustment of content iterator last node) - contenteditable.innerHTML = "<div>a</div><div><br></div>"; - - synthesizeSelectionSet(kLFLen, 1+kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #17 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first <div> element"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #17 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #17 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the second <div> element"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #17 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(kLFLen, "a" + kLF, "runSetSelectionEventTest #17 (kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - synthesizeSelectionSet(1+2*kLFLen, 0); - is(selection.anchorNode, contenteditable.lastChild, - "runSetSelectionEventTest #17 (1+2*kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor node should be the second <div> element"); - is(selection.anchorOffset, 0, - "runSetSelectionEventTest #17 (1+2*kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 0"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #17 (1+2*kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus node should be the second <div> element"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #17 (1+2*kLFLen, 0), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(1+2*kLFLen, "", "runSetSelectionEventTest #17 (1+2*kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - // #18 (bug 1319660 - content iterator start node regression) - contenteditable.innerHTML = "<div><br></div><div><br></div>"; - - synthesizeSelectionSet(2*kLFLen, kLFLen); - is(selection.anchorNode, contenteditable.firstChild, - "runSetSelectionEventTest #18 (2*kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor node should be the first <div> element"); - is(selection.anchorOffset, 1, - "runSetSelectionEventTest #18 (2*kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection anchor offset should be 1"); - is(selection.focusNode, contenteditable.lastChild, - "runSetSelectionEventTest #18 (2*kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus node should be the second <div> element"); - is(selection.focusOffset, 0, - "runSetSelectionEventTest #18 (2*kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\": selection focus offset should be 0"); - checkSelection(2*kLFLen, kLF, "runSetSelectionEventTest #18 (2*kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); -} - -function runQueryTextContentEventTest() -{ - contenteditable.focus(); - - var result; - - // #1 - contenteditable.innerHTML = "abc<br>def"; - - result = synthesizeQueryTextContent(0, 6 + kLFLen); - is(result.text, "abc" + kLF + "def", "runQueryTextContentEventTest #1 (0, 6+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 100); - is(result.text, "abc" + kLF + "def", "runQueryTextContentEventTest #1 (0, 100), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(2, 2 + kLFLen); - is(result.text, "c" + kLF + "d", "runQueryTextContentEventTest #1 (2, 2+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(1, 2); - is(result.text, "bc", "runQueryTextContentEventTest #1 (1, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #1 (3, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(6 + kLFLen, 1); - is(result.text, "", "runQueryTextContentEventTest #1 (6 + kLFLen, 0), \"" + contenteditable.innerHTML + "\""); - - // #2 - contenteditable.innerHTML = "<p>a<b>b</b>c</p><p>def</p>"; - - result = synthesizeQueryTextContent(kLFLen, 4+kLFLen); - is(result.text, "abc" + kLF + "d", "runQueryTextContentEventTest #2 (kLFLen, 4+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, 2); - is(result.text, "ab", "runQueryTextContentEventTest #2 (kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(1+kLFLen, 2); - is(result.text, "bc", "runQueryTextContentEventTest #2 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(2+kLFLen, 2+kLFLen); - is(result.text, "c" + kLF + "d", "runQueryTextContentEventTest #2 (2+kLFLen, 2+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen*2, 1); - is(result.text, "d", "runQueryTextContentEventTest #2 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #2 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(2+kLFLen, 1+kLFLen); - is(result.text, "c" + kLF, "runQueryTextContentEventTest #2 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #2 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen, 1+kLFLen); - is(result.text, kLF + "d", "runQueryTextContentEventTest #2 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #3 - contenteditable.innerHTML = "<div>abc<p>def</p></div>"; - - result = synthesizeQueryTextContent(1+kLFLen, 2); - is(result.text, "bc", "runQueryTextContentEventTest #3 (1+kLFLen, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(1+kLFLen, 3+kLFLen); - is(result.text, "bc" + kLF + "d", "runQueryTextContentEventTest #3 (1+kLFLen, 3+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen*2, 1); - is(result.text, "d", "runQueryTextContentEventTest #3 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 6+kLFLen*2); - is(result.text, kLF + "abc" + kLF + "def", "runQueryTextContentEventTest #3 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 100); - is(result.text, kLF + "abc" + kLF + "def", "runQueryTextContentEventTest #3 (0, 100), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(4+kLFLen*2, 2); - is(result.text, "ef", "runQueryTextContentEventTest #3 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(4+kLFLen*2, 100); - is(result.text, "ef", "runQueryTextContentEventTest #3 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(6+kLFLen*2, 1); - is(result.text, "", "runQueryTextContentEventTest #3 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #3 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 1+kLFLen); - is(result.text, kLF + "a", "runQueryTextContentEventTest #3 (0, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(2+kLFLen, 1+kLFLen); - is(result.text, "c" + kLF, "runQueryTextContentEventTest #3 (2+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #3 (3+kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen, 1+kLFLen); - is(result.text, kLF + "d", "runQueryTextContentEventTest #3 (3+kLFLen, 1+kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #4 - contenteditable.innerHTML = "<div><p>abc</p>def</div>"; - - result = synthesizeQueryTextContent(1+kLFLen*2, 2); - is(result.text, "bc", "runQueryTextContentEventTest #4 (1+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(1+kLFLen*2, 3); - is(result.text, "bcd", "runQueryTextContentEventTest #4 (1+kLFLen*2, 3), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(3+kLFLen*2, 1); - is(result.text, "d", "runQueryTextContentEventTest #4 (3+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 6+kLFLen*2); - is(result.text, kLF + kLF + "abcdef", "runQueryTextContentEventTest #4 (0, 6+kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 100); - is(result.text, kLF + kLF + "abcdef", "runQueryTextContentEventTest #4 (0, 100), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(4+kLFLen*2, 2); - is(result.text, "ef", "runQueryTextContentEventTest #4 (4+kLFLen*2, 2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(4+kLFLen*2, 100); - is(result.text, "ef", "runQueryTextContentEventTest #4 (4+kLFLen*2, 100), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(6+kLFLen*2, 1); - is(result.text, "", "runQueryTextContentEventTest #4 (6+kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #4 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen*2); - is(result.text, kLF + kLF, "runQueryTextContentEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, 1+kLFLen*2); - is(result.text, kLF + kLF + "a", "runQueryTextContentEventTest #4 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, 1+kLFLen); - is(result.text, kLF + "a", "runQueryTextContentEventTest #4 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - // #5 - contenteditable.innerHTML = "<br>"; - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #5 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, 1); - is(result.text, "", "runQueryTextContentEventTest #5 (kLFLen, 1), \"" + contenteditable.innerHTML + "\""); - - // #6 - contenteditable.innerHTML = "<p><br></p>"; - - result = synthesizeQueryTextContent(kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #6 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen*2, 1); - is(result.text, "", "runQueryTextContentEventTest #5 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #6 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen*2); - is(result.text, kLF + kLF, "runQueryTextContentEventTest #6 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - // #7 - contenteditable.innerHTML = "<br><br>"; - - result = synthesizeQueryTextContent(0, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #7 (0, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(0, kLFLen * 2); - is(result.text, kLF + kLF, "runQueryTextContentEventTest #7 (0, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #7 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen * 2, 1); - is(result.text, "", "runQueryTextContentEventTest #7 (kLFLen*2, 1), \"" + contenteditable.innerHTML + "\""); - - // #8 - contenteditable.innerHTML = "<p><br><br></p>"; - - result = synthesizeQueryTextContent(kLFLen, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #8 (kLFLen, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen, kLFLen * 2); - is(result.text, kLF + kLF, "runQueryTextContentEventTest #8 (kLFLen, kLFLen*2), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen*2, kLFLen); - is(result.text, kLF, "runQueryTextContentEventTest #8 (kLFLen*2, kLFLen), \"" + contenteditable.innerHTML + "\""); - - result = synthesizeQueryTextContent(kLFLen*3, 1); - is(result.text, "", "runQueryTextContentEventTest #8 (kLFLen*3, 1), \"" + contenteditable.innerHTML + "\""); - - // #16 - contenteditable.innerHTML = "a<blink>b</blink>c"; - - result = synthesizeQueryTextContent(0, 3); - is(result.text, "abc", "runQueryTextContentEventTest #16 (0, 3), \"" + contenteditable.innerHTML + "\""); -} - -function runQueryIMESelectionTest() -{ - textarea.focus(); - textarea.value = "before after"; - var startoffset = textarea.selectionStart = textarea.selectionEnd = "before ".length; - - if (!checkIMESelection("RawClause", false, 0, "", "runQueryIMESelectionTest: before starting composition") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: before starting composition") || - !checkIMESelection("ConvertedClause", false, 0, "", "runQueryIMESelectionTest: before starting composition") || - !checkIMESelection("SelectedClause", false, 0, "", "runQueryIMESelectionTest: before starting composition")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "a", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkIMESelection("RawClause", true, startoffset, "a", "runQueryIMESelectionTest: inputting raw text") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: inputting raw text") || - !checkIMESelection("ConvertedClause", false, 0, "", "runQueryIMESelectionTest: inputting raw text") || - !checkIMESelection("SelectedClause", false, 0, "", "runQueryIMESelectionTest: inputting raw text")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "abcdefgh", - "clauses": - [ - { "length": 8, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 8, "length": 0 } - }); - - if (!checkIMESelection("RawClause", true, startoffset, "abcdefgh", "runQueryIMESelectionTest: updating raw text") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: updating raw text") || - !checkIMESelection("ConvertedClause", false, 0, "", "runQueryIMESelectionTest: updating raw text") || - !checkIMESelection("SelectedClause", false, 0, "", "runQueryIMESelectionTest: updating raw text")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "ABCDEFGH", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 3, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 3, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkIMESelection("RawClause", false, 0, "", "runQueryIMESelectionTest: starting to convert") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: starting to convert") || - !checkIMESelection("ConvertedClause", true, startoffset + 2, "CDE", "runQueryIMESelectionTest: starting to convert") || - !checkIMESelection("SelectedClause", true, startoffset, "AB", "runQueryIMESelectionTest: starting to convert")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "ABCDEFGH", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 3, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 3, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - if (!checkIMESelection("RawClause", false, 0, "", "runQueryIMESelectionTest: changing selected clause") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: changing selected clause") || - !checkIMESelection("ConvertedClause", true, startoffset, "AB", "runQueryIMESelectionTest: changing selected clause") || - !checkIMESelection("SelectedClause", true, startoffset + 2, "CDE", "runQueryIMESelectionTest: changing selected clause")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); - - if (!checkIMESelection("RawClause", false, 0, "", "runQueryIMESelectionTest: after committing composition") || - !checkIMESelection("SelectedRawClause", false, 0, "", "runQueryIMESelectionTest: after committing composition") || - !checkIMESelection("ConvertedClause", false, 0, "", "runQueryIMESelectionTest: after committing composition") || - !checkIMESelection("SelectedClause", false, 0, "", "runQueryIMESelectionTest: after committing composition")) { - return; - } - - startoffset = textarea.selectionStart; - - synthesizeCompositionChange( - { "composition": - { "string": "abcdefgh", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_RAW_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_RAW_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - ] - }, - "caret": { "start": 8, "length": 0 } - }); - - if (!checkIMESelection("RawClause", true, startoffset, "a", "runQueryIMESelectionTest: unrealistic testcase") || - !checkIMESelection("SelectedRawClause", true, startoffset + 1, "b", "runQueryIMESelectionTest: unrealistic testcase") || - !checkIMESelection("ConvertedClause", true, startoffset + 2, "c", "runQueryIMESelectionTest: unrealistic testcase") || - !checkIMESelection("SelectedClause", true, startoffset + 3, "d", "runQueryIMESelectionTest: unrealistic testcase")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); -} - -function runQueryContentEventRelativeToInsertionPoint() -{ - textarea.focus(); - textarea.value = "0123456789"; - - var startoffset = textarea.selectionStart = textarea.selectionEnd = 0; - - if (!checkContentRelativeToSelection(0, 1, 0, "0", "runQueryContentEventRelativeToInsertionPoint[0-0]", "#1") || - !checkContentRelativeToSelection(-1, 1, 0, "0", "runQueryContentEventRelativeToInsertionPoint[0-0]", "#2") || - !checkContentRelativeToSelection(1, 1, 1, "1", "runQueryContentEventRelativeToInsertionPoint[0-0]", "#3") || - !checkContentRelativeToSelection(5, 10, 5, "56789", "runQueryContentEventRelativeToInsertionPoint[0-0]", "#4") || - !checkContentRelativeToSelection(10, 1, 10, "", "runQueryContentEventRelativeToInsertionPoint[0-0]", "#5")) { - return; - } - - textarea.selectionEnd = 5; - - if (!checkContentRelativeToSelection(0, 1, 0, "0", "runQueryContentEventRelativeToInsertionPoint[0-5]", "#1") || - !checkContentRelativeToSelection(-1, 1, 0, "0", "runQueryContentEventRelativeToInsertionPoint[0-5]", "#2") || - !checkContentRelativeToSelection(1, 1, 1, "1", "runQueryContentEventRelativeToInsertionPoint[0-5]", "#3") || - !checkContentRelativeToSelection(5, 10, 5, "56789", "runQueryContentEventRelativeToInsertionPoint[0-5]", "#4") || - !checkContentRelativeToSelection(10, 1, 10, "", "runQueryContentEventRelativeToInsertionPoint[0-5]"), "#5") { - return; - } - - startoffset = textarea.selectionStart = textarea.selectionEnd = 4; - - if (!checkContentRelativeToSelection(0, 1, startOffset + 0, "4", "runQueryContentEventRelativeToInsertionPoint[4-4]", "#1") || - !checkContentRelativeToSelection(-1, 1, startOffset - 1, "3", "runQueryContentEventRelativeToInsertionPoint[4-4]", "#2") || - !checkContentRelativeToSelection(1, 1, startOffset + 1, "5", "runQueryContentEventRelativeToInsertionPoint[4-4]", "#3") || - !checkContentRelativeToSelection(5, 10, startOffset + 5, "9", "runQueryContentEventRelativeToInsertionPoint[4-4]", "#4") || - !checkContentRelativeToSelection(10, 1, 10, "", "runQueryContentEventRelativeToInsertionPoint[4-4]", "#5")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "a", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContentRelativeToSelection(0, 1, startOffset + 0, "a", "runQueryContentEventRelativeToInsertionPoint[composition at 4]", "#1") || - !checkContentRelativeToSelection(-1, 1, startOffset - 1, "3", "runQueryContentEventRelativeToInsertionPoint[composition at 4]", "#2") || - !checkContentRelativeToSelection(1, 1, startOffset + 1, "4", "runQueryContentEventRelativeToInsertionPoint[composition at 4]", "#3") || - !checkContentRelativeToSelection(5, 10, startOffset + 5, "89", "runQueryContentEventRelativeToInsertionPoint[composition at 4]", "#4") || - !checkContentRelativeToSelection(11, 1, 11, "", "runQueryContentEventRelativeToInsertionPoint[composition at 4]")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); - - // Move start of composition at first compositionupdate event. - function onCompositionUpdate(aEvent) - { - startoffset = textarea.selectionStart = textarea.selectionEnd = textarea.selectionStart - 1; - textarea.removeEventListener("compositionupdate", onCompositionUpdate); - } - textarea.addEventListener("compositionupdate", onCompositionUpdate); - - synthesizeCompositionChange( - { "composition": - { "string": "a", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContentRelativeToSelection(0, 1, startOffset + 0, "b", "runQueryContentEventRelativeToInsertionPoint[composition at 3]", "#1") || - !checkContentRelativeToSelection(-1, 1, startOffset - 1, "3", "runQueryContentEventRelativeToInsertionPoint[composition at 3]", "#2") || - !checkContentRelativeToSelection(1, 1, startOffset + 1, "a", "runQueryContentEventRelativeToInsertionPoint[composition at 3]", "#3") || - !checkContentRelativeToSelection(5, 10, startOffset + 5, "789", "runQueryContentEventRelativeToInsertionPoint[composition at 3]", "#4") || - !checkContentRelativeToSelection(12, 1, 12, "", "runQueryContentEventRelativeToInsertionPoint[composition at 3]", "#5")) { - synthesizeComposition({ type: "compositioncommitasis" }); - return; - } - - synthesizeComposition({ type: "compositioncommitasis" }); -} - -function runCSSTransformTest() -{ - textarea.focus(); - textarea.value = "some text"; - textarea.selectionStart = textarea.selectionEnd = textarea.value.length; - var editorRect = synthesizeQueryEditorRect(); - if (!checkQueryContentResult(editorRect, - "runCSSTransformTest: editorRect")) { - return; - } - var firstCharRect = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(firstCharRect, - "runCSSTransformTest: firstCharRect")) { - return; - } - var lastCharRect = synthesizeQueryTextRect(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRect, - "runCSSTransformTest: lastCharRect")) { - return; - } - var caretRect = synthesizeQueryCaretRect(textarea.selectionStart); - if (!checkQueryContentResult(caretRect, - "runCSSTransformTest: caretRect")) { - return; - } - var caretRectBeforeFirstChar = synthesizeQueryCaretRect(0); - if (!checkQueryContentResult(caretRectBeforeFirstChar, - "runCSSTransformTest: caretRectBeforeFirstChar")) { - return; - } - - try { - textarea.style.transform = "translate(10px, 15px)"; - function movedRect(aRect, aX, aY) - { - return { left: aRect.left + aX, top: aRect.top + aY, width: aRect.width, height: aRect.height } - } - - var editorRectTranslated = synthesizeQueryEditorRect(); - if (!checkQueryContentResult(editorRectTranslated, - "runCSSTransformTest: editorRectTranslated, " + textarea.style.transform) || - !checkRect(editorRectTranslated, movedRect(editorRect, 10, 15), - "runCSSTransformTest: editorRectTranslated, " + textarea.style.transform)) { - return; - } - var firstCharRectTranslated = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(firstCharRectTranslated, - "runCSSTransformTest: firstCharRectTranslated, " + textarea.style.transform) || - !checkRect(firstCharRectTranslated, movedRect(firstCharRect, 10, 15), - "runCSSTransformTest: firstCharRectTranslated, " + textarea.style.transform)) { - return; - } - var lastCharRectTranslated = synthesizeQueryTextRect(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslated, - "runCSSTransformTest: lastCharRectTranslated, " + textarea.style.transform) || - !checkRect(lastCharRectTranslated, movedRect(lastCharRect, 10, 15), - "runCSSTransformTest: lastCharRectTranslated, " + textarea.style.transform)) { - return; - } - var caretRectTranslated = synthesizeQueryCaretRect(textarea.selectionStart); - if (!checkQueryContentResult(caretRectTranslated, - "runCSSTransformTest: caretRectTranslated, " + textarea.style.transform) || - !checkRect(caretRectTranslated, movedRect(caretRect, 10, 15), - "runCSSTransformTest: caretRectTranslated, " + textarea.style.transform)) { - return; - } - var caretRectBeforeFirstCharTranslated = synthesizeQueryCaretRect(0); - if (!checkQueryContentResult(caretRectBeforeFirstCharTranslated, - "runCSSTransformTest: caretRectBeforeFirstCharTranslated, " + textarea.style.transform) || - !checkRect(caretRectBeforeFirstCharTranslated, movedRect(caretRectBeforeFirstChar, 10, 15), - "runCSSTransformTest: caretRectBeforeFirstCharTranslated, " + textarea.style.transform)) { - return; - } - var firstCharRectTranslatedAsArray = synthesizeQueryTextRectArray(0, 1); - if (!checkQueryContentResult(firstCharRectTranslatedAsArray, "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(firstCharRectTranslatedAsArray, [firstCharRectTranslated], "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - var lastCharRectTranslatedAsArray = synthesizeQueryTextRectArray(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslatedAsArray, "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(lastCharRectTranslatedAsArray, [lastCharRectTranslated], "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - - // XXX It's too difficult to check the result with scale and rotate... - // For now, let's check if query text rect and query text rect array returns same rect. - textarea.style.transform = "scale(1.5)"; - firstCharRectTranslated = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(firstCharRectTranslated, - "runCSSTransformTest: firstCharRectTranslated, " + textarea.style.transform)) { - return; - } - lastCharRectTranslated = synthesizeQueryTextRect(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslated, - "runCSSTransformTest: lastCharRectTranslated, " + textarea.style.transform)) { - return; - } - firstCharRectTranslatedAsArray = synthesizeQueryTextRectArray(0, 1); - if (!checkQueryContentResult(firstCharRectTranslatedAsArray, "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(firstCharRectTranslatedAsArray, [firstCharRectTranslated], "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - lastCharRectTranslatedAsArray = synthesizeQueryTextRectArray(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslatedAsArray, "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(lastCharRectTranslatedAsArray, [lastCharRectTranslated], "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - - textarea.style.transform = "rotate(30deg)"; - firstCharRectTranslated = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(firstCharRectTranslated, - "runCSSTransformTest: firstCharRectTranslated, " + textarea.style.transform)) { - return; - } - lastCharRectTranslated = synthesizeQueryTextRect(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslated, - "runCSSTransformTest: lastCharRectTranslated, " + textarea.style.transform)) { - return; - } - firstCharRectTranslatedAsArray = synthesizeQueryTextRectArray(0, 1); - if (!checkQueryContentResult(firstCharRectTranslatedAsArray, "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(firstCharRectTranslatedAsArray, [firstCharRectTranslated], "runCSSTransformTest: firstCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - lastCharRectTranslatedAsArray = synthesizeQueryTextRectArray(textarea.value.length - 1, textarea.value.length); - if (!checkQueryContentResult(lastCharRectTranslatedAsArray, "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform) || - !checkRectArray(lastCharRectTranslatedAsArray, [lastCharRectTranslated], "runCSSTransformTest: lastCharRectTranslatedAsArray, " + textarea.style.transform)) { - return; - } - } finally { - textarea.style.transform = ""; - } -} - -function runBug722639Test() -{ - textarea.focus(); - textarea.value = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; - textarea.value += textarea.value; - textarea.value += textarea.value; // 80 characters - - var firstLine = synthesizeQueryTextRect(0, 1); - if (!checkQueryContentResult(firstLine, - "runBug722639Test: firstLine")) { - return; - } - ok(true, "runBug722639Test: 1st line, top=" + firstLine.top + ", left=" + firstLine.left); - var firstLineAsArray = synthesizeQueryTextRectArray(0, 1); - if (!checkQueryContentResult(firstLineAsArray, "runBug722639Test: 1st line as array") || - !checkRectArray(firstLineAsArray, [firstLine], "runBug722639Test: 1st line as array should match with text rect result")) { - return; - } - if (kLFLen > 1) { - var firstLineLF = synthesizeQueryTextRect(1, 1); - if (!checkQueryContentResult(firstLineLF, - "runBug722639Test: firstLineLF")) { - return; - } - is(firstLineLF.top, firstLine.top, "runBug722639Test: 1st line's \\n rect should be same as 1st line's \\r rect"); - is(firstLineLF.left, firstLine.left, "runBug722639Test: 1st line's \\n rect should be same as 1st line's \\r rect"); - is(firstLineLF.height, firstLine.height, "runBug722639Test: 1st line's \\n rect should be same as 1st line's \\r rect"); - is(firstLineLF.width, firstLine.width, "runBug722639Test: 1st line's \\n rect should be same as 1st line's \\r rect"); - var firstLineLFAsArray = synthesizeQueryTextRectArray(1, 1); - if (!checkQueryContentResult(firstLineLFAsArray, "runBug722639Test: 1st line's \\n rect as array") || - !checkRectArray(firstLineLFAsArray, [firstLineLF], "runBug722639Test: 1st line's rect as array should match with text rect result")) { - return; - } - } - var secondLine = synthesizeQueryTextRect(kLFLen, 1); - if (!checkQueryContentResult(secondLine, - "runBug722639Test: secondLine")) { - return; - } - ok(true, "runBug722639Test: 2nd line, top=" + secondLine.top + ", left=" + secondLine.left); - var secondLineAsArray = synthesizeQueryTextRectArray(kLFLen, 1); - if (!checkQueryContentResult(secondLineAsArray, "runBug722639Test: 2nd line as array") || - !checkRectArray(secondLineAsArray, [secondLine], "runBug722639Test: 2nd line as array should match with text rect result")) { - return; - } - if (kLFLen > 1) { - var secondLineLF = synthesizeQueryTextRect(kLFLen + 1, 1); - if (!checkQueryContentResult(secondLineLF, - "runBug722639Test: secondLineLF")) { - return; - } - is(secondLineLF.top, secondLine.top, "runBug722639Test: 2nd line's \\n rect should be same as 2nd line's \\r rect"); - is(secondLineLF.left, secondLine.left, "runBug722639Test: 2nd line's \\n rect should be same as 2nd line's \\r rect"); - is(secondLineLF.height, secondLine.height, "runBug722639Test: 2nd line's \\n rect should be same as 2nd line's \\r rect"); - is(secondLineLF.width, secondLine.width, "runBug722639Test: 2nd line's \\n rect should be same as 2nd line's \\r rect"); - var secondLineLFAsArray = synthesizeQueryTextRectArray(kLFLen + 1, 1); - if (!checkQueryContentResult(secondLineLFAsArray, "runBug722639Test: 2nd line's \\n rect as array") || - !checkRectArray(secondLineLFAsArray, [secondLineLF], "runBug722639Test: 2nd line's rect as array should match with text rect result")) { - return; - } - } - var lineHeight = secondLine.top - firstLine.top; - ok(lineHeight > 0, - "runBug722639Test: lineHeight must be positive"); - is(secondLine.left, firstLine.left, - "runBug722639Test: the left value must be always same value"); - is(secondLine.height, firstLine.height, - "runBug722639Test: the height must be always same value"); - var previousTop = secondLine.top; - for (var i = 3; i <= textarea.value.length + 1; i++) { - var currentLine = synthesizeQueryTextRect(kLFLen * (i - 1), 1); - if (!checkQueryContentResult(currentLine, - "runBug722639Test: " + i + "th currentLine")) { - return; - } - ok(true, "runBug722639Test: " + i + "th line, top=" + currentLine.top + ", left=" + currentLine.left); - var currentLineAsArray = synthesizeQueryTextRectArray(kLFLen * (i - 1), 1); - if (!checkQueryContentResult(currentLineAsArray, "runBug722639Test: " + i + "th line as array") || - !checkRectArray(currentLineAsArray, [currentLine], "runBug722639Test: " + i + "th line as array should match with text rect result")) { - return; - } - // NOTE: the top position may be 1px larger or smaller than other lines - // due to sub pixel positioning. - if (Math.abs(currentLine.top - (previousTop + lineHeight)) <= 1) { - ok(true, "runBug722639Test: " + i + "th line's top is expected"); - } else { - is(currentLine.top, previousTop + lineHeight, - "runBug722639Test: " + i + "th line's top is unexpected"); - } - is(currentLine.left, firstLine.left, - "runBug722639Test: " + i + "th line's left is unexpected"); - is(currentLine.height, firstLine.height, - "runBug722639Test: " + i + "th line's height is unexpected"); - if (kLFLen > 1) { - var currentLineLF = synthesizeQueryTextRect(kLFLen * (i - 1) + 1, 1); - if (!checkQueryContentResult(currentLineLF, - "runBug722639Test: " + i + "th currentLineLF")) { - return; - } - is(currentLineLF.top, currentLine.top, "runBug722639Test: " + i + "th line's \\n rect should be same as same line's \\r rect"); - is(currentLineLF.left, currentLine.left, "runBug722639Test: " + i + "th line's \\n rect should be same as same line's \\r rect"); - is(currentLineLF.height, currentLine.height, "runBug722639Test: " + i + "th line's \\n rect should be same as same line's \\r rect"); - is(currentLineLF.width, currentLine.width, "runBug722639Test: " + i + "th line's \\n rect should be same as same line's \\r rect"); - var currentLineLFAsArray = synthesizeQueryTextRectArray(kLFLen * (i - 1) + 1, 1); - if (!checkQueryContentResult(currentLineLFAsArray, "runBug722639Test: " + i + "th line's \\n rect as array") || - !checkRectArray(currentLineLFAsArray, [currentLineLF], "runBug722639Test: " + i + "th line's rect as array should match with text rect result")) { - return; - } - } - previousTop = currentLine.top; - } -} - -function runForceCommitTest() -{ - var events; - function eventHandler(aEvent) - { - events.push(aEvent); - } - window.addEventListener("compositionstart", eventHandler, true); - window.addEventListener("compositionupdate", eventHandler, true); - window.addEventListener("compositionend", eventHandler, true); - window.addEventListener("input", eventHandler, true); - window.addEventListener("text", eventHandler, true); - - // Make the composition in textarea commit by click in the textarea - textarea.focus(); - textarea.value = ""; - - events = []; - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - is(events.length, 4, - "runForceCommitTest: wrong event count #1"); - is(events[0].type, "compositionstart", - "runForceCommitTest: the 1st event must be compositionstart #1"); - is(events[1].type, "compositionupdate", - "runForceCommitTest: the 2nd event must be compositionupdate #1"); - is(events[2].type, "text", - "runForceCommitTest: the 3rd event must be text #1"); - is(events[3].type, "input", - "runForceCommitTest: the 4th event must be input #1"); - - events = []; - synthesizeMouseAtCenter(textarea, {}); - - is(events.length, 3, - "runForceCommitTest: wrong event count #2"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #2"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #2"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #2"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #2"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #2"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #2"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #2"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #2"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #2"); - - // Make the composition in textarea commit by click in another editor (input) - textarea.focus(); - textarea.value = ""; - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - synthesizeMouseAtCenter(input, {}); - - is(events.length, 3, - "runForceCommitTest: wrong event count #3"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #3"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #3"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #3"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #3"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #3"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #3"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #3"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #3"); - ok(!getEditorIMESupport(input).isComposing, - "runForceCommitTest: the input has composition #3"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #3"); - is(input.value, "", - "runForceCommitTest: the input has the committed text? #3"); - - // Make the composition in textarea commit by blur() - textarea.focus(); - textarea.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - textarea.blur(); - - is(events.length, 3, - "runForceCommitTest: wrong event count #4"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #4"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #4"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #4"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #4"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #4"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #4"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #4"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #4"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #4"); - - // Make the composition in textarea commit by input.focus() - textarea.focus(); - textarea.value = ""; - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - input.focus(); - - is(events.length, 3, - "runForceCommitTest: wrong event count #5"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #5"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #5"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #5"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #5"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #5"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #5"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #5"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #5"); - ok(!getEditorIMESupport(input).isComposing, - "runForceCommitTest: the input has composition #5"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #5"); - is(input.value, "", - "runForceCommitTest: the input has the committed text? #5"); - - // Make the composition in textarea commit by click in another document's editor - textarea.focus(); - textarea.value = ""; - textareaInFrame.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - synthesizeMouseAtCenter(textareaInFrame, {}, iframe.contentWindow); - - is(events.length, 3, - "runForceCommitTest: wrong event count #6"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #6"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #6"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #6"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #6"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #6"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #6"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #6"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #6"); - ok(!getEditorIMESupport(textareaInFrame).isComposing, - "runForceCommitTest: the textarea in frame has composition #6"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #6"); - is(textareaInFrame.value, "", - "runForceCommitTest: the textarea in frame has the committed text? #6"); - - // Make the composition in textarea commit by another document's editor's focus() - textarea.focus(); - textarea.value = ""; - textareaInFrame.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - textareaInFrame.focus(); - - is(events.length, 3, - "runForceCommitTest: wrong event count #7"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #7"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #7"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #7"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #7"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #7"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #7"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #7"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #7"); - ok(!getEditorIMESupport(textareaInFrame).isComposing, - "runForceCommitTest: the textarea in frame has composition #7"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #7"); - is(textareaInFrame.value, "", - "runForceCommitTest: the textarea in frame has the committed text? #7"); - - // Make the composition in a textarea commit by click in another editable document - textarea.focus(); - textarea.value = ""; - iframe2.contentDocument.body.innerHTML = "Text in the Body"; - var iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - synthesizeMouseAtCenter(iframe2.contentDocument.body, {}, iframe2.contentWindow); - - is(events.length, 3, - "runForceCommitTest: wrong event count #8"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #8"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #8"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #8"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #8"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #8"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #8"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #8"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #8"); - ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing, - "runForceCommitTest: the editable document has composition #8"); - is(textarea.value, "\u306E", - "runForceCommitTest: the textarea doesn't have the committed text #8"); - is(iframe2.contentDocument.body.innerHTML, iframe2BodyInnerHTML, - "runForceCommitTest: the editable document has the committed text? #8"); - - // Make the composition in an editable document commit by click in it - iframe2.contentWindow.focus(); - iframe2.contentDocument.body.innerHTML = "Text in the Body"; - iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }, iframe2.contentWindow); - - events = []; - synthesizeMouseAtCenter(iframe2.contentDocument.body, {}, iframe2.contentWindow); - - is(events.length, 3, - "runForceCommitTest: wrong event count #9"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #9"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #9"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #9"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #9"); - is(events[0].target, iframe2.contentDocument.body, - "runForceCommitTest: The 1st event was fired on wrong event target #9"); - is(events[1].target, iframe2.contentDocument.body, - "runForceCommitTest: The 2nd event was fired on wrong event target #9"); - is(events[2].target, iframe2.contentDocument.body, - "runForceCommitTest: The 3rd event was fired on wrong event target #9"); - ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing, - "runForceCommitTest: the editable document still has composition #9"); - ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML && - iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0, - "runForceCommitTest: the editable document doesn't have the committed text #9"); - - // Make the composition in an editable document commit by click in another document's editor - textarea.value = ""; - iframe2.contentWindow.focus(); - iframe2.contentDocument.body.innerHTML = "Text in the Body"; - iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }, iframe2.contentWindow); - - events = []; - synthesizeMouseAtCenter(textarea, {}); - - is(events.length, 3, - "runForceCommitTest: wrong event count #10"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #10"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #10"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #10"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #10"); - is(events[0].target, iframe2.contentDocument.body, - "runForceCommitTest: The 1st event was fired on wrong event target #10"); - is(events[1].target, iframe2.contentDocument.body, - "runForceCommitTest: The 2nd event was fired on wrong event target #10"); - is(events[2].target, iframe2.contentDocument.body, - "runForceCommitTest: The 3rd event was fired on wrong event target #10"); - ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing, - "runForceCommitTest: the editable document still has composition #10"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea has composition #10"); - ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML && - iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0, - "runForceCommitTest: the editable document doesn't have the committed text #10"); - is(textarea.value, "", - "runForceCommitTest: the textarea has the committed text? #10"); - - // Make the composition in an editable document commit by click in the another editable document - iframe2.contentWindow.focus(); - iframe2.contentDocument.body.innerHTML = "Text in the Body"; - iframe2BodyInnerHTML = iframe2.contentDocument.body.innerHTML; - iframe3.contentDocument.body.innerHTML = "Text in the Body"; - iframe3BodyInnerHTML = iframe2.contentDocument.body.innerHTML; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }, iframe2.contentWindow); - - events = []; - synthesizeMouseAtCenter(iframe3.contentDocument.body, {}, iframe3.contentWindow); - - is(events.length, 3, - "runForceCommitTest: wrong event count #11"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #11"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #11"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #11"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #11"); - is(events[0].target, iframe2.contentDocument.body, - "runForceCommitTest: The 1st event was fired on wrong event target #11"); - is(events[1].target, iframe2.contentDocument.body, - "runForceCommitTest: The 2nd event was fired on wrong event target #11"); - is(events[2].target, iframe2.contentDocument.body, - "runForceCommitTest: The 3rd event was fired on wrong event target #11"); - ok(!getHTMLEditorIMESupport(iframe2.contentWindow).isComposing, - "runForceCommitTest: the editable document still has composition #11"); - ok(!getHTMLEditorIMESupport(iframe3.contentWindow).isComposing, - "runForceCommitTest: the other editable document has composition #11"); - ok(iframe2.contentDocument.body.innerHTML != iframe2BodyInnerHTML && - iframe2.contentDocument.body.innerHTML.indexOf("\u306E") >= 0, - "runForceCommitTest: the editable document doesn't have the committed text #11"); - is(iframe3.contentDocument.body.innerHTML, iframe3BodyInnerHTML, - "runForceCommitTest: the other editable document has the committed text? #11"); - - input.focus(); - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - input.value = "set value"; - - is(events.length, 3, - "runForceCommitTest: wrong event count #12"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #12"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #12"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #12"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #12"); - is(events[0].target, input, - "runForceCommitTest: The 1st event was fired on wrong event target #12"); - is(events[1].target, input, - "runForceCommitTest: The 2nd event was fired on wrong event target #12"); - is(events[2].target, input, - "runForceCommitTest: The 3rd event was fired on wrong event target #12"); - ok(!getEditorIMESupport(input).isComposing, - "runForceCommitTest: the input still has composition #12"); - is(input.value, "set value", - "runForceCommitTest: the input doesn't have the set text #12"); - - textarea.focus(); - textarea.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - textarea.value = "set value"; - - is(events.length, 3, - "runForceCommitTest: wrong event count #13"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #13"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #13"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #13"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #13"); - is(events[0].target, textarea, - "runForceCommitTest: The 1st event was fired on wrong event target #13"); - is(events[1].target, textarea, - "runForceCommitTest: The 2nd event was fired on wrong event target #13"); - is(events[2].target, textarea, - "runForceCommitTest: The 3rd event was fired on wrong event target #13"); - ok(!getEditorIMESupport(textarea).isComposing, - "runForceCommitTest: the textarea still has composition #13"); - is(textarea.value, "set value", - "runForceCommitTest: the textarea doesn't have the set text #13"); - - input.focus(); - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - input.value += " appended value"; - - is(events.length, 3, - "runForceCommitTest: wrong event count #14"); - is(events[0].type, "text", - "runForceCommitTest: the 1st event must be text #14"); - is(events[1].type, "compositionend", - "runForceCommitTest: the 2nd event must be compositionend #14"); - is(events[2].type, "input", - "runForceCommitTest: the 3rd event must be input #14"); - is(events[1].data, "\u306E", - "runForceCommitTest: compositionend has wrong data #14"); - is(events[0].target, input, - "runForceCommitTest: The 1st event was fired on wrong event target #14"); - is(events[1].target, input, - "runForceCommitTest: The 2nd event was fired on wrong event target #14"); - is(events[2].target, input, - "runForceCommitTest: The 3rd event was fired on wrong event target #14"); - ok(!getEditorIMESupport(input).isComposing, - "runForceCommitTest: the input still has composition #14"); - is(input.value, "\u306E appended value", - "runForceCommitTest: the input should have both composed text and appended text #14"); - - input.focus(); - input.value = "abcd"; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - input.value = "abcd\u306E"; - - is(events.length, 0, - "runForceCommitTest: setting same value to input with composition shouldn't cause any events #15"); - is(input.value, "abcd\u306E", - "runForceCommitTest: the input has unexpected value #15"); - - input.blur(); // commit composition - - textarea.focus(); - textarea.value = "abcd"; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - textarea.value = "abcd\u306E"; - - is(events.length, 0, - "runForceCommitTest: setting same value to textarea with composition shouldn't cause any events #16"); - is(textarea.value, "abcd\u306E", - "runForceCommitTest: the input has unexpected value #16"); - - textarea.blur(); // commit composition - - window.removeEventListener("compositionstart", eventHandler, true); - window.removeEventListener("compositionupdate", eventHandler, true); - window.removeEventListener("compositionend", eventHandler, true); - window.removeEventListener("input", eventHandler, true); - window.removeEventListener("text", eventHandler, true); -} - -function runNestedSettingValue() -{ - var isTesting = false; - var events = []; - function eventHandler(aEvent) - { - events.push(aEvent); - if (isTesting) { - aEvent.target.value += aEvent.type + ", "; - } - } - window.addEventListener("compositionstart", eventHandler, true); - window.addEventListener("compositionupdate", eventHandler, true); - window.addEventListener("compositionend", eventHandler, true); - window.addEventListener("input", eventHandler, true); - window.addEventListener("text", eventHandler, true); - - textarea.focus(); - textarea.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - isTesting = true; - textarea.value = "first setting value, "; - isTesting = false; - - is(events.length, 3, - "runNestedSettingValue: wrong event count #1"); - is(events[0].type, "text", - "runNestedSettingValue: the 1st event must be text #1"); - is(events[1].type, "compositionend", - "runNestedSettingValue: the 2nd event must be compositionend #1"); - is(events[2].type, "input", - "runNestedSettingValue: the 3rd event must be input #1"); - is(events[1].data, "\u306E", - "runNestedSettingValue: compositionend has wrong data #1"); - is(events[0].target, textarea, - "runNestedSettingValue: The 1st event was fired on wrong event target #1"); - is(events[1].target, textarea, - "runNestedSettingValue: The 2nd event was fired on wrong event target #1"); - is(events[2].target, textarea, - "runNestedSettingValue: The 3rd event was fired on wrong event target #1"); - ok(!getEditorIMESupport(textarea).isComposing, - "runNestedSettingValue: the textarea still has composition #1"); - is(textarea.value, "first setting value, text, compositionend, input, ", - "runNestedSettingValue: the textarea should have all string set to value attribute"); - - input.focus(); - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - isTesting = true; - input.value = "first setting value, "; - isTesting = false; - - is(events.length, 3, - "runNestedSettingValue: wrong event count #2"); - is(events[0].type, "text", - "runNestedSettingValue: the 1st event must be text #2"); - is(events[1].type, "compositionend", - "runNestedSettingValue: the 2nd event must be compositionend #2"); - is(events[2].type, "input", - "runNestedSettingValue: the 3rd event must be input #2"); - is(events[1].data, "\u306E", - "runNestedSettingValue: compositionend has wrong data #2"); - is(events[0].target, input, - "runNestedSettingValue: The 1st event was fired on wrong event target #2"); - is(events[1].target, input, - "runNestedSettingValue: The 2nd event was fired on wrong event target #2"); - is(events[2].target, input, - "runNestedSettingValue: The 3rd event was fired on wrong event target #2"); - ok(!getEditorIMESupport(input).isComposing, - "runNestedSettingValue: the input still has composition #2"); - is(textarea.value, "first setting value, text, compositionend, input, ", - "runNestedSettingValue: the input should have all string set to value attribute #2"); - - textarea.focus(); - textarea.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - isTesting = true; - textarea.setRangeText("first setting value, "); - isTesting = false; - - is(events.length, 3, - "runNestedSettingValue: wrong event count #3"); - is(events[0].type, "text", - "runNestedSettingValue: the 1st event must be text #3"); - is(events[1].type, "compositionend", - "runNestedSettingValue: the 2nd event must be compositionend #3"); - is(events[2].type, "input", - "runNestedSettingValue: the 3rd event must be input #3"); - is(events[1].data, "\u306E", - "runNestedSettingValue: compositionend has wrong data #3"); - is(events[0].target, textarea, - "runNestedSettingValue: The 1st event was fired on wrong event target #3"); - is(events[1].target, textarea, - "runNestedSettingValue: The 2nd event was fired on wrong event target #3"); - is(events[2].target, textarea, - "runNestedSettingValue: The 3rd event was fired on wrong event target #3"); - ok(!getEditorIMESupport(textarea).isComposing, - "runNestedSettingValue: the textarea still has composition #3"); - is(textarea.value, "\u306Efirst setting value, text, compositionend, input, ", - "runNestedSettingValue: the textarea should have appended by setRangeText() and all string set to value attribute #3"); - - input.focus(); - input.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - events = []; - isTesting = true; - input.setRangeText("first setting value, "); - isTesting = false; - - is(events.length, 3, - "runNestedSettingValue: wrong event count #4"); - is(events[0].type, "text", - "runNestedSettingValue: the 1st event must be text #4"); - is(events[1].type, "compositionend", - "runNestedSettingValue: the 2nd event must be compositionend #4"); - is(events[2].type, "input", - "runNestedSettingValue: the 3rd event must be input #4"); - is(events[1].data, "\u306E", - "runNestedSettingValue: compositionend has wrong data #4"); - is(events[0].target, input, - "runNestedSettingValue: The 1st event was fired on wrong event target #4"); - is(events[1].target, input, - "runNestedSettingValue: The 2nd event was fired on wrong event target #4"); - is(events[2].target, input, - "runNestedSettingValue: The 3rd event was fired on wrong event target #4"); - ok(!getEditorIMESupport(input).isComposing, - "runNestedSettingValue: the input still has composition #4"); - is(textarea.value, "\u306Efirst setting value, text, compositionend, input, ", - "runNestedSettingValue: the input should have all string appended by setRangeText() and set to value attribute #4"); - - window.removeEventListener("compositionstart", eventHandler, true); - window.removeEventListener("compositionupdate", eventHandler, true); - window.removeEventListener("compositionend", eventHandler, true); - window.removeEventListener("input", eventHandler, true); - window.removeEventListener("text", eventHandler, true); - -} - -function runAsyncForceCommitTest(aNextTest) -{ - var events; - function eventHandler(aEvent) - { - events.push(aEvent); - }; - - // If IME commits composition for a request, TextComposition commits - // composition automatically because most web apps must expect that active - // composition should be committed synchronously. Therefore, in this case, - // a click during composition should cause committing composition - // synchronously and delayed commit shouldn't cause composition events. - var commitRequested = false; - function callback(aTIP, aNotification) - { - ok(true, aNotification.type); - if (aNotification.type != "request-to-commit") { - return true; - } - commitRequested = true; - setTimeout(function () { - events = []; - aTIP.commitComposition(); - - is(events.length, 0, - "runAsyncForceCommitTest: composition events shouldn't been fired by asynchronous call of nsITextInputProcessor.commitComposition()"); - - window.removeEventListener("compositionstart", eventHandler, true); - window.removeEventListener("compositionupdate", eventHandler, true); - window.removeEventListener("compositionend", eventHandler, true); - window.removeEventListener("input", eventHandler, true); - window.removeEventListener("text", eventHandler, true); - - SimpleTest.executeSoon(aNextTest); - }, 1); - return true; - }; - - window.addEventListener("compositionstart", eventHandler, true); - window.addEventListener("compositionupdate", eventHandler, true); - window.addEventListener("compositionend", eventHandler, true); - window.addEventListener("input", eventHandler, true); - window.addEventListener("text", eventHandler, true); - - // Make the composition in textarea commit by click in the textarea - textarea.focus(); - textarea.value = ""; - - events = []; - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }, window, callback); - - is(events.length, 4, - "runAsyncForceCommitTest: wrong event count #1"); - is(events[0].type, "compositionstart", - "runAsyncForceCommitTest: the 1st event must be compositionstart #1"); - is(events[1].type, "compositionupdate", - "runAsyncForceCommitTest: the 2nd event must be compositionupdate #1"); - is(events[2].type, "text", - "runAsyncForceCommitTest: the 3rd event must be text #1"); - is(events[3].type, "input", - "runAsyncForceCommitTest: the 4th event must be input #1"); - - events = []; - commitRequested = false; - synthesizeMouseAtCenter(textarea, {}); - - ok(commitRequested, - "runAsyncForceCommitTest: \"request-to-commit\" should've been notified"); - is(events.length, 3, - "runAsyncForceCommitTest: wrong event count #2"); - is(events[0].type, "text", - "runAsyncForceCommitTest: the 1st event must be text #2"); - is(events[1].type, "compositionend", - "runAsyncForceCommitTest: the 2nd event must be compositionend #2"); - is(events[2].type, "input", - "runAsyncForceCommitTest: the 3rd event must be input #2"); - is(events[1].data, "\u306E", - "runAsyncForceCommitTest: compositionend has wrong data #2"); - is(events[0].target, textarea, - "runAsyncForceCommitTest: The 1st event was fired on wrong event target #2"); - is(events[1].target, textarea, - "runAsyncForceCommitTest: The 2nd event was fired on wrong event target #2"); - is(events[2].target, textarea, - "runAsyncForceCommitTest: The 3rd event was fired on wrong event target #2"); - ok(!getEditorIMESupport(textarea).isComposing, - "runAsyncForceCommitTest: the textarea still has composition #2"); - is(textarea.value, "\u306E", - "runAsyncForceCommitTest: the textarea doesn't have the committed text #2"); -} - -function runBug811755Test() -{ - iframe2.contentDocument.body.innerHTML = "<div>content<br/></div>"; - iframe2.contentWindow.focus(); - // Query everything - var textContent = synthesizeQueryTextContent(0, 10); - if (!checkQueryContentResult(textContent, "runBug811755Test: synthesizeQueryTextContent #1")) { - return false; - } - // Query everything but specify exact end offset, which should be immediately after the <br> node - // If PreContentIterator is used, the next node after <br> is the node after </div>. - // If ContentIterator is used, the next node is the <div> node itself. In this case, the end - // node ends up being before the start node, and an empty string is returned. - var queryContent = synthesizeQueryTextContent(0, textContent.text.length); - if (!checkQueryContentResult(queryContent, "runBug811755Test: synthesizeQueryTextContent #2")) { - return false; - } - is(queryContent.text, textContent.text, "runBug811755Test: two queried texts don't match"); - return queryContent.text == textContent.text; -} - -function runIsComposingTest() -{ - var expectedIsComposing = false; - var descriptionBase = "runIsComposingTest: "; - var description = ""; - - function eventHandler(aEvent) - { - if (aEvent.type == "keydown" || aEvent.type == "keyup") { - is(aEvent.isComposing, expectedIsComposing, - "runIsComposingTest: " + description + " (type=" + aEvent.type + ", key=" + aEvent.key + ")"); - } else { - is(aEvent.isComposing, expectedIsComposing, - "runIsComposingTest: " + description + " (type=" + aEvent.type + ")"); - } - } - - function onComposition(aEvent) - { - if (aEvent.type == "compositionstart") { - expectedIsComposing = true; - } else if (aEvent.type == "compositionend") { - expectedIsComposing = false; - } - } - - textarea.addEventListener("keydown", eventHandler, true); - textarea.addEventListener("keypress", eventHandler, true); - textarea.addEventListener("keyup", eventHandler, true); - textarea.addEventListener("input", eventHandler, true); - textarea.addEventListener("compositionstart", onComposition, true); - textarea.addEventListener("compositionend", onComposition, true); - - textarea.focus(); - textarea.value = ""; - - // XXX These cases shouldn't occur in actual native key events because we - // don't dispatch key events while composition (bug 354358). - SpecialPowers.setBoolPref("dom.keyboardevent.dispatch_during_composition", true); - description = "events before dispatching compositionstart"; - synthesizeKey("VK_LEFT", {}); - - description = "events after dispatching compositionchange"; - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 }, - "key": { key: "a", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A }, - }); - - // Although, firing keypress event during composition is a bug. - synthesizeKey("VK_INSERT", {}); - - description = "events for committing composition string"; - - synthesizeComposition({ type: "compositioncommitasis", - key: { key: "KEY_Enter", code: "Enter", type: "keydown" } }); - - // input event will be fired by synthesizing compositionend event. - // Then, its isComposing should be false. - description = "events after dispatching compositioncommitasis"; - synthesizeKey("VK_RETURN", { type: "keyup" }); - - SpecialPowers.clearUserPref("dom.keyboardevent.dispatch_during_composition"); - - textarea.removeEventListener("keydown", eventHandler, true); - textarea.removeEventListener("keypress", eventHandler, true); - textarea.removeEventListener("keyup", eventHandler, true); - textarea.removeEventListener("input", eventHandler, true); - textarea.removeEventListener("compositionstart", onComposition, true); - textarea.removeEventListener("compositionend", onComposition, true); - - textarea.value = ""; -} - -function runRedundantChangeTest() -{ - textarea.focus(); - - var result = {}; - function clearResult() - { - result = { compositionupdate: false, compositionend: false, text: false, input: false, inputaftercompositionend: false }; - } - - function handler(aEvent) - { - if (aEvent.type == "input" && result.compositionend) { - result.inputaftercompositionend = true; - return; - } - result[aEvent.type] = true; - } - - textarea.addEventListener("compositionupdate", handler, true); - textarea.addEventListener("compositionend", handler, true); - textarea.addEventListener("input", handler, true); - textarea.addEventListener("text", handler, true); - - textarea.value = ""; - - // synthesize change event - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "\u3042", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - is(result.compositionupdate, true, "runRedundantChangeTest: compositionupdate should be fired after synthesizing composition change #1"); - is(result.compositionend, false, "runRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change #1"); - is(result.text, true, "runRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string #1"); - is(result.input, true, "runRedundantChangeTest: input should be fired after synthesizing composition change #1"); - is(textarea.value, "\u3042", "runRedundantChangeTest: textarea has uncommitted string #1"); - - // synthesize another change event - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "\u3042\u3044", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - is(result.compositionupdate, true, "runRedundantChangeTest: compositionupdate should be fired after synthesizing composition change #2"); - is(result.compositionend, false, "runRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change #2"); - is(result.text, true, "runRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string #2"); - is(result.input, true, "runRedundantChangeTest: input should be fired after synthesizing composition change #2"); - is(textarea.value, "\u3042\u3044", "runRedundantChangeTest: textarea has uncommitted string #2"); - - // synthesize same change event again - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "\u3042\u3044", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - is(result.compositionupdate, false, "runRedundantChangeTest: compositionupdate shouldn't be fired after synthesizing composition change again"); - is(result.compositionend, false, "runRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change again"); - is(result.text, false, "runRedundantChangeTest: text shouldn't be fired after synthesizing composition change again because it's dispatched when there is composing string"); - is(result.input, false, "runRedundantChangeTest: input shouldn't be fired after synthesizing composition change again"); - is(textarea.value, "\u3042\u3044", "runRedundantChangeTest: textarea has uncommitted string #3"); - - // synthesize commit-as-is - clearResult(); - synthesizeComposition({ type: "compositioncommitasis" }); - is(result.compositionupdate, false, "runRedundantChangeTest: compositionupdate shouldn't be fired after synthesizing composition commit-as-is"); - is(result.compositionend, true, "runRedundantChangeTest: compositionend should be fired after synthesizing composition commit-as-is"); - is(result.text, true, "runRedundantChangeTest: text shouldn't be fired after synthesizing composition commit-as-is for removing the ranges"); - is(result.input, false, "runRedundantChangeTest: input shouldn't be fired before compositionend at synthesizing commit-as-is"); - is(result.inputaftercompositionend, true, "runRedundantChangeTest: input should be fired after synthesizing composition commit-as-is after compositionend"); - is(textarea.value, "\u3042\u3044", "runRedundantChangeTest: textarea has the commit string"); - - textarea.removeEventListener("compositionupdate", handler, true); - textarea.removeEventListener("compositionend", handler, true); - textarea.removeEventListener("input", handler, true); - textarea.removeEventListener("text", handler, true); -} - -function runNotRedundantChangeTest() -{ - textarea.focus(); - - var result = {}; - function clearResult() - { - result = { compositionupdate: false, compositionend: false, text: false, input: false, inputaftercompositionend: false }; - } - - function handler(aEvent) - { - if (aEvent.type == "input" && result.compositionend) { - result.inputaftercompositionend = true; - return; - } - result[aEvent.type] = true; - } - - textarea.addEventListener("compositionupdate", handler, true); - textarea.addEventListener("compositionend", handler, true); - textarea.addEventListener("input", handler, true); - textarea.addEventListener("text", handler, true); - - textarea.value = "abcde"; - - // synthesize change event with non-null ranges - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "ABCDE", - "clauses": - [ - { "length": 5, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - is(result.compositionupdate, true, "runNotRedundantChangeTest: compositionupdate should be fired after synthesizing composition change with non-null ranges"); - is(result.compositionend, false, "runNotRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change with non-null ranges"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with non-null ranges"); - is(result.input, true, "runNotRedundantChangeTest: input should be fired after synthesizing composition change with non-null ranges"); - is(textarea.value, "abcdeABCDE", "runNotRedundantChangeTest: textarea has uncommitted string #1"); - - // synthesize change event with null ranges - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "ABCDE", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - }); - is(result.compositionupdate, false, "runNotRedundantChangeTest: compositionupdate shouldn't be fired after synthesizing composition change with null ranges after non-null ranges"); - is(result.compositionend, false, "runNotRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change with null ranges after non-null ranges"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with null ranges after non-null ranges"); - is(result.input, true, "runNotRedundantChangeTest: input should be fired after synthesizing composition change with null ranges after non-null ranges"); - is(textarea.value, "abcdeABCDE", "runNotRedundantChangeTest: textarea has uncommitted string #2"); - - // synthesize change event with non-null ranges - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "ABCDE", - "clauses": - [ - { "length": 5, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - is(result.compositionupdate, false, "runNotRedundantChangeTest: compositionupdate shouldn't be fired after synthesizing composition change with non-null ranges after null ranges"); - is(result.compositionend, false, "runNotRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change with non-null ranges after null ranges"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with non-null ranges after null ranges"); - is(result.input, true, "runNotRedundantChangeTest: input should be fired after synthesizing composition change with non-null ranges after null ranges"); - is(textarea.value, "abcdeABCDE", "runNotRedundantChangeTest: textarea has uncommitted string #3"); - - // synthesize change event with empty data and null ranges - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "", - "clauses": - [ - { "length": 0, "attr": 0 } - ] - }, - }); - is(result.compositionupdate, true, "runNotRedundantChangeTest: compositionupdate should be fired after synthesizing composition change with empty data and null ranges after non-null ranges"); - is(result.compositionend, false, "runNotRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change with empty data and null ranges after non-null ranges"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with empty data and null ranges after non-null ranges"); - is(result.input, true, "runNotRedundantChangeTest: input should be fired after synthesizing composition change with empty data and null ranges after non-null ranges"); - is(textarea.value, "abcde", "runNotRedundantChangeTest: textarea doesn't have uncommitted string #1"); - - // synthesize change event with non-null ranges - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": "ABCDE", - "clauses": - [ - { "length": 5, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - is(result.compositionupdate, true, "runNotRedundantChangeTest: compositionupdate should be fired after synthesizing composition change with non-null ranges after empty data and null ranges"); - is(result.compositionend, false, "runNotRedundantChangeTest: compositionend shouldn't be fired after synthesizing composition change with non-null ranges after empty data and null ranges"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with non-null ranges after empty data and null ranges"); - is(result.input, true, "runNotRedundantChangeTest: input should be fired after synthesizing composition change with non-null ranges after empty data and null ranges"); - is(textarea.value, "abcdeABCDE", "runNotRedundantChangeTest: textarea has uncommitted string #4"); - - clearResult(); - synthesizeComposition({ type: "compositioncommit", data: "" }); - - is(result.compositionupdate, true, "runNotRedundantChangeTest: compositionupdate should be fired after synthesizing composition commit with empty data after non-empty data"); - is(result.compositionend, true, "runNotRedundantChangeTest: compositionend should be fired after synthesizing composition commit with empty data after non-empty data"); - is(result.text, true, "runNotRedundantChangeTest: text should be fired after synthesizing composition change because it's dispatched when there is composing string with empty data after non-empty data"); - is(result.input, false, "runNotRedundantChangeTest: input shouldn't be fired before compositionend after synthesizing composition change with empty data after non-empty data"); - is(result.inputaftercompositionend, true, "runNotRedundantChangeTest: input should be fired after compositionend after synthesizing composition change with empty data after non-empty data"); - is(textarea.value, "abcde", "runNotRedundantChangeTest: textarea doesn't have uncommitted string #2"); - - textarea.removeEventListener("compositionupdate", handler, true); - textarea.removeEventListener("compositionend", handler, true); - textarea.removeEventListener("input", handler, true); - textarea.removeEventListener("text", handler, true); -} - -function runControlCharTest() -{ - textarea.focus(); - - var result = {}; - function clearResult() - { - result = { compositionupdate: null, compositionend: null }; - } - - function handler(aEvent) - { - result[aEvent.type] = aEvent.data; - } - - textarea.addEventListener("compositionupdate", handler, true); - textarea.addEventListener("compositionend", handler, true); - - textarea.value = ""; - - var controlChars = String.fromCharCode.apply(null, Object.keys(Array.from({length:0x20}))) + "\x7F"; - var allowedChars = "\t"; - - var data = "AB" + controlChars + "CD" + controlChars + "EF"; - var removedData = "AB" + allowedChars + "CD" + allowedChars + "EF"; - - var DIndex = data.indexOf("D"); - var removedDIndex = removedData.indexOf("D"); - - // input string contains control characters - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": data, - "clauses": - [ - { "length": DIndex, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": data.length - DIndex, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": DIndex, "length": 0 } - }); - - checkSelection(removedDIndex, "", "runControlCharTest", "#1") - - is(result.compositionupdate, removedData, "runControlCharTest: control characters in event.data should be removed in compositionupdate event #1"); - is(textarea.value, removedData, "runControlCharTest: control characters should not appear in textarea #1"); - - synthesizeComposition({ type: "compositioncommit", data: data }); - - is(result.compositionend, removedData, "runControlCharTest: control characters in event.data should be removed in compositionend event #2"); - is(textarea.value, removedData, "runControlCharTest: control characters should not appear in textarea #2"); - - textarea.value = ""; - - clearResult(); - - SpecialPowers.setBoolPref("dom.compositionevent.allow_control_characters", true); - - // input string contains control characters, allowing control characters - clearResult(); - synthesizeCompositionChange( - { "composition": - { "string": data, - "clauses": - [ - { "length": DIndex, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": data.length - DIndex, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": DIndex, "length": 0 } - }); - - checkSelection(DIndex - 1 + kLFLen, "", "runControlCharTest", "#3") - - is(result.compositionupdate, data, "runControlCharTest: control characters in event.data should not be removed in compositionupdate event #3"); - is(textarea.value, data.replace(/\r/g, "\n"), "runControlCharTest: control characters should appear in textarea #3"); - - synthesizeComposition({ type: "compositioncommit", data: data }); - - is(result.compositionend, data, "runControlCharTest: control characters in event.data should not be removed in compositionend event #4"); - is(textarea.value, data.replace(/\r/g, "\n"), "runControlCharTest: control characters should appear in textarea #4"); - - SpecialPowers.clearUserPref("dom.compositionevent.allow_control_characters"); - - textarea.removeEventListener("compositionupdate", handler, true); - textarea.removeEventListener("compositionend", handler, true); -} - -function runRemoveContentTest(aCallback) -{ - var events = []; - function eventHandler(aEvent) - { - events.push(aEvent); - } - textarea.addEventListener("compositionstart", eventHandler, true); - textarea.addEventListener("compositionupdate", eventHandler, true); - textarea.addEventListener("compositionend", eventHandler, true); - textarea.addEventListener("input", eventHandler, true); - textarea.addEventListener("text", eventHandler, true); - - textarea.focus(); - textarea.value = ""; - - synthesizeCompositionChange( - { "composition": - { "string": "\u306E", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - var nextSibling = textarea.nextSibling; - var parent = textarea.parentElement; - - events = []; - parent.removeChild(textarea); - - hitEventLoop(function () { - // XXX Currently, "input" event isn't fired on removed content. - is(events.length, 3, - "runRemoveContentTest: wrong event count #1"); - is(events[0].type, "compositionupdate", - "runRemoveContentTest: the 1st event must be compositionupdate #1"); - is(events[1].type, "text", - "runRemoveContentTest: the 2nd event must be text #1"); - is(events[2].type, "compositionend", - "runRemoveContentTest: the 3rd event must be compositionend #1"); - is(events[0].data, "", - "runRemoveContentTest: compositionupdate has wrong data #1"); - is(events[2].data, "", - "runRemoveContentTest: compositionend has wrong data #1"); - is(events[0].target, textarea, - "runRemoveContentTest: The 1st event was fired on wrong event target #1"); - is(events[1].target, textarea, - "runRemoveContentTest: The 2nd event was fired on wrong event target #1"); - is(events[2].target, textarea, - "runRemoveContentTest: The 3rd event was fired on wrong event target #1"); - ok(!getEditorIMESupport(textarea).isComposing, - "runRemoveContentTest: the textarea still has composition #1"); - todo_is(textarea.value, "", - "runRemoveContentTest: the textarea has the committed text? #1"); - - parent.insertBefore(textarea, nextSibling); - - textarea.focus(); - textarea.value = ""; - - synthesizeComposition({ type: "compositionstart" }); - - events = []; - parent.removeChild(textarea); - - hitEventLoop(function () { - // XXX Currently, "input" event isn't fired on removed content. - is(events.length, 1, - "runRemoveContentTest: wrong event count #2"); - is(events[0].type, "compositionend", - "runRemoveContentTest: the 1st event must be compositionend #2"); - is(events[0].data, "", - "runRemoveContentTest: compositionupdate has wrong data #2"); - is(events[0].target, textarea, - "runRemoveContentTest: The 1st event was fired on wrong event target #2"); - ok(!getEditorIMESupport(textarea).isComposing, - "runRemoveContentTest: the textarea still has composition #2"); - is(textarea.value, "", - "runRemoveContentTest: the textarea has the committed text? #2"); - - parent.insertBefore(textarea, nextSibling); - - textarea.removeEventListener("compositionstart", eventHandler, true); - textarea.removeEventListener("compositionupdate", eventHandler, true); - textarea.removeEventListener("compositionend", eventHandler, true); - textarea.removeEventListener("input", eventHandler, true); - textarea.removeEventListener("text", eventHandler, true); - - SimpleTest.executeSoon(aCallback); - }, 50); - }, 50); -} - -function runTestOnAnotherContext(aPanelOrFrame, aFocusedEditor, aTestName) -{ - aFocusedEditor.value = ""; - - var editorRect = synthesizeQueryEditorRect(); - if (!checkQueryContentResult(editorRect, aTestName + ": editorRect")) { - return; - } - - var r = aPanelOrFrame.getBoundingClientRect(); - var parentRect = { "left": r.left, "top": r.top, "width": r.right - r.left, - "height": r.bottom - r.top }; - checkRectContainsRect(editorRect, parentRect, aTestName + - ": the editor rect coordinates are wrong"); - - // input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3078\u3093\u3057\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u3078\u3093\u3057\u3093", aTestName, "#1-1") || - !checkSelection(4, "", aTestName, "#1-1")) { - return; - } - - // convert them #1 - synthesizeCompositionChange( - { "composition": - { "string": "\u8FD4\u4FE1", - "clauses": - [ - { "length": 2, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u8FD4\u4FE1", aTestName, "#1-2") || - !checkSelection(2, "", aTestName, "#1-2")) { - return; - } - - // convert them #2 - synthesizeCompositionChange( - { "composition": - { "string": "\u5909\u8EAB", - "clauses": - [ - { "length": 2, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u5909\u8EAB", aTestName, "#1-3") || - !checkSelection(2, "", aTestName, "#1-3")) { - return; - } - - // commit them - synthesizeComposition({ type: "compositioncommitasis" }); - if (!checkContent("\u5909\u8EAB", aTestName, "#1-4") || - !checkSelection(2, "", aTestName, "#1-4")) { - return; - } - - is(aFocusedEditor.value, "\u5909\u8EAB", - aTestName + ": composition isn't in the focused editor"); - if (aFocusedEditor.value != "\u5909\u8EAB") { - return; - } - - var textRect = synthesizeQueryTextRect(0, 1); - var caretRect = synthesizeQueryCaretRect(2); - if (!checkQueryContentResult(textRect, - aTestName + ": synthesizeQueryTextRect") || - !checkQueryContentResult(caretRect, - aTestName + ": synthesizeQueryCaretRect")) { - return; - } - checkRectContainsRect(textRect, editorRect, aTestName + ":testRect"); - checkRectContainsRect(caretRect, editorRect, aTestName + ":caretRect"); -} - -function runFrameTest() -{ - textareaInFrame.focus(); - runTestOnAnotherContext(iframe, textareaInFrame, "runFrameTest"); - runCharAtPointTest(textareaInFrame, "textarea in the iframe"); -} - -var gPanelShown = false; -var gPanelFocused = false; -function onPanelShown(aEvent) -{ - gPanelShown = true; - textbox.focus(); - setTimeout(doPanelTest, 0); -} - -function onFocusPanelTextbox(aEvent) -{ - gPanelFocused = true; - setTimeout(doPanelTest, 0); -} - -var gIsPanelHiding = false; -var gIsRunPanelTestInternal = false; -function doPanelTest() -{ - if (!gPanelFocused || !gPanelShown) { - return; - } - if (gIsRunPanelTestInternal) { - return; - } - gIsRunPanelTestInternal = true; - runTestOnAnotherContext(panel, textbox, "runPanelTest"); - runCharAtPointTest(textbox, "textbox in the panel"); - gIsPanelHiding = true; - panel.hidePopup(); -} - -function onPanelHidden(aEvent) -{ - panel.hidden = true; - ok(gIsPanelHiding, "runPanelTest: the panel is hidden unexpectedly"); - finish(); -} - -function runPanelTest() -{ - panel.hidden = false; - panel.openPopupAtScreen(window.screenX + window.outerWidth, 0, false); -} - -function runMaxLengthTest() -{ - input.maxLength = 1; - input.value = ""; - input.focus(); - - var kDesc ="runMaxLengthTest"; - - // input first character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u3089", kDesc, "#1-1") || - !checkSelection(1, "", kDesc, "#1-1")) { - return; - } - - // input second character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC", kDesc, "#1-2") || - !checkSelection(2, "", kDesc, "#1-2")) { - return; - } - - // input third character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", kDesc, "#1-3") || - !checkSelection(3, "", kDesc, "#1-3")) { - return; - } - - // input fourth character - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093", kDesc, "#1-4") || - !checkSelection(4, "", kDesc, "#1-4")) { - return; - } - - - // backspace - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081", kDesc, "#1-5") || - !checkSelection(3, "", kDesc, "#1-5")) { - return; - } - - // re-input - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093", - "clauses": - [ - { "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093", kDesc, "#1-6") || - !checkSelection(4, "", kDesc, "#1-6")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055", - "clauses": - [ - { "length": 5, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 5, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055", kDesc, "#1-7") || - !checkSelection(5, "", kDesc, "#1-7")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044", - "clauses": - [ - { "length": 6, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 6, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044", kDesc, "#1-8") || - !checkSelection(6, "", kDesc, "#1-8")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053", - "clauses": - [ - { "length": 7, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 7, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053", - kDesc, "#1-8") || - !checkSelection(7, "", kDesc, "#1-8")) { - return; - } - - synthesizeCompositionChange( - { "composition": - { "string": "\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046", - "clauses": - [ - { "length": 8, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 8, "length": 0 } - }); - - if (!checkContent("\u3089\u30FC\u3081\u3093\u3055\u3044\u3053\u3046", - kDesc, "#1-9") || - !checkSelection(8, "", kDesc, "#1-9")) { - return; - } - - // convert - synthesizeCompositionChange( - { "composition": - { "string": "\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", - "clauses": - [ - { "length": 4, - "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 2, - "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": 4, "length": 0 } - }); - - if (!checkContent("\u30E9\u30FC\u30E1\u30F3\u6700\u9AD8", kDesc, "#1-10") || - !checkSelection(4, "", kDesc, "#1-10")) { - return; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommitasis" }); - if (!checkContent("\u30E9", kDesc, "#1-11") || - !checkSelection(1, "", kDesc, "#1-11")) { - return; - } - - // input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u3057", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u30E9\u3057", kDesc, "#2-1") || - !checkSelection(1 + 1, "", kDesc, "#2-1")) { - return; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommit", data: "\u3058" }); - if (!checkContent("\u30E9", kDesc, "#2-2") || - !checkSelection(1 + 0, "", kDesc, "#2-2")) { - return; - } - - // Undo - synthesizeKey("Z", {accelKey: true}); - - // XXX this is unexpected behavior, see bug 258291 - if (!checkContent("\u30E9", kDesc, "#3-1") || - !checkSelection(1 + 0, "", kDesc, "#3-1")) { - return; - } - - // Undo - synthesizeKey("Z", {accelKey: true}); - if (!checkContent("", kDesc, "#3-2") || - !checkSelection(0, "", kDesc, "#3-2")) { - return; - } - - // Redo - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - if (!checkContent("\u30E9", kDesc, "#3-3") || - !checkSelection(1, "", kDesc, "#3-3")) { - return; - } - - // Redo - synthesizeKey("Z", {accelKey: true, shiftKey: true}); - if (!checkContent("\u30E9", kDesc, "#3-4") || - !checkSelection(1 + 0, "", kDesc, "#3-4")) { - return; - } - - // The input element whose content length is already maxlength and - // the carest is at start of the content. - input.value = "X"; - input.selectionStart = input.selectionEnd = 0; - - // input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u9B54", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - - if (!checkContent("\u9B54X", kDesc, "#4-1") || - !checkSelection(1, "", kDesc, "#4-1")) { - return; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommitasis" }); - - // The input text must be discarded. Then, the caret position shouldn't be - // updated from its position at compositionstart. - if (!checkContent("X", kDesc, "#4-2") || - !checkSelection(0, "", kDesc, "#4-2")) { - return; - } - - // input characters - synthesizeCompositionChange( - { "composition": - { "string": "\u9B54\u6CD5", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - - if (!checkContent("\u9B54\u6CD5X", kDesc, "#5-1") || - !checkSelection(2, "", kDesc, "#5-1")) { - return; - } - - // commit the composition string - synthesizeComposition({ type: "compositioncommitasis" }); - - if (!checkContent("X", kDesc, "#5-2") || - !checkSelection(0, "", kDesc, "#5-2")) { - return; - } -} - -function runEditorReframeTests(aCallback) -{ - function runEditorReframeTest(aEditor, aWindow, aEventType, aNextTest) - { - function getValue() - { - return aEditor == contenteditable ? - aEditor.innerHTML.replace("<br>", "") : aEditor.value; - } - - var description = "runEditorReframeTest(" + aEditor.id + ", \"" + aEventType + "\"): "; - - var tests = [ - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "a", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "a", description + "Typing 'a'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "ab", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ab", description + "Typing 'b' next to 'a'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "abc", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "abc", description + "Typing 'c' next to 'ab'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "abc", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "abc", description + "Starting to convert 'ab][c'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "ABc", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABc", description + "Starting to convert 'AB][c'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "ABC", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_CONVERTED_CLAUSE }, - { "length": 1, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABC", description + "Starting to convert 'AB][C'"); - }, - }, - { test: function () { - // Commit composition - synthesizeComposition({ type: "compositioncommitasis" }); - }, - check: function () { - is(getValue(aEditor), "ABC", description + "Committed as 'ABC'"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "d", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABCd", description + "Typing 'd' next to ABC"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "de", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABCde", description + "Typing 'e' next to ABCd"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "def", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABCdef", description + "Typing 'f' next to ABCde"); - }, - }, - { test: function () { - // Commit composition - synthesizeComposition({ type: "compositioncommitasis" }); - }, - check: function () { - is(getValue(aEditor), "ABCdef", description + "Commit 'def' without convert"); - }, - }, - { test: function () { - // Select "Cd" - synthesizeKey("KEY_ArrowLeft", { code: "ArrowLeft" }); - synthesizeKey("KEY_ArrowLeft", { code: "ArrowLeft" }); - synthesizeKey("KEY_Shift", { type: "keydown", code: "ShiftLeft", shiftKey: true }); - synthesizeKey("KEY_ArrowLeft", { code: "ArrowLeft", shiftKey: true }); - synthesizeKey("KEY_ArrowLeft", { code: "ArrowLeft", shiftKey: true }); - synthesizeKey("KEY_Shift", { type: "keyup", code: "ShiftLeft" }); - }, - check: function () { - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "g", - "clauses": - [ - { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 1, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABgef", description + "Typing 'g' next to AB"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "gh", - "clauses": - [ - { "length": 2, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 2, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABghef", description + "Typing 'h' next to ABg"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "ghi", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_RAW_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABghief", description + "Typing 'i' next to ABgh"); - }, - }, - { test: function () { - synthesizeCompositionChange( - { "composition": - { "string": "GHI", - "clauses": - [ - { "length": 3, "attr": COMPOSITION_ATTR_SELECTED_CLAUSE } - ] - }, - "caret": { "start": 3, "length": 0 } - }); - }, - check: function () { - is(getValue(aEditor), "ABGHIef", description + "Convert 'ghi' to 'GHI'"); - }, - }, - { test: function () { - // Commit composition - synthesizeComposition({ type: "compositioncommitasis" }); - }, - check: function () { - is(getValue(aEditor), "ABGHIef", description + "Commit 'GHI'"); - }, - }, - ]; - - var index = 0; - function doReframe(aEvent) - { - aEvent.target.style.overflow = - aEvent.target.style.overflow != "hidden" ? "hidden" : "auto"; - } - aEditor.focus(); - aEditor.addEventListener(aEventType, doReframe); - - function doNext() - { - if (tests.length <= index) { - aEditor.style.overflow = "auto"; - aEditor.removeEventListener(aEventType, doReframe); - requestAnimationFrame(function() { setTimeout(aNextTest); }); - return; - } - tests[index].test(); - hitEventLoop(function () { - tests[index].check(); - index++; - setTimeout(doNext, 0); - }, 20); - } - doNext(); - } - - input.value = ""; - runEditorReframeTest(input, window, "input", function () { - input.value = ""; - runEditorReframeTest(input, window, "compositionupdate", function () { - textarea.value = ""; - runEditorReframeTest(textarea, window, "input", function () { - textarea.value = ""; - runEditorReframeTest(textarea, window, "compositionupdate", function () { - contenteditable.innerHTML = ""; - runEditorReframeTest(contenteditable, windowOfContenteditable, "input", function () { - contenteditable.innerHTML = ""; - runEditorReframeTest(contenteditable, windowOfContenteditable, "compositionupdate", function () { - aCallback(); - }); - }); - }); - }); - }); - }); -} - -function runTest() -{ - contenteditable = document.getElementById("iframe4").contentDocument.getElementById("contenteditable"); - windowOfContenteditable = document.getElementById("iframe4").contentWindow; - textareaInFrame = iframe.contentDocument.getElementById("textarea"); - - runUndoRedoTest(); - runCompositionCommitAsIsTest(); - runCompositionCommitTest(); - runCompositionTest(); - runCompositionEventTest(); - runQueryTextRectInContentEditableTest(); - runCharAtPointTest(textarea, "textarea in the document"); - runCharAtPointAtOutsideTest(); - runSetSelectionEventTest(); - runQueryTextContentEventTest(); - runQueryIMESelectionTest(); - runQueryContentEventRelativeToInsertionPoint(); - runCSSTransformTest(); - runBug722639Test(); - runForceCommitTest(); - runNestedSettingValue(); - runBug811755Test(); - runIsComposingTest(); - runRedundantChangeTest(); - runNotRedundantChangeTest(); - runControlCharTest(); - runEditorReframeTests(function () { - runAsyncForceCommitTest(function () { - runRemoveContentTest(function () { - runFrameTest(); - runPanelTest(); - runMaxLengthTest(); - }); - }); - }); -} - -]]> -</script> - -</window> diff --git a/widget/tests/window_imestate_iframes.html b/widget/tests/window_imestate_iframes.html deleted file mode 100644 index 064cf19a5..000000000 --- a/widget/tests/window_imestate_iframes.html +++ /dev/null @@ -1,380 +0,0 @@ -<html> -<head> - <title>Test for IME state controling and focus moving for iframes</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> - <style type="text/css"> - iframe { - border: none; - height: 100px; - } - </style> -</head> -<body onunload="onUnload();"> -<p id="display"> - <!-- Use input[readonly] because it isn't affected by the partial focus - movement on Mac --> - <input id="prev" readonly><br> - <iframe id="iframe_not_editable" - src="data:text/html,<html><body><input id='editor'></body></html>"></iframe><br> - - <!-- Testing IME state and focus movement, the anchor elements cannot get focus --> - <iframe id="iframe_html" - src="data:text/html,<html id='editor' contenteditable='true'><body><a href='about:blank'>about:blank;</a></body></html>"></iframe><br> - <iframe id="iframe_designMode" - src="data:text/html,<body id='editor' onload='document.designMode="on";'><a href='about:blank'>about:blank;</a></body>"></iframe><br> - <iframe id="iframe_body" - src="data:text/html,<body id='editor' contenteditable='true'><a href='about:blank'>about:blank;</a></body>"></iframe><br> - <iframe id="iframe_p" - src="data:text/html,<body><p id='editor' contenteditable='true'><a href='about:blank'>about:blank;</a></p></body>"></iframe><br> - - <input id="next" readonly><br> -</p> -<script class="testbody" type="application/javascript"> - -window.opener.wrappedJSObject.SimpleTest.waitForFocus(runTests, window); - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function onUnload() -{ - window.opener.wrappedJSObject.onFinish(); -} - -var gFocusObservingElement = null; -var gBlurObservingElement = null; - -function onFocus(aEvent) -{ - if (aEvent.target != gFocusObservingElement) { - return; - } - ok(gFocusObservingElement.willFocus, - "focus event is fired on unexpected element"); - gFocusObservingElement.willFocus = false; -} - -function onBlur(aEvent) -{ - if (aEvent.target != gBlurObservingElement) { - return; - } - ok(gBlurObservingElement.willBlur, - "blur event is fired on unexpected element"); - gBlurObservingElement.willBlur = false; -} - -function observeFocusBlur(aNextFocusedNode, aWillFireFocusEvent, - aNextBlurredNode, aWillFireBlurEvent) -{ - if (gFocusObservingElement) { - if (gFocusObservingElement.willFocus) { - ok(false, "focus event was never fired on " + gFocusObservingElement); - } - gFocusObservingElement.removeEventListener("focus", onFocus, true); - gFocusObservingElement.willFocus = NaN; - gFocusObservingElement = null; - } - if (gBlurObservingElement) { - if (gBlurObservingElement.willBlur) { - ok(false, "blur event was never fired on " + gBlurObservingElement); - } - gBlurObservingElement.removeEventListener("blur", onBlur, true); - gBlurObservingElement.willBlur = NaN; - gBlurObservingElement = null; - } - if (aNextFocusedNode) { - gFocusObservingElement = aNextFocusedNode; - gFocusObservingElement.willFocus = aWillFireFocusEvent; - gFocusObservingElement.addEventListener("focus", onFocus, true); - } - if (aNextBlurredNode) { - gBlurObservingElement = aNextBlurredNode; - gBlurObservingElement.willBlur = aWillFireBlurEvent; - gBlurObservingElement.addEventListener("blur", onBlur, true); - } -} - -function runTests() -{ - var utils = - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils); - var fm = - Components.classes["@mozilla.org/focus-manager;1"] - .getService(Components.interfaces.nsIFocusManager); - - var iframe, editor, root, input; - var prev = document.getElementById("prev"); - var next = document.getElementById("next"); - var html = document.documentElement; - - function resetFocusToInput(aDescription) - { - observeFocusBlur(null, false, null, false); - prev.focus(); - is(fm.focusedElement, prev, - "input#prev[readonly] element didn't get focus: " + aDescription); - is(utils.IMEStatus, utils.IME_STATUS_DISABLED, - "IME enabled on input#prev[readonly]: " + aDescription); - } - - function resetFocusToParentHTML(aDescription) - { - observeFocusBlur(null, false, null, false); - html.focus(); - is(fm.focusedElement, html, - "Parent html element didn't get focus: " + aDescription); - is(utils.IMEStatus, utils.IME_STATUS_DISABLED, - "IME enabled on parent html element: " + aDescription); - } - - function testTabKey(aForward, - aNextFocusedNode, aWillFireFocusEvent, - aNextBlurredNode, aWillFireBlurEvent, - aIMEShouldBeEnabled, aTestingCaseDescription) - { - observeFocusBlur(aNextFocusedNode, aWillFireFocusEvent, - aNextBlurredNode, aWillFireBlurEvent); - synthesizeKey("VK_TAB", { shiftKey: !aForward }); - var description = "Tab key test: "; - if (!aForward) { - description = "Shift-" + description; - } - description += aTestingCaseDescription + ": "; - is(fm.focusedElement, aNextFocusedNode, - description + "didn't move focus as expected"); - is(utils.IMEStatus, - aIMEShouldBeEnabled ? - utils.IME_STATUS_ENABLED : utils.IME_STATUS_DISABLED, - description + "didn't set IME state as expected"); - } - - function testMouseClick(aNextFocusedNode, aWillFireFocusEvent, - aWillAllNodeLostFocus, - aNextBlurredNode, aWillFireBlurEvent, - aIMEShouldBeEnabled, aTestingCaseDescription) - { - observeFocusBlur(aNextFocusedNode, aWillFireFocusEvent, - aNextBlurredNode, aWillFireBlurEvent); - // We're relying on layout inside the iframe being up to date, so make it so - iframe.contentDocument.documentElement.getBoundingClientRect(); - synthesizeMouse(iframe, 10, 80, { }); - var description = "Click test: " + aTestingCaseDescription + ": "; - is(fm.focusedElement, !aWillAllNodeLostFocus ? aNextFocusedNode : null, - description + "didn't move focus as expected"); - is(utils.IMEStatus, - aIMEShouldBeEnabled ? - utils.IME_STATUS_ENABLED : utils.IME_STATUS_DISABLED, - description + "didn't set IME state as expected"); - } - - function testOnEditorFlagChange(aDescription, aIsInDesignMode) - { - const kReadonly = - Components.interfaces.nsIPlaintextEditor.eEditorReadonlyMask; - var description = "testOnEditorFlagChange: " + aDescription; - resetFocusToParentHTML(description); - var htmlEditor = - iframe.contentWindow. - QueryInterface(Components.interfaces.nsIInterfaceRequestor). - getInterface(Components.interfaces.nsIWebNavigation). - QueryInterface(Components.interfaces.nsIDocShell).editor; - var e = aIsInDesignMode ? root : editor; - e.focus(); - is(fm.focusedElement, e, - description + ": focus() of editor didn't move focus as expected"); - is(utils.IMEStatus, utils.IME_STATUS_ENABLED, - description + ": IME isn't enabled when the editor gets focus"); - var flags = htmlEditor.flags; - htmlEditor.flags |= kReadonly; - is(fm.focusedElement, e, - description + ": when editor becomes readonly, focus moved unexpectedly"); - is(utils.IMEStatus, utils.IME_STATUS_DISABLED, - description + ": when editor becomes readonly, IME is still enabled"); - htmlEditor.flags = flags; - is(fm.focusedElement, e, - description + ": when editor becomes read-write, focus moved unexpectedly"); - is(utils.IMEStatus, utils.IME_STATUS_ENABLED, - description + ": when editor becomes read-write, IME is still disabled"); - } - - // hide all iframes - document.getElementById("iframe_not_editable").style.display = "none"; - document.getElementById("iframe_html").style.display = "none"; - document.getElementById("iframe_designMode").style.display = "none"; - document.getElementById("iframe_body").style.display = "none"; - document.getElementById("iframe_p").style.display = "none"; - - // non editable HTML element and input element can get focus. - iframe = document.getElementById("iframe_not_editable"); - iframe.style.display = "inline"; - editor = iframe.contentDocument.getElementById("editor"); - root = iframe.contentDocument.documentElement; - resetFocusToInput("initializing for iframe_not_editable"); - - testTabKey(true, root, false, prev, true, - false, "input#prev[readonly] -> html"); - testTabKey(true, editor, true, root, false, - true, "html -> input in the subdoc"); - testTabKey(true, next, true, editor, true, - false, "input in the subdoc -> input#next[readonly]"); - testTabKey(false, editor, true, next, true, - true, "input#next[readonly] -> input in the subdoc"); - testTabKey(false, root, false, editor, true, - false, "input in the subdoc -> html"); - testTabKey(false, prev, true, root, false, - false, "html -> input#next[readonly]"); - - iframe.style.display = "none"; - - // HTML element (of course, it's root) must enables IME. - iframe = document.getElementById("iframe_html"); - iframe.style.display = "inline"; - editor = iframe.contentDocument.getElementById("editor"); - root = iframe.contentDocument.documentElement; - resetFocusToInput("initializing for iframe_html"); - - testTabKey(true, editor, true, prev, true, - true, "input#prev[readonly] -> html[contentediable=true]"); - testTabKey(true, next, true, editor, true, - false, "html[contentediable=true] -> input#next[readonly]"); - testTabKey(false, editor, true, next, true, - true, "input#next[readonly] -> html[contentediable=true]"); - testTabKey(false, prev, true, editor, true, - false, "html[contenteditable=true] -> input[readonly]"); - - prev.style.display = "none"; - resetFocusToParentHTML("testing iframe_html"); - testTabKey(true, editor, true, html, false, - true, "html of parent -> html[contentediable=true]"); - testTabKey(false, html, false, editor, true, - false, "html[contenteditable=true] -> html of parent"); - prev.style.display = "inline"; - resetFocusToInput("after parent html <-> html[contenteditable=true]"); - - testMouseClick(editor, true, false, prev, true, true, "iframe_html"); - - testOnEditorFlagChange("html[contentediable=true]", false); - - iframe.style.display = "none"; - - // designMode should behave like <html contenteditable="true"></html> - // but focus/blur events shouldn't be fired on its root element because - // any elements shouldn't be focused state in designMode. - iframe = document.getElementById("iframe_designMode"); - iframe.style.display = "inline"; - iframe.contentDocument.designMode = "on"; - editor = iframe.contentDocument.getElementById("editor"); - root = iframe.contentDocument.documentElement; - resetFocusToInput("initializing for iframe_designMode"); - - testTabKey(true, root, false, prev, true, - true, "input#prev[readonly] -> html in designMode"); - testTabKey(true, next, true, root, false, - false, "html in designMode -> input#next[readonly]"); - testTabKey(false, root, false, next, true, - true, "input#next[readonly] -> html in designMode"); - testTabKey(false, prev, true, root, false, - false, "html in designMode -> input#prev[readonly]"); - - prev.style.display = "none"; - resetFocusToParentHTML("testing iframe_designMode"); - testTabKey(true, root, false, html, false, - true, "html of parent -> html in designMode"); - testTabKey(false, html, false, root, false, - false, "html in designMode -> html of parent"); - prev.style.display = "inline"; - resetFocusToInput("after parent html <-> html in designMode"); - - testMouseClick(editor, false, true, prev, true, true, "iframe_designMode"); - - testOnEditorFlagChange("html in designMode", true); - - iframe.style.display = "none"; - - // When there is no HTML element but the BODY element is editable, - // the body element should get focus and enables IME. - iframe = document.getElementById("iframe_body"); - iframe.style.display = "inline"; - editor = iframe.contentDocument.getElementById("editor"); - root = iframe.contentDocument.documentElement; - resetFocusToInput("initializing for iframe_body"); - - testTabKey(true, editor, true, prev, true, - true, "input#prev[readonly] -> body[contentediable=true]"); - testTabKey(true, next, true, editor, true, - false, "body[contentediable=true] -> input#next[readonly]"); - testTabKey(false, editor, true, next, true, - true, "input#next[readonly] -> body[contentediable=true]"); - testTabKey(false, prev, true, editor, true, - false, "body[contenteditable=true] -> input#prev[readonly]"); - - prev.style.display = "none"; - resetFocusToParentHTML("testing iframe_body"); - testTabKey(true, editor, true, html, false, - true, "html of parent -> body[contentediable=true]"); - testTabKey(false, html, false, editor, true, - false, "body[contenteditable=true] -> html of parent"); - prev.style.display = "inline"; - resetFocusToInput("after parent html <-> body[contenteditable=true]"); - - testMouseClick(editor, true, false, prev, true, true, "iframe_body"); - - testOnEditorFlagChange("body[contentediable=true]", false); - - iframe.style.display = "none"; - - // When HTML/BODY elements are not editable, focus shouldn't be moved to - // the editable content directly. - iframe = document.getElementById("iframe_p"); - iframe.style.display = "inline"; - editor = iframe.contentDocument.getElementById("editor"); - root = iframe.contentDocument.documentElement; - resetFocusToInput("initializing for iframe_p"); - - testTabKey(true, root, false, prev, true, - false, "input#prev[readonly] -> html (has p[contenteditable=true])"); - testTabKey(true, editor, true, root, false, - true, "html (has p[contenteditable=true]) -> p[contentediable=true]"); - testTabKey(true, next, true, editor, true, - false, "p[contentediable=true] -> input#next[readonly]"); - testTabKey(false, editor, true, next, true, - true, "input#next[readonly] -> p[contentediable=true]"); - testTabKey(false, root, false, editor, true, - false, "p[contenteditable=true] -> html (has p[contenteditable=true])"); - testTabKey(false, prev, true, root, false, - false, "html (has p[contenteditable=true]) -> input#prev[readonly]"); - prev.style.display = "none"; - - resetFocusToParentHTML("testing iframe_p"); - testTabKey(true, root, false, html, false, - false, "html of parent -> html (has p[contentediable=true])"); - testTabKey(false, html, false, root, false, - false, "html (has p[contentediable=true]) -> html of parent"); - prev.style.display = "inline"; - resetFocusToInput("after parent html <-> html (has p[contentediable=true])"); - - testMouseClick(root, false, true, prev, true, false, "iframe_p"); - - testOnEditorFlagChange("p[contenteditable=true]", false); - - iframe.style.display = "none"; - - window.close(); -} - -</script> -</body> - -</html> diff --git a/widget/tests/window_mouse_scroll_win.html b/widget/tests/window_mouse_scroll_win.html deleted file mode 100644 index 4a83e23ef..000000000 --- a/widget/tests/window_mouse_scroll_win.html +++ /dev/null @@ -1,1531 +0,0 @@ -<html lang="en-US" - style="font-family: Arial; font-size: 10px; line-height: 16px;"> -<head> - <title>Test for mouse scroll handling on Windows</title> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> - <link rel="stylesheet" type="text/css" - href="chrome://mochikit/content/tests/SimpleTest/test.css" /> -</head> -<body onunload="onUnload();"> -<div id="display" style="width: 5000px; height: 5000px;"> -<p id="p1" style="font-size: 16px; width: 100px; height: 100px;">1st <p>.</p> -<p id="p2" style="font-size: 32px; width: 100px; height: 100px;">2nd <p>.</p> -</div> -<script class="testbody" type="application/javascript"> - -window.opener.wrappedJSObject.SimpleTest.waitForFocus(prepareTests, window); - -const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils; - -const WHEEL_PAGESCROLL = 4294967295; - -const WM_VSCROLL = 0x0115; -const WM_HSCROLL = 0x0114; -const WM_MOUSEWHEEL = 0x020A; -const WM_MOUSEHWHEEL = 0x020E; - -const SB_LINEUP = 0; -const SB_LINELEFT = 0; -const SB_LINEDOWN = 1; -const SB_LINERIGHT = 1; -const SB_PAGEUP = 2; -const SB_PAGELEFT = 2; -const SB_PAGEDOWN = 3; -const SB_PAGERIGHT = 3; - -const SHIFT_L = 0x0100; -const SHIFT_R = 0x0200; -const CTRL_L = 0x0400; -const CTRL_R = 0x0800; -const ALT_L = 0x1000; -const ALT_R = 0x2000; - -const DOM_PAGE_SCROLL_DELTA = 32768; - -const kSystemScrollSpeedOverridePref = "mousewheel.system_scroll_override_on_root_content.enabled"; - -const kAltKeyActionPref = "mousewheel.with_alt.action"; -const kCtrlKeyActionPref = "mousewheel.with_control.action"; -const kShiftKeyActionPref = "mousewheel.with_shift.action"; -const kWinKeyActionPref = "mousewheel.with_win.action"; - -const kAltKeyDeltaMultiplierXPref = "mousewheel.with_alt.delta_multiplier_x"; -const kAltKeyDeltaMultiplierYPref = "mousewheel.with_alt.delta_multiplier_y"; -const kCtrlKeyDeltaMultiplierXPref = "mousewheel.with_control.delta_multiplier_x"; -const kCtrlKeyDeltaMultiplierYPref = "mousewheel.with_control.delta_multiplier_y"; -const kShiftKeyDeltaMultiplierXPref = "mousewheel.with_shift.delta_multiplier_x"; -const kShiftKeyDeltaMultiplierYPref = "mousewheel.with_shift.delta_multiplier_y"; -const kWinKeyDeltaMultiplierXPref = "mousewheel.with_win.delta_multiplier_x"; -const kWinKeyDeltaMultiplierYPref = "mousewheel.with_win.delta_multiplier_y"; - -const kEmulateWheelByWMSCROLLPref = "mousewheel.emulate_at_wm_scroll"; -const kVAmountPref = "mousewheel.windows.vertical_amount_override"; -const kHAmountPref = "mousewheel.windows.horizontal_amount_override"; -const kTimeoutPref = "mousewheel.windows.transaction.timeout"; - -const kMouseLineScrollEvent = "DOMMouseScroll"; -const kMousePixelScrollEvent = "MozMousePixelScroll"; - -const kVAxis = Components.interfaces.nsIDOMMouseScrollEvent.VERTICAL_AXIS; -const kHAxis = Components.interfaces.nsIDOMMouseScrollEvent.HORIZONTAL_AXIS; - -var gLineHeight = 0; -var gCharWidth = 0; -var gPageHeight = 0; -var gPageWidth = 0; - -var gP1 = document.getElementById("p1"); -var gP2 = document.getElementById("p2"); - -var gOtherWindow; - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -function todo_is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.todo_is(aLeft, aRight, aMessage); -} - -function onUnload() -{ - SpecialPowers.clearUserPref(kAltKeyActionPref); - SpecialPowers.clearUserPref(kCtrlKeyActionPref); - SpecialPowers.clearUserPref(kShiftKeyActionPref); - SpecialPowers.clearUserPref(kWinKeyActionPref); - - SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierXPref); - SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierYPref); - SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierXPref); - SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierYPref); - SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierXPref); - SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierYPref); - SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref); - SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref); - - SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref); - SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref); - SpecialPowers.clearUserPref(kVAmountPref); - SpecialPowers.clearUserPref(kHAmountPref); - SpecialPowers.clearUserPref(kTimeoutPref); - window.opener.wrappedJSObject.SimpleTest.finish(); -} - -function getWindowUtils(aWindow) -{ - if (!aWindow) { - aWindow = window; - } - return aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(nsIDOMWindowUtils); -} - -function getPointInScreen(aElement, aWindow) -{ - if (!aWindow) { - aWindow = window; - } - var bounds = aElement.getBoundingClientRect(); - return { x: bounds.left + aWindow.mozInnerScreenX, - y: bounds.top + aWindow.mozInnerScreenY }; -} - -function cut(aNum) -{ - return (aNum >= 0) ? Math.floor(aNum) : Math.ceil(aNum); -} - -/** - * Make each steps for the tests in following arrays in global scope. Each item - * of the arrays will be executed after previous test is finished. - * - * description: - * Set the description of the test. This will be used for the message of is() - * or the others. - * - * message: - * aNativeMessage of nsIDOMWindowUtils.sendNativeMouseScrollEvent(). - * Must be WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL or WM_HSCROLL. - * - * delta: - * The native delta value for WM_MOUSEWHEEL or WM_MOUSEHWHEEL. - * Or one of the SB_* const value for WM_VSCROLL or WM_HSCROLL. - * - * target: - * The target element, under the mouse cursor. - * - * window: - * The window which is used for getting nsIDOMWindowUtils. - * - * modifiers: - * Pressed modifier keys, 0 means no modifier key is pressed. - * Otherwise, one or more values of SHIFT_L, SHIFT_R, CTRL_L, CTRL_R, - * ALT_L or ALT_R. - * - * additionalFlags: - * aAdditionalFlags of nsIDOMWindowUtils.sendNativeMouseScrollEvent(). - * See the document of nsIDOMWindowUtils for the detail of the values. - * - * onLineScrollEvent: - * Must be a function or null. - * If the value is a function, it will be called when DOMMouseScroll event - * is received by the synthesized event. - * If return true, the common checks are canceled. - * - * onPixelScrollEvent: - * Must be a function or null. - * If the value is a function, it will be called when MozMousePixelScroll - * event is received by the synthesized event. - * If return true, the common checks are canceled. - * - * expected: - * Must not be null and this must have: - * axis: - * kVAxis if the synthesized event causes vertical scroll. Otherwise, - * it causes horizontal scroll, kHAxis. - * lines: - * Integer value which is expected detail attribute value of - * DOMMouseScroll. If the event shouldn't be fired, must be 0. - * pixels: - * Integer value or a function which returns double value. The value is - * expected detail attribute value of MozMousePixelScroll. - * If the event shouldn't be fired, must be 0. - * - * Note that if both lines and pixels are 0, the test framework waits - * a few seconds. After that, go to next test. - * - * init: - * Must be a function or null. If this value is a function, it's called - * before synthesizing the native event. - * - * finish: - * Must be a function or null. If this value is a function, it's called - * after received all expected events or timeout if no events are expected. - */ - -// First, get the computed line height, char width, page height and page width. -var gPreparingSteps = [ - { description: "Preparing gLineHeight", - message: WM_MOUSEWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - onLineScrollEvent: function (aEvent) { - return true; - }, - onPixelScrollEvent: function (aEvent) { - gLineHeight = aEvent.detail; - return true; - }, - expected: { - axis: kVAxis, lines: 1, pixels: 1, - }, - init: function () { - SpecialPowers.setIntPref(kVAmountPref, 1); - SpecialPowers.setIntPref(kHAmountPref, 1); - }, - }, - { description: "Preparing gCharWidth", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - onLineScrollEvent: function (aEvent) { - return true; - }, - onPixelScrollEvent: function (aEvent) { - gCharWidth = aEvent.detail; - return true; - }, - expected: { - axis: kVAxis, lines: 1, pixels: 1, - }, - }, - { description: "Preparing gPageHeight", - message: WM_MOUSEWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - onLineScrollEvent: function (aEvent) { - return true; - }, - onPixelScrollEvent: function (aEvent) { - gPageHeight = aEvent.detail; - return true; - }, - expected: { - axis: kHAxis, lines: 1, pixels: 1, - }, - init: function () { - SpecialPowers.setIntPref(kVAmountPref, 0xFFFF); - SpecialPowers.setIntPref(kHAmountPref, 0xFFFF); - }, - }, - { description: "Preparing gPageWidth", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - onLineScrollEvent: function (aEvent) { - return true; - }, - onPixelScrollEvent: function (aEvent) { - gPageWidth = aEvent.detail; - return true; - }, - expected: { - axis: kHAxis, lines: 1, pixels: 1, - }, - finish: function () { - ok(gLineHeight > 0, "gLineHeight isn't positive got " + gLineHeight); - ok(gCharWidth > 0, "gCharWidth isn't positive got " + gCharWidth); - ok(gPageHeight > 0, "gPageHeight isn't positive got " + gPageHeight); - ok(gPageWidth > 0, "gPageWidth isn't positive got " + gPageWidth); - - ok(gPageHeight > gLineHeight, - "gPageHeight must be larger than gLineHeight"); - ok(gPageWidth > gCharWidth, - "gPageWidth must be larger than gCharWidth"); - runNextTest(gBasicTests, 0) - } - }, -]; - -var gBasicTests = [ - // Widget shouldn't dispatch a pixel event if the delta can be devided by - // lines to be scrolled. However, pixel events should be fired by ESM. - { description: "WM_MOUSEWHEEL, -120, 3 lines", - message: WM_MOUSEWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, - }, - init: function () { - SpecialPowers.setIntPref(kVAmountPref, 3); - SpecialPowers.setIntPref(kHAmountPref, 3); - }, - }, - - { description: "WM_MOUSEWHEEL, 120, -3 lines", - message: WM_MOUSEWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 120, 3 chars", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -120, -3 chars", - message: WM_MOUSEHWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, - }, - }, - - // Pixel scroll event should be fired always but line scroll event should be - // fired only when accumulated delta value is over a line. - { description: "WM_MOUSEWHEEL, -20, 0.5 lines", - message: WM_MOUSEWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / 2; }, - }, - }, - { description: "WM_MOUSEWHEEL, -20, 0.5 lines (pending: 0.5 lines)", - message: WM_MOUSEWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight / 2; }, - }, - }, - { description: "WM_MOUSEWHEEL, -20, 0.5 lines", - message: WM_MOUSEWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / 2; }, - }, - }, - - { description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: 0.5 lines)", - message: WM_MOUSEWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / -2; }, - }, - }, - { description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: -0.5 lines)", - message: WM_MOUSEWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight / 2; }, - }, - }, - { description: "WM_MOUSEWHEEL, 20, -0.5 lines", - message: WM_MOUSEWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / -2; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 20, 0.5 chars", - message: WM_MOUSEHWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / 2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 20, 0.5 chars (pending: 0.5 chars)", - message: WM_MOUSEHWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth / 2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 20, 0.5 chars", - message: WM_MOUSEHWHEEL, delta: 20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / 2; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: 0.5 chars)", - message: WM_MOUSEHWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: -0.5 chars)", - message: WM_MOUSEHWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth / 2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, -20, -0.5 chars", - message: WM_MOUSEHWHEEL, delta: -20, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, - }, - }, - - // Even if the mouse cursor is an element whose font-size is different than - // the scrollable element, the pixel scroll amount shouldn't be changed. - // Widget shouldn't dispatch a pixel event if the delta can be devided by - // lines to be scrolled. However, pixel events should be fired by ESM. - { description: "WM_MOUSEWHEEL, -120, 3 lines, on the other div whose font-size is larger", - message: WM_MOUSEWHEEL, delta: -120, - target: gP2, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, - }, - }, - - { description: "WM_MOUSEWHEEL, 120, -3 lines, on the other div whose font-size is larger", - message: WM_MOUSEWHEEL, delta: 120, - target: gP2, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 120, 3 chars, on the other div whose font-size is larger", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP2, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -120, -3 chars, on the other div whose font-size is larger", - message: WM_MOUSEHWHEEL, delta: -120, - target: gP2, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, - }, - }, - - // Modifier key tests - { description: "WM_MOUSEWHEEL, -40, 1 line with left Shift", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_L, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_MOUSEWHEEL, -40, 1 line with right Shift", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_R, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_MOUSEWHEEL, -40, 1 line with left Ctrl", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_MOUSEWHEEL, -40, 1 line with right Ctrl", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_R, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_MOUSEWHEEL, -40, 1 line with left Alt", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_L, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_MOUSEWHEEL, -40, 1 line with right Alt", - message: WM_MOUSEWHEEL, delta: -40, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_R, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 40, 1 character with left Shift", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_L, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 40, 1 character with right Shift", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_R, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 40, 1 character with left Ctrl", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 40, 1 character with right Ctrl", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_R, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 40, 1 character with left Alt", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_L, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 40, 1 character with right Alt", - message: WM_MOUSEHWHEEL, delta: 40, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_R, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - - finish: function () { - runNextTest(gScrollMessageTests, 0); - } - }, -]; - -var gPageScrllTests = [ - // Pixel scroll event should be fired always but line scroll event should be - // fired only when accumulated delta value is over a line. - { description: "WM_MOUSEWHEEL, -60, 0.5 pages", - message: WM_MOUSEWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / 2; }, - }, - }, - { description: "WM_MOUSEWHEEL, -60, 0.5 pages (pending: 0.5 pages)", - message: WM_MOUSEWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return ((gPageHeight / 2) + (gPageHeight % 2)); }, - }, - }, - { description: "WM_MOUSEWHEEL, -60, 0.5 pages", - message: WM_MOUSEWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / 2; }, - }, - }, - - { description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: 0.5 pages)", - message: WM_MOUSEWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / -2; }, - }, - }, - { description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: -0.5 pages)", - message: WM_MOUSEWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -((gPageHeight / 2) + (gPageHeight % 2)); }, - }, - }, - { description: "WM_MOUSEWHEEL, 60, -0.5 pages", - message: WM_MOUSEWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / -2; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 60, 0.5 pages", - message: WM_MOUSEHWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gPageWidth / 2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, 60, 0.5 pages (pending: 0.5 pages)", - message: WM_MOUSEHWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return ((gPageWidth / 2) + (gPageWidth % 2)); }, - }, - }, - { description: "WM_MOUSEHWHEEL, 60, 0.5 pages", - message: WM_MOUSEHWHEEL, delta: 60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gPageWidth / 2; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: 0.5 pages)", - message: WM_MOUSEHWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, - }, - }, - { description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: -0.5 pages)", - message: WM_MOUSEHWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -((gCharWidth / 2) + (gCharWidth % 2)); }, - }, - }, - { description: "WM_MOUSEHWHEEL, -60, -0.5 pages", - message: WM_MOUSEHWHEEL, delta: -60, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, - }, - }, -]; - -var gScrollMessageTests = [ - // Widget should dispatch neither line scroll event nor pixel scroll event if - // the WM_*SCROLL's lParam is NULL and mouse wheel emulation is disabled. - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: 0, - }, - init: function () { - SpecialPowers.setIntPref(kVAmountPref, 3); - SpecialPowers.setIntPref(kHAmountPref, 3); - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); - }, - }, - - { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 0, pixels: 0, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: 0, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 0, pixels: 0, - }, - }, - - // Widget should emulate mouse wheel behavior for WM_*SCROLL even if the - // kEmulateWheelByWMSCROLLPref is disabled but the message's lParam is not - // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages, - // but ESM dispatches it instead. - { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - - { description: "WM_VSCROLL, SB_PAGEUP, lParam is not NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_PAGEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -gPageHeight; }, - }, - }, - - { description: "WM_VSCROLL, SB_PAGEDOWN, lParam is not NULL, emulation disabled", - message: WM_VSCROLL, delta: SB_PAGEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return gPageHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_PAGELEFT, lParam is not NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_PAGELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -gPageWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_PAGERIGHT, lParam is not NULL, emulation disabled", - message: WM_HSCROLL, delta: SB_PAGERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return gPageWidth; }, - }, - }, - - // Widget should emulate mouse wheel behavior for WM_*SCROLL when the - // kEmulateWheelByWMSCROLLPref is enabled even if the message's lParam is - // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages, - // but ESM dispatches it instead. - { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - - { description: "WM_VSCROLL, SB_PAGEUP, lParam is NULL, emulation enabled", - message: WM_VSCROLL, delta: SB_PAGEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -gPageHeight; }, - }, - }, - - { description: "WM_VSCROLL, SB_PAGEDOWN, lParam is NULL, emulation enabled", - message: WM_VSCROLL, delta: SB_PAGEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return gPageHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_PAGELEFT, lParam is NULL, emulation enabled", - message: WM_HSCROLL, delta: SB_PAGELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, - pixels: function () { return -gPageWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_PAGERIGHT, lParam is NULL, emulation enabled", - message: WM_HSCROLL, delta: SB_PAGERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, - pixels: function () { return gPageWidth; }, - }, - }, - - // Modifier key tests for WM_*SCROLL - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Shift", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); - }, - }, - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Shift", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_R, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Ctrl", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Ctrl", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Alt", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Alt", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_R, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Shift", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Shift", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: SHIFT_R, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Ctrl", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Ctrl", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: CTRL_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Alt", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_L, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Alt", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: ALT_R, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - - finish: function () { - runDeactiveWindowTests(); - } - }, -]; - -var gDeactiveWindowTests = [ - // Typically, mouse drivers send wheel messages to focused window. - // However, we prefer to scroll a scrollable element under the mouse cursor. - { description: "WM_MOUSEWHEEL, -120, 3 lines, window is deactive", - message: WM_MOUSEWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, - }, - init: function () { - SpecialPowers.setIntPref(kVAmountPref, 3); - SpecialPowers.setIntPref(kHAmountPref, 3); - }, - onLineScrollEvent: function (aEvent) { - var fm = Components.classes["@mozilla.org/focus-manager;1"]. - getService(Components.interfaces.nsIFocusManager); - is(fm.activeWindow, gOtherWindow, "The other window isn't activated"); - }, - }, - - { description: "WM_MOUSEWHEEL, 120, -3 lines, window is deactive", - message: WM_MOUSEWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 120, 3 chars, window is deactive", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -120, -3 chars, window is deactive", - message: WM_MOUSEHWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, - }, - }, - - // Of course, even if some drivers prefer the cursor position, we don't need - // to change anything. - { description: "WM_MOUSEWHEEL, -120, 3 lines, window is deactive (receive the message directly)", - message: WM_MOUSEWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, - }, - }, - - { description: "WM_MOUSEWHEEL, 120, -3 lines, window is deactive (receive the message directly)", - message: WM_MOUSEWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, 120, 3 chars, window is deactive (receive the message directly)", - message: WM_MOUSEHWHEEL, delta: 120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, - }, - }, - - { description: "WM_MOUSEHWHEEL, -120, -3 chars, window is deactive (receive the message directly)", - message: WM_MOUSEHWHEEL, delta: -120, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, - }, - }, - - // Same for WM_*SCROLL if lParam is not NULL - { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - - // Same for WM_*SCROLL if lParam is NULL but emulation is enabled - { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: 0, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - - // Same for WM_*SCROLL if lParam is not NULL and message sent to the deactive window directly - { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | - nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | - nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | - nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | - nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - }, - - // Same for WM_*SCROLL if lParam is NULL but emulation is enabled, and message sent to the deactive window directly - { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", - message: WM_VSCROLL, delta: SB_LINEUP, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, - }, - init: function () { - SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); - }, - }, - - { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", - message: WM_VSCROLL, delta: SB_LINEDOWN, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", - message: WM_HSCROLL, delta: SB_LINELEFT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, - }, - }, - - { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", - message: WM_HSCROLL, delta: SB_LINERIGHT, - target: gP1, x: 10, y: 10, window: window, - modifiers: 0, - additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, - expected: { - axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, - }, - - finish: function () { - gOtherWindow.close(); - gOtherWindow = null; - window.close(); - } - }, -]; - -function runDeactiveWindowTests() -{ - gOtherWindow = window.open("data:text/html,", "_blank", - "chrome,width=100,height=100,top=700,left=700"); - - window.opener.wrappedJSObject.SimpleTest.waitForFocus(function () { - runNextTest(gDeactiveWindowTests, 0); - }, gOtherWindow); -} - -function runNextTest(aTests, aIndex) -{ - if (aIndex > 0 && aTests[aIndex - 1] && aTests[aIndex - 1].finish) { - aTests[aIndex - 1].finish(); - } - - if (aTests.length == aIndex) { - return; - } - - var test = aTests[aIndex++]; - if (test.init) { - test.init(); - } - test.handled = { lines: false, pixels: false }; - - switch (test.message) { - case WM_MOUSEWHEEL: - case WM_MOUSEHWHEEL: - case WM_VSCROLL: - case WM_HSCROLL: - var expectedLines = test.expected.lines; - var expectedPixels = - cut((typeof test.expected.pixels == "function") ? - test.expected.pixels() : test.expected.pixels); - var handler = function (aEvent) { - var doCommonTests = true; - - if (!aEvent) { - ok(!test.handled.lines, - test.description + ", line scroll event has been handled"); - ok(!test.handled.pixels, - test.description + ", pixel scroll event has been handled"); - doCommonTests = false; - } else if (aEvent.type == kMouseLineScrollEvent) { - ok(!test.handled.lines, - test.description + ":(" + aEvent.type + "), same event has already been handled"); - test.handled.lines = true; - isnot(expectedLines, 0, - test.description + ":(" + aEvent.type + "), event shouldn't be fired"); - if (test.onLineScrollEvent && test.onLineScrollEvent(aEvent)) { - doCommonTests = false; - } - } else if (aEvent.type == kMousePixelScrollEvent) { - ok(!test.handled.pixels, - test.description + ":(" + aEvent.type + "), same event has already been handled"); - test.handled.pixels = true; - isnot(expectedPixels, 0, - test.description + ":(" + aEvent.type + "), event shouldn't be fired"); - if (test.onPixelScrollEvent && test.onPixelScrollEvent(aEvent)) { - doCommonTests = false; - } - } - - if (doCommonTests) { - var expectedDelta = - (aEvent.type == kMouseLineScrollEvent) ? - expectedLines : expectedPixels; - is(aEvent.target.id, test.target.id, - test.description + ":(" + aEvent.type + "), ID mismatch"); - is(aEvent.axis, test.expected.axis, - test.description + ":(" + aEvent.type + "), axis mismatch"); - ok(aEvent.detail != 0, - test.description + ":(" + aEvent.type + "), delta must not be 0"); - is(aEvent.detail, expectedDelta, - test.description + ":(" + aEvent.type + "), delta mismatch"); - is(aEvent.shiftKey, (test.modifiers & (SHIFT_L | SHIFT_R)) != 0, - test.description + ":(" + aEvent.type + "), shiftKey mismatch"); - is(aEvent.ctrlKey, (test.modifiers & (CTRL_L | CTRL_R)) != 0, - test.description + ":(" + aEvent.type + "), ctrlKey mismatch"); - is(aEvent.altKey, (test.modifiers & (ALT_L | ALT_R)) != 0, - test.description + ":(" + aEvent.type + "), altKey mismatch"); - } - - if (!aEvent || (test.handled.lines || expectedLines == 0) && - (test.handled.pixels || expectedPixels == 0)) { - // Don't scroll actually. - if (aEvent) { - aEvent.preventDefault(); - } - test.target.removeEventListener(kMouseLineScrollEvent, handler, true); - test.target.removeEventListener(kMousePixelScrollEvent, handler, true); - setTimeout(runNextTest, 0, aTests, aIndex); - } - }; - - test.target.addEventListener(kMouseLineScrollEvent, handler, true); - test.target.addEventListener(kMousePixelScrollEvent, handler, true); - - if (expectedLines == 0 && expectedPixels == 0) { - // The timeout might not be enough if system is slow by other process, - // so, the test might be passed unexpectedly. However, it must be able - // to be detected by random orange. - setTimeout(handler, 500); - } - - var utils = getWindowUtils(test.window); - var ptInScreen = getPointInScreen(test.target, test.window); - var isVertical = - ((test.message == WM_MOUSEWHEEL) || (test.message == WM_VSCROLL)); - var deltaX = !isVertical ? test.delta : 0; - var deltaY = isVertical ? test.delta : 0; - utils.sendNativeMouseScrollEvent(ptInScreen.x + test.x, - ptInScreen.y + test.y, - test.message, deltaX, deltaY, 0, - test.modifiers, - test.additionalFlags, - test.target); - break; - default: - ok(false, test.description + ": invalid message"); - // Let's timeout. - } -} - -function prepareTests() -{ - // Disable special action with modifier key - SpecialPowers.setIntPref(kAltKeyActionPref, 1); - SpecialPowers.setIntPref(kCtrlKeyActionPref, 1); - SpecialPowers.setIntPref(kShiftKeyActionPref, 1); - SpecialPowers.setIntPref(kWinKeyActionPref, 1); - - SpecialPowers.setIntPref(kAltKeyDeltaMultiplierXPref, 100); - SpecialPowers.setIntPref(kAltKeyDeltaMultiplierYPref, 100); - SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierXPref, 100); - SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierYPref, 100); - SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierXPref, 100); - SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierYPref, 100); - SpecialPowers.setIntPref(kWinKeyDeltaMultiplierXPref, 100); - SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref, 100); - - SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false); - SpecialPowers.setIntPref(kTimeoutPref, -1); - - runNextTest(gPreparingSteps, 0); -} - -</script> -</body> - -</html> diff --git a/widget/tests/window_picker_no_crash_child.html b/widget/tests/window_picker_no_crash_child.html deleted file mode 100644 index 51bf1b1e6..000000000 --- a/widget/tests/window_picker_no_crash_child.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> - <title>Picker window</title> -</head> -<body> -<form name="form1"> -<input type="file" name="uploadbox"> -</form> -</body> -</html> diff --git a/widget/tests/window_state_windows.xul b/widget/tests/window_state_windows.xul deleted file mode 100644 index 9643e1dad..000000000 --- a/widget/tests/window_state_windows.xul +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0"?> - -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> - -<window id="NativeWindow" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - width="300" - height="300" - onload="onLoad();" - title="Window State Tests"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript"> - <![CDATA[ - - let Cc = Components.classes; - let Ci = Components.interfaces; - let Cu = Components.utils; - Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - - SimpleTest.waitForExplicitFinish(); - - function onLoad() { - var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - - /* - switch(win.windowState) { - case win.STATE_FULLSCREEN: - dump("STATE_FULLSCREEN \n"); - break; - case win.STATE_MAXIMIZED: - dump("STATE_MAXIMIZED \n"); - break; - case win.STATE_MINIMIZED: - dump("STATE_MINIMIZED \n"); - break; - case win.STATE_NORMAL: - dump("STATE_NORMAL \n"); - break; - } - */ - - // Make sure size mode changes are reflected in the widget. - win.restore(); - ok(win.windowState == win.STATE_NORMAL, "window state is restored."); - win.minimize(); - ok(win.windowState == win.STATE_MINIMIZED, "window state is minimized."); - - // Windows resizes children to 0x0. Code in nsWindow filters these changes out. Without - // this all sorts of screwy things can happen in child widgets. - ok(document.height > 0, "document height should not be zero for a minimized window!"); - ok(document.width > 0, "document width should not be zero for a minimized window!"); - - // Make sure size mode changes are reflected in the widget. - win.restore(); - ok(win.windowState == win.STATE_NORMAL, "window state is restored."); - win.maximize(); - ok(win.windowState == win.STATE_MAXIMIZED, "window state is maximized."); - win.restore(); - ok(win.windowState == win.STATE_NORMAL, "window state is restored."); - - /* - dump(win.screenX + "\n"); - win.minimize(); - dump(win.screenX + "\n"); - win.restore(); - dump(win.screenX + "\n"); - */ - - SimpleTest.finish(); - } - - ]]> - </script> - <body xmlns="http://www.w3.org/1999/xhtml"> - <p id="display"></p> - <div id="content" style="display: none"></div> - <pre id="test"></pre> - </body> -</window> diff --git a/widget/tests/window_wheeltransaction.xul b/widget/tests/window_wheeltransaction.xul deleted file mode 100644 index 8573eb3a4..000000000 --- a/widget/tests/window_wheeltransaction.xul +++ /dev/null @@ -1,1560 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin" type="text/css"?> -<window title="Wheel scroll tests" - width="600" height="600" - onload="onload();" - onunload="onunload();" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" /> - <script type="application/javascript" - src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js" /> - -<body xmlns="http://www.w3.org/1999/xhtml"> -<style type="text/css"> - #rootview { - overflow: auto; - width: 400px; - height: 400px; - border: 1px solid; - } - #container { - overflow: auto; - width: 600px; - height: 600px; - } - #rootview pre { - margin: 20px 0 20px 20px; - padding: 0; - overflow: auto; - display: block; - width: 100px; - height: 100.5px; - font-size: 16px; - } -</style> -<div id="rootview" onscroll="onScrollView(event);"> - <div id="container"> - <pre id="subview1" onscroll="onScrollView(event);"> -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. - </pre> - <pre id="subview2" onscroll="onScrollView(event);"> -Text. -Text. -Text. -Text. -Text. -Text. -Text. -Text. -Text. -Text. - </pre> - <pre id="subview3" onscroll="onScrollView(event);"> -Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. Text. - </pre> - </div> -</div> -<div id="content" style="display: none"> -</div> -<pre id="test"> -</pre> -</body> - -<script class="testbody" type="application/javascript"> -<![CDATA[ - -function ok(aCondition, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); -} - -function is(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); -} - -function isnot(aLeft, aRight, aMessage) -{ - window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); -} - -var gCurrentTestListStatus = { nextListIndex: 0 }; -var gCurrentTest; - -const kListenEvent_None = 0; -const kListenEvent_OnScroll = 1; -const kListenEvent_OnScrollFailed = 2; -const kListenEvent_OnTransactionTimeout = 4; -const kListenEvent_All = kListenEvent_OnScroll | - kListenEvent_OnScrollFailed | - kListenEvent_OnTransactionTimeout; -var gLitesnEvents = kListenEvent_None; - -/** - * At unexpected transaction timeout, we need to stop *all* timers. But it is - * difficult and it can be create more complex testing code. So, we should use - * only one timer at one time. For that, we must store the timer id to this - * variable. And the functions which may be called via a timer must clear the - * current timer by |_clearTimer| function. - */ -var gTimer; - -var gPrefSvc = Components.classes["@mozilla.org/preferences-service;1"]. - getService(Components.interfaces.nsIPrefBranch); -const kPrefSmoothScroll = "general.smoothScroll"; -const kPrefNameTimeout = "mousewheel.transaction.timeout"; -const kPrefNameIgnoreMoveDelay = "mousewheel.transaction.ignoremovedelay"; -const kPrefTestEventsAsyncEnabled = "test.events.async.enabled"; - -const kDefaultTimeout = gPrefSvc.getIntPref(kPrefNameTimeout); -const kDefaultIgnoreMoveDelay = gPrefSvc.getIntPref(kPrefNameIgnoreMoveDelay); - -gPrefSvc.setBoolPref(kPrefSmoothScroll, false); -gPrefSvc.setBoolPref(kPrefTestEventsAsyncEnabled, true); - -var gTimeout, gIgnoreMoveDelay; -var gEnoughForTimeout, gEnoughForIgnoreMoveDelay; - -function setTimeoutPrefs(aTimeout, aIgnoreMoveDelay) -{ - gPrefSvc.setIntPref(kPrefNameTimeout, aTimeout); - gPrefSvc.setIntPref(kPrefNameIgnoreMoveDelay, aIgnoreMoveDelay); - gTimeout = aTimeout; - gIgnoreMoveDelay = aIgnoreMoveDelay; - gEnoughForTimeout = gTimeout * 2; - gEnoughForIgnoreMoveDelay = gIgnoreMoveDelay * 1.2; -} - -function resetTimeoutPrefs() -{ - if (gTimeout == kDefaultTimeout) - return; - setTimeoutPrefs(kDefaultTimeout, kDefaultIgnoreMoveDelay); - initTestList(); -} - -function growUpTimeoutPrefs() -{ - if (gTimeout != kDefaultTimeout) - return; - setTimeoutPrefs(5000, 1000); - initTestList(); -} - -// setting enough time for testing. -gPrefSvc.setIntPref(kPrefNameTimeout, gTimeout); -gPrefSvc.setIntPref(kPrefNameIgnoreMoveDelay, gIgnoreMoveDelay); - -var gRootView = document.getElementById("rootview"); -var gSubView1 = document.getElementById("subview1"); -var gSubView2 = document.getElementById("subview2"); -var gSubView3 = document.getElementById("subview3"); - -gRootView.addEventListener("MozMouseScrollFailed", onMouseScrollFailed, false); -gRootView.addEventListener("MozMouseScrollTransactionTimeout", - onTransactionTimeout, false); - -function finish() -{ - window.close(); -} - -function onload() -{ - runNextTestList(); -} - -function onunload() -{ - resetTimeoutPrefs(); - gPrefSvc.clearUserPref(kPrefSmoothScroll); - gPrefSvc.clearUserPref(kPrefTestEventsAsyncEnabled); - disableNonTestMouseEvents(false); - SpecialPowers.DOMWindowUtils.restoreNormalRefresh(); - window.opener.wrappedJSObject.SimpleTest.finish(); -} - -const kSubView1Offset = { x: 20, y: 20 }; -const kSubView2Offset = { x: 20, y: 20 + 100 + 20 }; -const kSubView3Offset = { x: 20, y: 20 + (100 + 20) * 2 }; - -function _getSubViewTestPtForV(aPt) -{ - return { x: aPt.x + 10, y: aPt.y + 10 }; -} - -const kPtInRootViewForV = { x: kSubView1Offset.x + 10, - y: kSubView1Offset.y - 10 }; -const kPtInSubView1ForV = _getSubViewTestPtForV(kSubView1Offset); -const kPtInSubView2ForV = _getSubViewTestPtForV(kSubView2Offset); -const kPtInSubView3ForV = _getSubViewTestPtForV(kSubView3Offset); - -function _convertTestPtForH(aPt) -{ - return { x: aPt.y, y: aPt.x }; -} - -const kPtInRootViewForH = _convertTestPtForH(kPtInRootViewForV); -const kPtInSubView1ForH = _convertTestPtForH(kPtInSubView1ForV); -const kPtInSubView2ForH = _convertTestPtForH(kPtInSubView2ForV); -const kPtInSubView3ForH = _convertTestPtForH(kPtInSubView3ForV); - -/** - * Define the tests here: - * Scrolls are processed async always. Therefore, we need to call all tests - * by timer. gTestLists is array of testing lists. In other words, an item - * of gTestList is a group of one or more testing. Each items has following - * properties: - * - * - retryWhenTransactionTimeout - * The testing of wheel transaction might be fialed randomly by - * timeout. Then, automatically the failed test list will be retested - * automatically only this number of times. - * - * - steps - * This property is array of testing. Each steps must have following - * properties at least. - * - * - func - * This property means function which will be called via - * |setTimeout|. The function cannot have params. If you need - * some additional parameters, you can specify some original - * properties for the test function. If you do so, you should - * document it in the testing function. - * - delay - * This property means delay time until the function to be called. - * I.e., the value used for the second param of |setTimeout|. - * - * And also you need one more property when you call a testing function. - * - * - description - * This property is description of the test. This is used for - * logging. - * - * At testing, you can access to current step via |gCurrentTest|. - */ - -var gTestLists; -function initTestList() -{ - gTestLists = [ - /************************************************************************** - * Continuous scrolling test for |gRootView| - * |gRootView| has both scrollbars and it has three children which are - * |gSubView1|, |gSubView2| and |gSubView3|. They have scrollbars. If - * the current transaction targets |gRootView|, other children should not - * be scrolled even if the wheel events are fired on them. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Vertical wheel events should scroll |gRootView| even if the position - // of wheel events in a child view which has scrollbar. - { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Continuous scrolling test for root view (vertical/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Continuous scrolling test for root view (vertical/backward)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Horizontal wheel events should scroll |gRootView| even if the - // position of wheel events in a child view which has scrollbar. - { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Continuous scrolling test for root view (horizontal/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Continuous scrolling test for root view (horizontal/backward)" } - ] - }, - - - /************************************************************************** - * Continuous scrolling test for |gSubView1| - * |gSubView1| has both scrollbars. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Vertical wheel events should scroll |gSubView1|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Continuous scrolling test for sub view 1 (vertical/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: false, isVertical: true, expectedView: gSubView1, - description: "Continuous scrolling test for sub view 1 (vertical/backward)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Horitontal wheel events should scroll |gSubView1|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - description: "Continuous scrolling test for sub view 1 (horizontal/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: false, isVertical: false, expectedView: gSubView1, - description: "Continuous scrolling test for sub view 1 (horizontal/backward)" } - ] - }, - - - /************************************************************************** - * Continuous scrolling test for |gSubView2| - * |gSubView2| has only vertical scrollbar. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Vertical wheel events should scroll |gSubView2|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForV, - isForward: true, isVertical: true, expectedView: gSubView2, - description: "Continuous scrolling test for sub view 2 (vertical/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForV, - isForward: false, isVertical: true, expectedView: gSubView2, - description: "Continuous scrolling test for sub view 2 (vertical/backward)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Horizontal wheel events should scroll its nearest scrollable ancestor - // view, i.e., it is |gRootView|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Continuous scrolling test for sub view 2 (horizontal/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView2ForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Continuous scrolling test for sub view 2 (horizontal/backward)" } - ] - }, - - - /************************************************************************** - * Continuous scrolling test for |gSubView3| - * |gSubView3| has only horizontal scrollbar. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Vertical wheel events should scroll its nearest scrollable ancestor - // view, i.e., it is |gRootView|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Continuous scrolling test for sub view 3 (vertical/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Continuous scrolling test for sub view 3 (vertical/backward)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Horitontal wheel events should scroll |gSubView3|. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForH, - isForward: true, isVertical: false, expectedView: gSubView3, - description: "Continuous scrolling test for sub view 3 (horizontal/forward)" }, - { func: testContinuousScroll, delay: 0, offset: kPtInSubView3ForH, - isForward: false, isVertical: false, expectedView: gSubView3, - description: "Continuous scrolling test for sub view 3 (horizontal/backward)" } - ] - }, - - - /************************************************************************** - * Don't reset transaction by a different direction wheel event - * Even if a wheel event doesn't same direction as last wheel event, the - * current transaction should not be reset. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical -> Horizontal - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView| by a vertical wheel - // event. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Don't reset transaction by a different direction wheel event (1-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Don't reset transaction by a different direction wheel event (1-2)" }, - // Send a horizontal wheel event over |gSubView1| but |gRootView| should - // be scrolled. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Don't reset transaction by a different direction wheel event (1-3)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal -> Vertical - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView| by a horizontal wheel - // event. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Don't reset transaction by a different direction wheel event (2-1)" }, - // Scroll back to left-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Don't reset transaction by a different direction wheel event (2-2)" }, - // Send a vertical wheel event over |gSubView1| but |gRootView| should - // be scrolled. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Don't reset transaction by a different direction wheel event (2-3)" } - ] - }, - - - /************************************************************************** - * Don't reset transaction even if a wheel event cannot scroll - * Even if a wheel event cannot scroll to specified direction in the - * current target view, the transaction should not be reset. E.g., there - * are some devices which can scroll obliquely. If so, probably, users - * cannot input only intended direction. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // A view only has vertical scrollbar case. - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gSubView2|. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView2ForV, - isForward: true, isVertical: true, expectedView: gSubView2, - description: "Don't reset transaction even if a wheel event cannot scroll (1-1)" }, - // |gSubView2| doesn't have horizontal scrollbar but should not scroll - // any views. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView2ForV, - isForward: true, isVertical: false, expectedView: null, - description: "Don't reset transaction even if a wheel event cannot scroll (1-2)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // A view only has horizontal scrollbar case. - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gSubView3|. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView3ForV, - isForward: true, isVertical: false, expectedView: gSubView3, - description: "Don't reset transaction even if a wheel event cannot scroll (2-1)" }, - // |gSubView3| doesn't have vertical scrollbar but should not scroll any - // views. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView3ForV, - isForward: true, isVertical: true, expectedView: null, - description: "Don't reset transaction even if a wheel event cannot scroll (2-2)" } - ] - }, - - - /************************************************************************** - * Reset transaction by mouse down/mouse up events - * Mouse down and mouse up events should cause resetting the current - * transaction. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Reset transaction by mouse down/mouse up events (v-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Reset transaction by mouse down/mouse up events (v-2)" }, - // Send mouse button events which should reset the current transaction. - // So, the next wheel event should scroll |gSubView1|. - { func: sendMouseButtonEvents, delay: 0, - description: "sendMouseButtonEvents" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Reset transaction by mouse down/mouse up events (v-3)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Reset transaction by mouse down/mouse up events (h-1)" }, - // Scroll back to left-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Reset transaction by mouse down/mouse up events (h-2)" }, - // Send mouse button events which should reset the current transaction. - // So, the next wheel event should scroll |gSubView1|. - { func: sendMouseButtonEvents, delay: 0, - description: "sendMouseButtonEvents" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - description: "Reset transaction by mouse down/mouse up events (h-3)" } - ] - }, - - - /************************************************************************** - * Reset transaction by a key event - * A key event should cause resetting the current transaction. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a key event (v-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a key event (v-2)" }, - // Send a key event which should reset the current transaction. So, the - // next wheel event should scroll |gSubView1|. - { func: sendKeyEvents, delay: 0, key: "a", - description: "sendKeyEvents" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Reset transaction by a key event (v-3)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Reset transaction by a key event (h-1)" }, - // Scroll back to left-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Reset transaction by a key event (h-2)" }, - // Send a key event which should reset the current transaction. So, the - // next wheel event should scroll |gSubView1|. - { func: sendKeyEvents, delay: 0, key: "a", - description: "sendKeyEvents" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - description: "Reset transaction by a key event (h-3)" } - ] - }, - - - /************************************************************************** - * Reset transaction by a mouse move event - * A mouse move event can cause reseting the current transaction even if - * mouse cursor is inside the target view of current transaction. Only - * when a wheel event is fired after |gIgnoreMoveDelay| milliseconds since - * the first mouse move event from last wheel event, the transaction - * should be reset. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a mouse move event (v-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a mouse move event (v-2)" }, - // Send a mouse move event immediately after last wheel event, then, - // current transaction should be kept. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForV, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-3)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: false, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-4)" }, - // Send a mouse move event after |gIgnoreMoveDelay| milliseconds since - // last wheel event, then, current transaction should be kept. - { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForV, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-5)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: false, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-6)" }, - // Send a wheel event after |gIgnoreMoveDelay| milliseconds since last - // mouse move event but it is fired immediately after the last wheel - // event, then, current transaction should be kept. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForV, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-7)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: false, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (v-8)" }, - // Send a wheel event after |gIgnoreMoveDelay| milliseconds have passed - // since last mouse move event which is fired after |gIgnoreMoveDelay| - // milliseconds since last wheel event, then, current transaction should - // be reset. - { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForV, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - canFailRandomly: { possibleView: gRootView }, - description: "Reset transaction by a mouse move event (v-9)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-2)" }, - // Send a mouse move event immediately after last wheel event, then, - // current transaction should be kept. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForH, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-3)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: false, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-4)" }, - // Send a mouse move event after |gIgnoreMoveDelay| milliseconds since - // last wheel event, then, current transaction should be kept. - { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForH, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-5)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: false, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-6)" }, - // Send a wheel event after |gIgnoreMoveDelay| milliseconds since last - // mouse move event but it is fired immediately after the last wheel - // event, then, current transaction should be kept. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInSubView1ForH, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-7)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: false, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Reset transaction by a mouse move event (h-8)" }, - // Send a wheel event after |gIgnoreMoveDelay| milliseconds have passed - // since last mouse move event which is fired after |gIgnoreMoveDelay| - // milliseconds since last wheel event, then, current transaction should - // be reset. - { func: sendMouseMoveEvent, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForH, - description: "sendMouseMoveEvent" }, - { func: testOneTimeScroll, delay: gEnoughForIgnoreMoveDelay, - offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - canFailRandomly: { possibleView: gRootView }, - description: "Reset transaction by a mouse move event (h-9)" } - ] - }, - - - /************************************************************************** - * Reset transaction by a mouse move event on outside of view - * When mouse cursor is moved to outside of the current target view, the - * transaction should be reset immediately. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gSubView1|. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Reset transaction by a mouse move event on outside of view (v-1)" }, - // Send mouse move event over |gRootView|. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInRootViewForV, - description: "sendMouseMoveEvent" }, - // Send Wheel event over |gRootView| which should be scrolled. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a mouse move event on outside of view (v-2)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Create a transaction which targets |gSubView1|. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Reset transaction by a mouse move event on outside of view (h-1)" }, - // Send mouse move event over |gRootView|. - { func: sendMouseMoveEvent, delay: 0, offset: kPtInRootViewForH, - description: "sendMouseMoveEvent" }, - // Send Wheel event over |gRootView| which should be scrolled. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Reset transaction by a mouse move event on outside of view (h-2)" } - ] - }, - - - /************************************************************************** - * Timeout test - * A view should not be scrolled during another to be transaction for - * another view scrolling. However, a wheel event which is sent after - * timeout, a view which is under the mouse cursor should be scrolled. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // First, create a transaction which should target the |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Timeout test (v-1)" }, - // Scroll back to top-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForV, - isForward: false, isVertical: true, expectedView: gRootView, - description: "Timeout test (v-2)" }, - // A wheel event over |gSubView1| should not scroll it during current - // transaction. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Timeout test (v-3)" }, - // Scroll back to top-most again. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: false, isVertical: true, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Timeout test (v-4)" }, - // A wheel event over |gSubView1| after timeout should scroll - // |gSubView1|. - { func: testOneTimeScroll, delay: gEnoughForTimeout, - offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - isTimeoutTesting: true, - description: "Timeout test (v-5)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // First, create a transaction which should target the |gRootView|. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Timeout test (h-1)" }, - // Scroll back to left-most for easy cursor position specifying. - { func: testOneTimeScroll, delay: 0, offset: kPtInRootViewForH, - isForward: false, isVertical: false, expectedView: gRootView, - description: "Timeout test (h-2)" }, - // A wheel event over |gSubView1| should not scroll it during current - // transaction. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Timeout test (h-3)" }, - // Scroll back to left-most again. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: false, isVertical: false, expectedView: gRootView, - canFailRandomly: { possibleView: gSubView1 }, - description: "Timeout test (h-4)" }, - // A wheel event over |gSubView1| after timeout should scroll - // |gSubView1|. - { func: testOneTimeScroll, delay: gEnoughForTimeout, - offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - isTimeoutTesting: true, - description: "Timeout test (h-5)" } - ] - }, - - - /************************************************************************** - * Timeout test even with many wheel events - * This tests whether timeout is occurred event if wheel events are sent. - * The transaction should not be updated by non-scrollable wheel events. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - // Vertical case - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Scroll |gSubView1| to bottom-most. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - description: "Timeout test even with many wheel events (v-1)" }, - // Don't scroll any views before timeout. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: null, - canFailRandomly: { possibleView: gRootView }, - description: "Timeout test even with many wheel events (v-2)" }, - // Recreate a transaction which is scrolling |gRootView| after time out. - { func: testRestartScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gRootView, - description: "Timeout test even with many wheel events (v-3)" } - ] - }, - - - { retryWhenTransactionTimeout: 5, - steps: [ - // Horizontal case - { func: initElements, delay: 0, forVertical: false, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - // Scroll |gSubView1| to right-most. - { func: testContinuousScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gSubView1, - description: "Timeout test even with many wheel events (h-1)" }, - // Don't scroll any views before timeout. - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: null, - canFailRandomly: { possibleView: gRootView }, - description: "Timeout test even with many wheel events (h-2)" }, - // Recreate a transaction which is scrolling |gRootView| after time out. - { func: testRestartScroll, delay: 0, offset: kPtInSubView1ForH, - isForward: true, isVertical: false, expectedView: gRootView, - description: "Timeout test even with many wheel events (h-3)" } - ] - }, - - - /************************************************************************** - * Very large scrolling wheel event - * If the delta value is larger than the scrolling page size, it should be - * scrolled only one page instead of the delta value. - **************************************************************************/ - { retryWhenTransactionTimeout: 5, - steps: [ - { func: initElements, delay: 0, forVertical: true, - description: "initElements" }, - { func: clearWheelTransaction, delay: 0, - description: "clearWheelTransaction" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - delta: 5000, - description: "Very large delta scrolling (v-1)" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: true, expectedView: gSubView1, - delta: 5000, - description: "Very large delta scrolling (v-2)" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: false, expectedView: gSubView1, - delta: 5000, - description: "Very large delta scrolling (h-1)" }, - { func: testOneTimeScroll, delay: 0, offset: kPtInSubView1ForV, - isForward: true, isVertical: false, expectedView: gSubView1, - delta: 5000, - description: "Very large delta scrolling (h-2)" } - ] - } - ]; -} - -/****************************************************************************** - * Actions for preparing tests - ******************************************************************************/ - -function initElements() -{ - _clearTimer(); - - function resetScrollPosition(aElement) - { - aElement.scrollTop = 0; - aElement.scrollLeft = 0; - } - - function initInRootView(aElement, aPt) - { - aElement.offset = - gCurrentTest.forVertical ? aPt : { x: aPt.y, y: aPt.x }; - } - - const kDisplay = gCurrentTest.forVertical ? "block" : "inline-block"; - gSubView1.style.display = kDisplay; - gSubView2.style.display = kDisplay; - gSubView3.style.display = kDisplay; - - resetScrollPosition(gRootView); - resetScrollPosition(gSubView1); - resetScrollPosition(gSubView2); - resetScrollPosition(gSubView3); - _getDOMWindowUtils(window).advanceTimeAndRefresh(0); - - runNextTestStep(); -} - -function clearWheelTransaction() -{ - _clearTimer(); - _clearTransaction(); - runNextTestStep(); -} - -function sendKeyEvents() -{ - _clearTimer(); - synthesizeKey(gCurrentTest.key, {}, window); - runNextTestStep(); -} - -function sendMouseButtonEvents() -{ - _clearTimer(); - synthesizeMouse(gRootView, -1, -1, { type:"mousedown" }, window); - synthesizeMouse(gRootView, -1, -1, { type:"mouseup" }, window); - runNextTestStep(); -} - -function sendMouseMoveEvent() -{ - _clearTimer(); - _fireMouseMoveEvent(gCurrentTest.offset); - runNextTestStep(); -} - -/****************************************************************************** - * Utilities for testing functions - ******************************************************************************/ - -function _clearTransaction() -{ - synthesizeMouse(gRootView, -1, -1, { type:"mousedown" }, window); - synthesizeMouse(gRootView, -1, -1, { type:"mouseup" }, window); -} - -function _saveScrollPositions() -{ - function save(aElement) - { - aElement.prevTop = aElement.scrollTop; - aElement.prevLeft = aElement.scrollLeft; - } - save(gRootView); - save(gSubView1); - save(gSubView2); - save(gSubView3); -} - -function _fireMouseMoveEvent(aOffset) -{ - synthesizeMouse(gRootView, aOffset.x, aOffset.y, { type:"mousemove" }, window); -} - -function _fireWheelScrollEvent(aOffset, aIsVertical, aForward, aDelta) -{ - var event = { deltaMode: WheelEvent.DOM_DELTA_LINE }; - if (aIsVertical) { - event.deltaY = aForward ? aDelta : -aDelta; - } else { - event.deltaX = aForward ? aDelta : -aDelta; - } - sendWheelAndPaint(gRootView, aOffset.x, aOffset.y, event, null, window); -} - -function _canScroll(aElement, aIsVertical, aForward) -{ - if (aIsVertical) { - if (!aForward) - return aElement.scrollTop > 0; - return aElement.scrollHeight > aElement.scrollTop + aElement.clientHeight; - } - if (!aForward) - return aElement.scrollLeft > 0; - return aElement.scrollWidth > aElement.scrollLeft + aElement.clientWidth; -} - -const kNotScrolled = 0; -const kScrolledToTop = 1; -const kScrolledToBottom = 2; -const kScrolledToLeft = 4; -const kScrolledToRight = 8; - -const kScrolledVertical = kScrolledToTop | kScrolledToBottom; -const kScrolledHorizontal = kScrolledToLeft | kScrolledToRight; - -function _getScrolledState(aElement) -{ - var ret = kNotScrolled; - if (aElement.scrollTop != aElement.prevTop) { - ret |= aElement.scrollTop < aElement.prevTop ? kScrolledToTop : - kScrolledToBottom; - } - if (aElement.scrollLeft != aElement.prevLeft) { - ret |= aElement.scrollLeft < aElement.prevLeft ? kScrolledToLeft : - kScrolledToRight; - } - return ret; -} - -function _getExpectedScrolledState() -{ - return gCurrentTest.isVertical ? - gCurrentTest.isForward ? kScrolledToBottom : kScrolledToTop : - gCurrentTest.isForward ? kScrolledToRight : kScrolledToLeft; -} - -function _getScrolledStateText(aScrolledState) -{ - if (aScrolledState == kNotScrolled) - return "Not scrolled"; - - var s = "scrolled to "; - if (aScrolledState & kScrolledVertical) { - s += aScrolledState & kScrolledToTop ? "backward" : "forward"; - s += " (vertical)" - if (aScrolledState & kScrolledHorizontal) - s += " and to "; - } - if (aScrolledState & kScrolledHorizontal) { - s += aScrolledState & kScrolledToLeft ? "backward" : "forward"; - s += " (horizontal)" - } - return s; -} - -function _getCurrentTestList() -{ - return gTestLists[gCurrentTestListStatus.nextListIndex - 1]; -} - -function _clearTimer() -{ - clearTimeout(gTimer); - gTimer = 0; -} - -/****************************************************************************** - * Testing functions - ******************************************************************************/ - -/** - * Note that testing functions must set following variables: - * - * gCurrentTest.repeatTest: See comment in |continueTest|. - * gCurrentTest.autoRepeatDelay: See comment in |continueTest|. - * gListenScrollEvent: When this is not true, the event handlers ignores the - * events. - */ - -function testContinuousScroll() -{ - /** - * Testing continuous scrolling. This function synthesizes a wheel event. If - * the test was success, this function will be recalled automatically. - * And when a generating wheel event cannot scroll the expected view, this - * function fires the wheel event only one time. - * - * @param gCurrentTest.offset - * The cursor position of firing wheel event. The values are offset - * from |gRootView|. - * @param gCurrentTest.isVertical - * Whether the wheel event is for virtical scrolling or horizontal. - * @param gCurrentTest.isForward - * Whether the wheel event is to forward or to backward. - * @param gCurrentTest.expectedView - * The expected view which will be scrolled by wheel event. This - * value must not be null. - */ - - _clearTimer(); - _saveScrollPositions(); - if (!gCurrentTest.expectedView) { - runNextTestStep(); - return; - } - - gLitesnEvents = kListenEvent_All; - gCurrentTest.repeatTest = true; - gCurrentTest.autoRepeatDelay = 0; - - if (!_canScroll(gCurrentTest.expectedView, - gCurrentTest.isVertical, gCurrentTest.isForward)) { - gCurrentTest.expectedView = null; - } - var delta = gCurrentTest.delta ? gCurrentTest.delta : 4; - _fireWheelScrollEvent(gCurrentTest.offset, - gCurrentTest.isVertical, gCurrentTest.isForward, delta); -} - -function testOneTimeScroll() -{ - /** - * Testing one wheel event. |runNextTestStep| will be called immediately - * after this function by |onScrollView| or |onTimeout|. - * - * @param gCurrentTest.offset - * The cursor position of firing wheel event. The values are offset - * from |gRootView|. - * @param gCurrentTest.isVertical - * Whether the wheel event is for virtical scrolling or horizontal. - * @param gCurrentTest.isForward - * Whether the wheel event is to forward or to backward. - * @param gCurrentTest.expectedView - * The expected view which will be scrolled by wheel event. This - * value can be null. It means any views should not be scrolled. - */ - - _clearTimer(); - _saveScrollPositions(); - - gLitesnEvents = kListenEvent_All; - gCurrentTest.repeatTest = false; - gCurrentTest.autoRepeatDelay = 0; - - var delta = gCurrentTest.delta ? gCurrentTest.delta : 4; - _fireWheelScrollEvent(gCurrentTest.offset, - gCurrentTest.isVertical, gCurrentTest.isForward, delta); -} - -function testRestartScroll() -{ - /** - * Testing restart to scroll in expected view after timeout from the current - * transaction. This function recall this itself until to success this test - * or timeout from this test. - * - * @param gCurrentTest.offset - * The cursor position of firing wheel event. The values are offset - * from |gRootView|. - * @param gCurrentTest.isVertical - * Whether the wheel event is for virtical scrolling or horizontal. - * @param gCurrentTest.isForward - * Whether the wheel event is to forward or to backward. - * @param gCurrentTest.expectedView - * The expected view which will be scrolled by wheel event. This - * value must not be null. - */ - - _clearTimer(); - _saveScrollPositions(); - - if (!gCurrentTest.wasTransactionTimeout) { - gCurrentTest.repeatTest = true; - gCurrentTest.autoRepeatDelay = gTimeout / 3; - gLitesnEvents = kListenEvent_All; - gCurrentTest.isTimeoutTesting = true; - if (gCurrentTest.expectedView) { - gCurrentTest.expectedViewAfterTimeout = gCurrentTest.expectedView; - gCurrentTest.expectedView = null; - } - } else { - gCurrentTest.repeatTest = false; - gCurrentTest.autoRepeatDelay = 0; - gLitesnEvents = kListenEvent_All; - gCurrentTest.isTimeoutTesting = false; - gCurrentTest.expectedView = gCurrentTest.expectedViewAfterTimeout; - } - - var delta = gCurrentTest.delta ? gCurrentTest.delta : 4; - _fireWheelScrollEvent(gCurrentTest.offset, - gCurrentTest.isVertical, gCurrentTest.isForward, delta); -} - -/****************************************************************************** - * Event handlers - ******************************************************************************/ - -function onScrollView(aEvent) -{ - /** - * Scroll event handler of |gRootView|, |gSubView1|, |gSubView2| and - * |gSubView3|. If testing is failed, this function cancels all left tests. - * For checking the event is expected, the event firer must call - * |_saveScrollPositions|. - * - * @param gCurrentTest.expectedView - * The expected view which should be scrolled by the wheel event. - * This value can be null. It means any views should not be - * scrolled. - * @param gCurrentTest.isVertical - * The expected view should be scrolled vertical or horizontal. - * @param gCurrentTest.isForward - * The expected view should be scrolled to forward or backward. - * @param gCurrentTest.canFailRandomly - * If this is not undefined, this test can fail by unexpected view - * scrolling which is caused by unexpected timeout. If this is - * defined, |gCurrentTest.possibleView| must be set. If the view is - * same as the event target, the failure can be random. At this - * time, we should retry the current test list. - */ - - if (!(gLitesnEvents & kListenEvent_OnScroll)) - return; - - // Now testing a timeout, but a view is scrolled before timeout. - if (gCurrentTest.isTimeoutTesting && !gCurrentTest.wasTransactionTimeout) { - is(aEvent.target.id, "", - "The view scrolled before timeout (the expected view after timeout is " + - gCurrentTest.expectedView ? gCurrentTest.expectedView.id : "null" + - "): " + gCurrentTest.description); - runNextTestList(); - return; - } - - // Check whether the scrolled event should be fired or not. - if (!gCurrentTest.expectedView) { - is(aEvent.target.id, "", - "no views should be scrolled (" + - _getScrolledStateText(_getScrolledState(aEvent.target)) + "): " + - gCurrentTest.description); - runNextTestList(); - return; - } - - // Check whether the scrolled view is expected or not. - if (aEvent.target != gCurrentTest.expectedView) { - // If current test can fail randomly and the possible view is same as the - // event target, this failure may be caused by unexpected timeout. - // At this time, we should retry the current tests with slower settings. - if (gCurrentTest.canFailRandomly && - gCurrentTest.canFailRandomly.possibleView == aEvent.target && - gCurrentTestListStatus.retryWhenTransactionTimeout > 0) { - gCurrentTestListStatus.retryWhenTransactionTimeout--; - retryCurrentTestList(); - return; - } - is(aEvent.target.id, gCurrentTest.expectedView.id, - "wrong view was scrolled: " + gCurrentTest.description); - runNextTestList(); - return; - } - - // Check whether the scrolling direction is expected or not. - var expectedState = _getExpectedScrolledState(); - var currentState = _getScrolledState(aEvent.target); - if (expectedState != currentState) { - is(_getScrolledStateText(currentState), - _getScrolledStateText(expectedState), - "scrolled to wrong direction: " + gCurrentTest.description); - runNextTestList(); - return; - } - - ok(true, "passed: " + gCurrentTest.description); - continueTest(); -} - -function onMouseScrollFailed() -{ - /** - * Scroll failed event handler. If testing is failed, this function cancels - * all remains of current test-list, and go to next test-list. - * - * NOTE: This event is fired immediately after |_fireWheelScrollEvent|. - * - * @param gCurrentTest.expectedView - * The expected view which should be scrolled by the wheel event. - * This value can be null. It means any views should not be - * scrolled. When this is not null, this event means the test may - * be failed. - */ - - if (!(gLitesnEvents & kListenEvent_OnScrollFailed)) - return; - - ok(!gCurrentTest.expectedView, - "failed to scroll on current target: " + gCurrentTest.description); - if (gCurrentTest.expectedView) { - runNextTestList(); - return; - } - - continueTest(); -} - -function onTransactionTimeout() -{ - /** - * Scroll transaction timeout event handler. If the timeout is unexpected, - * i.e., |gCurrentTest.isTimeoutTesting| is not true, this function retry - * the current test-list. However, if the current test-list failed by timeout - * |gCurrentTestListStatus.retryWhenTransactionTimeout| times already, marking - * to failed the current test-list, and go to next test-list. - * - * @param gCurrentTest.expectedView - * The expected view which should be scrolled by the wheel event. - * This value can be null. It means any views should not be - * scrolled. When this is not null, this event means the testing may - * be failed. - * @param gCurrentTest.isTimeoutTesting - * If this value is true, the current testing have waited this - * event. Otherwise, the testing may be failed. - * @param gCurrentTestListStatus.retryWhenTransactionTimeout - * If |gCurrentTest.isTimeoutTesting| is not true but this event is - * fired, the failure may be randomly. Then, this event handler - * retry to test the current test-list until this cound will be zero. - */ - - if (!gCurrentTest.isTimeoutTesting && - gCurrentTestListStatus.retryWhenTransactionTimeout > 0) { - gCurrentTestListStatus.retryWhenTransactionTimeout--; - // retry current test list - retryCurrentTestList(); - return; - } - - gCurrentTest.wasTransactionTimeout = true; - - if (!(gLitesnEvents & kListenEvent_OnTransactionTimeout)) - return; - - ok(gCurrentTest.isTimeoutTesting, - "transaction timeout: " + gCurrentTest.description); - if (!gCurrentTest.isTimeoutTesting) { - runNextTestList(); - return; - } - - continueTest(); -} - -/****************************************************************************** - * Main function for this tests - ******************************************************************************/ - -function runNextTestStep() -{ - // When this is first time or the current test list is finised, load next - // test-list. - _clearTimer(); - if (!gCurrentTest) - runNextTestList(); - else - runTestStepAt(gCurrentTestListStatus.nextStepIndex); -} - -function runNextTestList() -{ - _clearTimer(); - - gLitesnEvents = kListenEvent_None; - _clearTransaction(); - resetTimeoutPrefs(); - if (gCurrentTestListStatus.nextListIndex >= gTestLists.length) { - finish(); - return; - } - - gCurrentTestListStatus.nextListIndex++; - gCurrentTestListStatus.retryWhenTransactionTimeout = - _getCurrentTestList().retryWhenTransactionTimeout; - runTestStepAt(0); -} - -function runTestStepAt(aStepIndex) -{ - _clearTimer(); - - disableNonTestMouseEvents(true); - - // load a step of testing. - gCurrentTestListStatus.nextStepIndex = aStepIndex; - gCurrentTest = - _getCurrentTestList().steps[gCurrentTestListStatus.nextStepIndex++]; - if (gCurrentTest) { - gCurrentTest.wasTransactionTimeout = false; - gTimer = setTimeout(gCurrentTest.func, gCurrentTest.delay); - } else { - // If current test-list doesn't have more testing, go to next test-list - // after cleaning up the current transaction. - _clearTransaction(); - runNextTestList(); - } -} - -function retryCurrentTestList() -{ - _clearTimer(); - - gLitesnEvents = kListenEvent_None; - _clearTransaction(); - ok(true, "WARNING: retry current test-list..."); - growUpTimeoutPrefs(); // retry the test with longer timeout settings. - runTestStepAt(0); -} - -function continueTest() -{ - /** - * This function is called from an event handler when a test succeeded. - * - * @param gCurrentTest.repeatTest - * When this is true, onScrollView calls |gCurrentTest.func|. So, - * same test can repeat. Otherwise, this calls |runNextTestStep|. - * @param gCurrentTest.autoRepeatDelay - * The delay value in milliseconds, this is used to call - * |gCurrentTest.func| via |setTimeout|. - */ - - _clearTimer(); - gLitesnEvents = kListenEvent_OnTransactionTimeout; - - // We should call each functions via setTimeout. Because sometimes this test - // is broken by stack overflow. - if (gCurrentTest.repeatTest) { - gTimer = setTimeout(gCurrentTest.func, gCurrentTest.autoRepeatDelay); - } else { - gTimer = setTimeout(runNextTestStep, 0); - } -} - -]]> -</script> - -</window> |