зеркало из https://github.com/mozilla/gecko-dev.git
Backout of 2f4307a63c18 - Bug 759989.
This commit is contained in:
Родитель
3781be717a
Коммит
155a08f022
|
@ -85,7 +85,6 @@ _TEST_FILES = \
|
|||
test_bug741666.html \
|
||||
test_dom_keyboard_event.html \
|
||||
test_dom_mouse_event.html \
|
||||
test_bug742376.html \
|
||||
$(NULL)
|
||||
|
||||
#bug 585630
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=402089
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 742376</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=742376">Mozilla Bug 742376</a>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 742376 **/
|
||||
|
||||
function getListenerCount() {
|
||||
|
||||
var Cc = SpecialPowers.wrap(Components).classes;
|
||||
var Ci = SpecialPowers.wrap(Components).interfaces;
|
||||
var dss = Cc["@mozilla.org/devicesensors;1"].getService(Ci.nsIDeviceSensors);
|
||||
|
||||
return dss.listenerCount(Ci.nsIDeviceSensorData.TYPE_ORIENTATION);
|
||||
}
|
||||
|
||||
function dumbListener(event) {}
|
||||
function dumbListener2(event) {}
|
||||
|
||||
window.addEventListener("deviceorientation", dumbListener, false);
|
||||
window.addEventListener("deviceorientation", dumbListener2, false);
|
||||
|
||||
window.setTimeout(function() {
|
||||
|
||||
ok (getListenerCount() >= 1, "Must have at least one listeners at this point");
|
||||
|
||||
window.removeEventListener("deviceorientation", dumbListener, false);
|
||||
window.setTimeout(function() {
|
||||
|
||||
is (getListenerCount(), 1, "Must have one listeners at this point");
|
||||
|
||||
window.removeEventListener("deviceorientation", dumbListener2, false);
|
||||
|
||||
window.setTimeout(function() {
|
||||
is (getListenerCount(), 0, "Must have zero listeners at this point");
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
}, 0);
|
||||
}, 0);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -10040,44 +10040,35 @@ nsGlobalWindow::EnableDeviceSensor(PRUint32 aType)
|
|||
}
|
||||
}
|
||||
|
||||
if (alreadyEnabled)
|
||||
return;
|
||||
|
||||
mEnabledSensors.AppendElement(aType);
|
||||
|
||||
if (alreadyEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
|
||||
if (ac) {
|
||||
if (ac)
|
||||
ac->AddWindowListener(aType, this);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::DisableDeviceSensor(PRUint32 aType)
|
||||
{
|
||||
PRInt32 doomedElement = -1;
|
||||
PRInt32 listenerCount = 0;
|
||||
for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
|
||||
if (mEnabledSensors[i] == aType) {
|
||||
doomedElement = i;
|
||||
listenerCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (doomedElement == -1) {
|
||||
if (doomedElement == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
mEnabledSensors.RemoveElementAt(doomedElement);
|
||||
|
||||
if (listenerCount > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
|
||||
if (ac) {
|
||||
if (ac)
|
||||
ac->RemoveWindowListener(aType, this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -118,17 +118,6 @@ nsDeviceSensors::~nsDeviceSensors()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceSensors::ListenerCount(PRUint32 aType, PRInt32 *aRetVal)
|
||||
{
|
||||
if (!mEnabled) {
|
||||
*aRetVal = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aRetVal = mWindowListeners[aType]->Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceSensors::AddWindowListener(PRUint32 aType, nsIDOMWindow *aWindow)
|
||||
{
|
||||
if (!mEnabled)
|
||||
|
|
|
@ -24,14 +24,11 @@ interface nsIDeviceSensorData : nsISupports
|
|||
readonly attribute double z;
|
||||
};
|
||||
|
||||
[scriptable, uuid(83306c9f-1c8f-43c4-900a-245d7f219511)]
|
||||
[scriptable, uuid(b672bfe0-4479-4094-a9ef-1b6847720d07)]
|
||||
interface nsIDeviceSensors : nsISupports
|
||||
{
|
||||
long listenerCount(in unsigned long aType);
|
||||
|
||||
// Holds pointers, not AddRef objects -- it is up to the caller
|
||||
// to call RemoveWindowListener before the window is deleted.
|
||||
|
||||
[noscript] void addWindowListener(in unsigned long aType, in nsIDOMWindow aWindow);
|
||||
[noscript] void removeWindowListener(in unsigned long aType, in nsIDOMWindow aWindow);
|
||||
[noscript] void removeWindowAsListener(in nsIDOMWindow aWindow);
|
||||
|
|
Загрузка…
Ссылка в новой задаче