Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / tests / extensions / media_galleries / test.js
blob3e77d4986df67bbb7ce667bd12364bf2f0a57ed5
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var filePassingModule = null;
6 var testFilesystem;
7 var gotReady = false;
9 function handleMessage(message) {
10 if (message.data == 'ready') {
11 chrome.test.assertFalse(gotReady);
12 gotReady = true;
13 chrome.mediaGalleries.getMediaFileSystems(
14 function(filesystems) {
15 if (filesystems.length != 1) {
16 chrome.test.fail('Wrong number of media galleries: ' +
17 filesystems.length);
18 return;
20 testFilesystem = filesystems[0];
21 var message = {
22 'filesystem': testFilesystem,
23 'fullPath': '/test.jpg',
24 'testType': 'read_test'
26 filePassingModule.postMessage(message);
27 });
28 } else if (message.data == 'read_success'){
29 var message = {
30 'filesystem': testFilesystem,
31 'fullPath': '/test.jpg',
32 'testType': 'write_test'
34 filePassingModule.postMessage(message);
35 } else if (message.data == 'write_success'){
36 chrome.test.succeed();
37 } else {
38 chrome.test.fail(message.data);
42 window.onload = function() {
43 filePassingModule = document.getElementById('nacl_module');
44 filePassingModule.addEventListener('message', handleMessage, false);