Remove tests from widget.
This commit is contained in:
parent
2711cada39
commit
5dd9405261
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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>
|
|
@ -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
|
||||
|
|
@ -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>
|
|
@ -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"/>
|
|
@ -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
|
|
@ -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']
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
|
@ -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>
|
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
[DEFAULT]
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_taskbar_jumplistitems.js]
|
||||
[test_macwebapputils.js]
|
||||
skip-if = os != "mac"
|
|
@ -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;
|
||||
});
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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"/>
|
|
@ -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>
|
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Picker window</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="form1">
|
||||
<input type="file" name="uploadbox">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue