blob: 012a2885a813af6d4f64bc05bf4f0ad3a8c49a19 [file] [log] [blame]
<!DOCTYPE html>
<link rel="manifest" href="resources/manifest.json">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/third_party/WebKit/public/platform/modules/installedapp/installed_app_provider.mojom.js"></script>
<script src="resources/installedapp-test-helper.js"></script>
<script>
installedapp_test((t, mock) => {
// The expected input to the Mojo method FilterInstalledRelatedApps is the
// list of related_applications from this page's manifest. The mock service
// returns the empty list, implying that none are installed.
mock.pushExpectedCall(
[{platform: 'play', url: null, id: 'com.test'},
{platform: 'itunes', url: 'https://itunes.apple.com/', id: null}],
[]);
return navigator.getInstalledRelatedApps().then(result => {
assert_array_relatedapplication_equals(result, []);
});
}, 'getInstalledRelatedApps with related apps, none installed');
installedapp_test((t, mock) => {
// The expected input to the Mojo method FilterInstalledRelatedApps is the
// list of related_applications from this page's manifest. The mock service
// returns just the 'play' entry. Expect that result to be returned by
// getInstalledRelatedApps.
mock.pushExpectedCall(
[{platform: 'play', url: null, id: 'com.test'},
{platform: 'itunes', url: 'https://itunes.apple.com/', id: null}],
[{platform: 'play', url: null, id: 'com.test'}]);
// TODO(mgiuca): The |url| field should be omitted from the result, not ''.
return navigator.getInstalledRelatedApps().then(result => {
assert_array_relatedapplication_equals(
result, [{platform: 'play', url: '', id: 'com.test'}]);
});
}, 'getInstalledRelatedApps with related and installed apps (no url)');
installedapp_test((t, mock) => {
// The expected input to the Mojo method FilterInstalledRelatedApps is the
// list of related_applications from this page's manifest. The mock service
// returns both entries. Expect that result to be returned by
// getInstalledRelatedApps.
mock.pushExpectedCall(
[{platform: 'play', url: null, id: 'com.test'},
{platform: 'itunes', url: 'https://itunes.apple.com/', id: null}],
[{platform: 'play', url: null, id: 'com.test'},
{platform: 'itunes', url: 'https://itunes.apple.com/', id: null}]);
// TODO(mgiuca): The null fields should be omitted from the result, not ''.
return navigator.getInstalledRelatedApps().then(result => {
assert_array_relatedapplication_equals(
result,
[{platform: 'play', url: '', id: 'com.test'},
{platform: 'itunes', url: 'https://itunes.apple.com/', id: ''}]);
});
}, 'getInstalledRelatedApps with multiple related and installed apps');
</script>