Files
palemoon27/dom/requestsync/tests/common_basic.js
T
roytam1 1311ec4a42 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1162692 - Add SpeechSynthesisUtterance.chosenVoiceURI for testing purposes. r=smaug (aa30ec93c)
- Bug 1160844 - Only initialize pico tts when not in mochitest and speech synth is enabled. r=smaug (5d00c71e4)
- Bug 1167539 - Replace use of NS_ENSURE_* with NS_WARN_IF in dom//webspeech/synth/*. r=smaugmedia (10cb826f8)
- Bug 903135 - Multi platform MAR verification build config. r=rstrong (8022418a3)
- Bug 1144512 - Add b2g build support for API level 22. r=mwu (a1f9bf473)
- Bug 1115480 - Part 1: Implement XPCOM module for mDNSProvider. r=mcmanus (9e2b49f1a)
- Bug 1115480 - Part 2: Implement mDNS device provider. r=schien (22ca5283f)
- Bug 1115480 - Re-add metadata to the dom/presentation xpcshell.ini that shouldn't have been removed. (e6a5b401e)
- Bug 1058551 - Support redirects to data: URIs. r=honza (2ff31ce33)
- fix build (b48590cd0)
- Bug 1163859: Only update webrtc.debug prefs from gecko thread. r=rjesup (ac0f18cb1)
- Bug 1145354: Add SingletonThreadHolder for media/mtransport, and use it for mtransport IPC IO r=bwc (1106b13b5)
- Bug 1117586, [e10s] select dropdowns cannot be opened with the keyboard, r=roc (bbf8b8842)
- Bug 1152290 - "[e10s] "<select>" doesn't show selected value". r=roc (2a130ec4f)
- Bug 1147967 - Remove CreateStackFrameLocation. r=bholley (9ea0b73e0)
- Bug 958641 - De-holder nsIXPConnect::WrapNative. r=gabor (c5fe0ee54)
- Bug 1142999 - Remove gcc warning about unused typedef. r=ehoogeveen (e0103e01a)
- Bug 1145015 - Part 1: Remove IsValidKey() check in MagicGrallocBufferHandle serializer. r=sotaro, r=nical (bb470de06)
- Bug 1145015 - Part 2: Add more checking rules for GrallocBuffer allocation. r=sotaro, r=nical (05398af8d)
- Bug 1130096 - Convert embedding/components/windowwatcher/ to Gecko style. r=mccr8 (554041661)
- Bug 1164977 - Prevent MediaStreamAudioSourceNode from passing null to nsIPrincipal::subsumes. r=padenot (5f95a8ab9)
- Bug 1164292 followup: Add 'override' annotations to BasePrincipal & nsSystemPrincipal GetCsp()/SetCsp() methods. rs=ehsan (76e5d2013)
- Bug 1164977 - Hoist all the app attribute handling into BasePrincipal. r=gabor (e99bb5617)
- Bug 1172483 - Remove erroneous assert. (r=Waldo) (70ce92c09)
- Bug 1164977 - Unify subsumes/equals logic on BasePrincipal and reduce duplicated code. r=gabor (4dbf31b45)
- Bug 1140472 - Set an async stack when invoking promise handlers. r=bz (f12a5c9f6)
- Bug 1164977 - Hoist app attributes into a struct on BasePrincipal and refer to them as 'origin attributes'. r=gabor (85eb810f2)
- Bug 1164977 - Hoist attribute serialization into BasePrincipal. r=gabor (ff51a67d1)
- Bug 1158133 - Add a way to disable async stacks, and disable by default on mobile platforms. r=bent,jimb (c4954752e)
- Bug 1171177 - Remove VAROBJFIX. (r=luke) (5707455e6)
- Bug 1165162 - Make requestsync test failures more useful. rpending=baku (5c0a79f07)
- Bug 1139254 - Use MockRegistrar in services. r=gps (da61a6fad)
- Bug 1165162 - Fix up test_manager.js to use real principals. rpending=ferjm (797ffb5ce)
- Bug 1165162 - Stop recreating principals from the message manager. r=smaug (5f5241a6e)
- pointer style (c0da0f1a9)
- fix some misspatch (e209af9a6)
- Bug 1165486 - Replace the PlainObj varobj with NonSyntacticVariablesObject. (r=luke) (2179cf860)
- Bug 1171177 - Remove UNQUALIFIED_VAROBJ Shape flags in favor of Class-checking. (r=luke) (93391d13f)
- Bug 1165162 - Make OriginAttributes a dictionary, and make it accessible as both a jsval and a canonical string. r=gabor,r=bholley,sr=sicking (0731b0caf)
2021-02-12 11:37:41 +08:00

189 lines
7.6 KiB
JavaScript

function test_registerFailure() {
ok("sync" in navigator, "navigator.sync exists");
navigator.sync.register().then(
function() {
ok(false, "navigator.sync.register() throws without a task name");
}, function() {
ok(true, "navigator.sync.register() throws without a task name");
})
.then(function() {
return navigator.sync.register(42);
}).then(function() {
ok(false, "navigator.sync.register() throws without a string task name");
}, function() {
ok(true, "navigator.sync.register() throws without a string task name");
})
.then(function() {
return navigator.sync.register('foobar');
}).then(function() {
ok(false, "navigator.sync.register() throws without a param dictionary");
}, function() {
ok(true, "navigator.sync.register() throws without a param dictionary");
})
.then(function() {
return navigator.sync.register('foobar', 42);
}).then(function() {
ok(false, "navigator.sync.register() throws without a real dictionary");
}, function() {
ok(true, "navigator.sync.register() throws without a real dictionary");
})
.then(function() {
return navigator.sync.register('foobar', {});
}).then(function() {
ok(false, "navigator.sync.register() throws without a minInterval and wakeUpPage");
}, function() {
ok(true, "navigator.sync.register() throws without a minInterval and wakeUpPage");
})
.then(function() {
return navigator.sync.register('foobar', { minInterval: 100 });
}).then(function() {
ok(false, "navigator.sync.register() throws without a wakeUpPage");
}, function() {
ok(true, "navigator.sync.register() throws without a wakeUpPage");
})
.then(function() {
return navigator.sync.register('foobar', { wakeUpPage: 100 });
}).then(function() {
ok(false, "navigator.sync.register() throws without a minInterval");
}, function() {
ok(true, "navigator.sync.register() throws without a minInterval");
})
.then(function() {
runTests();
});
}
function genericError(name, val) {
ok(false, "Promise from " + name + " rejected with value: " + val);
}
function test_register() {
navigator.sync.register('foobar', { minInterval: 5, wakeUpPage:'/' }).then(
function() {
ok(true, "navigator.sync.register() worked!");
runTests();
}, genericError.bind(null, 'register'));
}
function test_unregister() {
navigator.sync.unregister('foobar').then(
function() {
ok(true, "navigator.sync.unregister() worked!");
runTests();
}, genericError.bind(null, 'unregister'));
}
function test_unregisterDuplicate() {
navigator.sync.unregister('foobar').then(
genericError.bind(null, 'unregisterDuplicate'),
function(error) {
ok(true, "navigator.sync.unregister() should throw if the task doesn't exist.");
ok(error, "UnknownTaskError", "Duplicate unregistration error is correct");
runTests();
});
}
function test_registrationEmpty() {
navigator.sync.registration('bar').then(
function(results) {
is(results, null, "navigator.sync.registration() should return null.");
runTests();
},
genericError.bind(null, 'registrationEmpty'));
}
function test_registration() {
navigator.sync.registration('foobar').then(
function(results) {
is(results.task, 'foobar', "navigator.sync.registration().task is correct");
ok("lastSync" in results, "navigator.sync.registration().lastSync is correct");
is(results.oneShot, true, "navigator.sync.registration().oneShot is correct");
is(results.minInterval, 5, "navigator.sync.registration().minInterval is correct");
ok("wakeUpPage" in results, "navigator.sync.registration().wakeUpPage is correct");
ok("wifiOnly" in results, "navigator.sync.registration().wifiOnly is correct");
ok("data" in results, "navigator.sync.registration().data is correct");
ok(!("app" in results), "navigator.sync.registrations().app is correct");
runTests();
},
genericError.bind(null, 'registration'));
}
function test_registrationsEmpty() {
navigator.sync.registrations().then(
function(results) {
is(results.length, 0, "navigator.sync.registrations() should return an empty array.");
runTests();
},
genericError.bind(null, 'registrationEmpty'));
}
function test_registrations() {
navigator.sync.registrations().then(
function(results) {
is(results.length, 1, "navigator.sync.registrations() should not return an empty array.");
is(results[0].task, 'foobar', "navigator.sync.registrations()[0].task is correct");
ok("lastSync" in results[0], "navigator.sync.registrations()[0].lastSync is correct");
is(results[0].oneShot, true, "navigator.sync.registrations()[0].oneShot is correct");
is(results[0].minInterval, 5, "navigator.sync.registrations()[0].minInterval is correct");
ok("wakeUpPage" in results[0], "navigator.sync.registration()[0].wakeUpPage is correct");
ok("wifiOnly" in results[0], "navigator.sync.registrations()[0].wifiOnly is correct");
ok("data" in results[0], "navigator.sync.registrations()[0].data is correct");
ok(!("app" in results[0]), "navigator.sync.registrations()[0].app is correct");
runTests();
},
genericError.bind(null, 'registrations'));
}
function test_managerRegistrationsEmpty() {
navigator.syncManager.registrations().then(
function(results) {
is(results.length, 0, "navigator.syncManager.registrations() should return an empty array.");
runTests();
},
genericError.bind(null, 'managerRegistrationsEmpty'));
}
function test_managerRegistrations(state, overwrittenMinInterval) {
navigator.syncManager.registrations().then(
function(results) {
is(results.length, 1, "navigator.sync.registrations() should not return an empty array.");
is(results[0].task, 'foobar', "navigator.sync.registrations()[0].task is correct");
ok("lastSync" in results[0], "navigator.sync.registrations()[0].lastSync is correct");
is(results[0].oneShot, true, "navigator.sync.registrations()[0].oneShot is correct");
is(results[0].minInterval, 5, "navigator.sync.registrations()[0].minInterval is correct");
ok("wakeUpPage" in results[0], "navigator.sync.registration()[0].wakeUpPage is correct");
ok("wifiOnly" in results[0], "navigator.sync.registrations()[0].wifiOnly is correct");
ok("data" in results[0], "navigator.sync.registrations()[0].data is correct");
ok("app" in results[0], "navigator.sync.registrations()[0].app is correct");
ok("manifestURL" in results[0].app, "navigator.sync.registrations()[0].app.manifestURL is correct");
is(results[0].app.origin, 'http://mochi.test:8888', "navigator.sync.registrations()[0].app.origin is correct");
is(results[0].app.isInBrowserElement, false, "navigator.sync.registrations()[0].app.isInBrowserElement is correct");
is(results[0].state, state, "navigator.sync.registrations()[0].state is correct");
is(results[0].overwrittenMinInterval, overwrittenMinInterval, "navigator.sync.registrations()[0].overwrittenMinInterval is correct");
ok("setPolicy" in results[0], "navigator.sync.registrations()[0].setPolicy is correct");
ok("runNow" in results[0], "navigator.sync.registrations()[0].runNow is correct");
runTests();
},
genericError.bind(null, 'managerRegistrations'));
}
function test_managerSetPolicy(state, overwrittenMinInterval) {
navigator.syncManager.registrations().then(
function(results) {
results[0].setPolicy(state, overwrittenMinInterval).then(
function() {
ok(state, results[0].state, "State matches");
ok(overwrittenMinInterval, results[0].overwrittenMinInterval, "OverwrittenMinInterval matches");
runTests();
}, genericError.bind(null, 'managerSetPolicy'));
}).catch(genericError.bind(null, 'managerSetPolicy_catch'));
}