mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 35178de36bd3 (bug 855704) for frequent mochitest failures.
This commit is contained in:
parent
732c5f013c
commit
6e36f8f54b
@ -17,6 +17,8 @@ var errorCodes = {
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
SpecialPowers.setBoolPref("media.webspeech.recognition.enable", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.enable", true);
|
||||
|
||||
function EventManager(sr) {
|
||||
var self = this;
|
||||
@ -121,6 +123,11 @@ function EventManager(sr) {
|
||||
}
|
||||
}
|
||||
|
||||
function resetPrefs() {
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", false);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", false);
|
||||
}
|
||||
|
||||
function buildResultCallback(transcript) {
|
||||
return (function(evt) {
|
||||
is(evt.results[0][0].transcript, transcript, "expect correct transcript");
|
||||
@ -133,35 +140,28 @@ function buildErrorCallback(errcode) {
|
||||
});
|
||||
}
|
||||
|
||||
function performTest(options) {
|
||||
var prefs = options.prefs;
|
||||
function performTest(eventsToRequest, expectedEvents, doneFunc, audioSampleFile) {
|
||||
var sr = new SpeechRecognition();
|
||||
var em = new EventManager(sr);
|
||||
|
||||
prefs.unshift(
|
||||
["media.webspeech.recognition.enable", true],
|
||||
["media.webspeech.test.enable", true]
|
||||
);
|
||||
for (var eventName in expectedEvents) {
|
||||
var cb = expectedEvents[eventName];
|
||||
em.expect(eventName, cb);
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({set: prefs}, function() {
|
||||
var sr = new SpeechRecognition();
|
||||
var em = new EventManager(sr);
|
||||
em.done = function() {
|
||||
em.requestTestEnd();
|
||||
resetPrefs();
|
||||
doneFunc();
|
||||
}
|
||||
|
||||
for (var eventName in options.expectedEvents) {
|
||||
var cb = options.expectedEvents[eventName];
|
||||
em.expect(eventName, cb);
|
||||
}
|
||||
if (!audioSampleFile) {
|
||||
audioSampleFile = DEFAULT_AUDIO_SAMPLE_FILE;
|
||||
}
|
||||
|
||||
em.done = function() {
|
||||
em.requestTestEnd();
|
||||
options.doneFunc();
|
||||
}
|
||||
em.audioSampleFile = audioSampleFile;
|
||||
|
||||
em.audioSampleFile = DEFAULT_AUDIO_SAMPLE_FILE;
|
||||
if (options.audioSampleFile) {
|
||||
em.audioSampleFile = options.audioSampleFile;
|
||||
}
|
||||
|
||||
for (var i = 0; i < options.eventsToRequest.length; i++) {
|
||||
em.requestFSMEvent(options.eventsToRequest[i]);
|
||||
}
|
||||
});
|
||||
for (var i = 0; i < eventsToRequest.length; i++) {
|
||||
em.requestFSMEvent(eventsToRequest[i]);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
];
|
||||
|
||||
function doNextTest() {
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
|
||||
|
||||
var nextEvent = eventsToAbortOn[nextEventIdx];
|
||||
var expectedEvents = {
|
||||
"start": null,
|
||||
@ -56,12 +59,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
|
||||
nextEventIdx++;
|
||||
|
||||
performTest({
|
||||
eventsToRequest: ["EVENT_START", "EVENT_AUDIO_DATA"],
|
||||
expectedEvents: expectedEvents,
|
||||
doneFunc: (nextEventIdx < eventsToAbortOn.length) ? doNextTest : SimpleTest.finish,
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
|
||||
});
|
||||
performTest([
|
||||
"EVENT_START",
|
||||
"EVENT_AUDIO_DATA"
|
||||
],
|
||||
expectedEvents,
|
||||
(nextEventIdx < eventsToAbortOn.length) ? doNextTest : SimpleTest.finish);
|
||||
}
|
||||
|
||||
doNextTest();
|
||||
|
@ -20,15 +20,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
performTest({
|
||||
eventsToRequest: ['EVENT_START', 'EVENT_AUDIO_ERROR'],
|
||||
expectedEvents: {
|
||||
'error': buildErrorCallback(errorCodes.AUDIO_CAPTURE),
|
||||
'end': null
|
||||
},
|
||||
doneFunc: SimpleTest.finish,
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true]]
|
||||
});
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
|
||||
performTest([
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_ERROR'
|
||||
], {
|
||||
'error': buildErrorCallback(errorCodes.AUDIO_CAPTURE),
|
||||
'end': null
|
||||
}, SimpleTest.finish);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,6 +20,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
|
||||
|
||||
function endHandler(evt, sr) {
|
||||
try {
|
||||
sr.start(); // shouldn't fail
|
||||
@ -30,24 +33,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
info("Successfully start() from end() callback");
|
||||
}
|
||||
|
||||
performTest({
|
||||
eventsToRequest: [
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
|
||||
],
|
||||
expectedEvents: {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'result': buildResultCallback("Mock final result"),
|
||||
'end': endHandler,
|
||||
},
|
||||
doneFunc: SimpleTest.finish,
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
|
||||
});
|
||||
performTest([
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
|
||||
], {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'result': buildResultCallback("Mock final result"),
|
||||
'end': endHandler,
|
||||
}, SimpleTest.finish);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -17,22 +17,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="text/javascript">
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [["media.webspeech.recognition.enable", false]]
|
||||
}, function() {
|
||||
var objects = [
|
||||
"SpeechRecognition",
|
||||
"SpeechGrammar",
|
||||
"SpeechRecognitionResult",
|
||||
"SpeechRecognitionResultList",
|
||||
"SpeechRecognitionAlternative"
|
||||
];
|
||||
SpecialPowers.setBoolPref("media.webspeech.recognition.enable", false);
|
||||
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
is(window[objects[i]], undefined,
|
||||
objects[i] + " should be undefined with pref off");
|
||||
}
|
||||
});
|
||||
var objects = [
|
||||
"SpeechRecognition",
|
||||
"SpeechGrammar",
|
||||
"SpeechRecognitionResult",
|
||||
"SpeechRecognitionResultList",
|
||||
"SpeechRecognitionAlternative"
|
||||
];
|
||||
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
is(window[objects[i]], undefined,
|
||||
objects[i] + " should be undefined with pref off");
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,24 +20,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
performTest({
|
||||
eventsToRequest: [
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_ERROR'
|
||||
],
|
||||
expectedEvents: {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'error': buildErrorCallback(errorCodes.NETWORK),
|
||||
'end': null
|
||||
},
|
||||
doneFunc: SimpleTest.finish,
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
|
||||
});
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
|
||||
|
||||
performTest([
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_ERROR'
|
||||
], {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'error': buildErrorCallback(errorCodes.NETWORK),
|
||||
'end': null
|
||||
}, SimpleTest.finish);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,24 +20,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
performTest({
|
||||
eventsToRequest: [
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
|
||||
],
|
||||
expectedEvents: {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'result': buildResultCallback("Mock final result"),
|
||||
'end': null
|
||||
},
|
||||
doneFunc:SimpleTest.finish,
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
|
||||
});
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
|
||||
|
||||
performTest([
|
||||
'EVENT_START',
|
||||
'EVENT_AUDIO_DATA',
|
||||
'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
|
||||
], {
|
||||
'start': null,
|
||||
'audiostart': null,
|
||||
'speechstart': null,
|
||||
'speechend': null,
|
||||
'audioend': null,
|
||||
'result': buildResultCallback("Mock final result"),
|
||||
'end': null
|
||||
}, SimpleTest.finish);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,22 +20,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
performTest({
|
||||
eventsToRequest: [
|
||||
"EVENT_START",
|
||||
"EVENT_AUDIO_DATA"
|
||||
],
|
||||
expectedEvents: {
|
||||
"start": null,
|
||||
"audiostart": null,
|
||||
"audioend": null,
|
||||
"error": buildErrorCallback(errorCodes.NO_SPEECH),
|
||||
"end": null
|
||||
},
|
||||
doneFunc: SimpleTest.finish,
|
||||
audioSampleFile: "silence.ogg",
|
||||
prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
|
||||
});
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
|
||||
SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
|
||||
|
||||
performTest([
|
||||
"EVENT_START",
|
||||
"EVENT_AUDIO_DATA"
|
||||
], {
|
||||
"start": null,
|
||||
"audiostart": null,
|
||||
"audioend": null,
|
||||
"error": buildErrorCallback(errorCodes.NO_SPEECH),
|
||||
"end": null
|
||||
}, SimpleTest.finish, "silence.ogg");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
Loading…
Reference in New Issue
Block a user