Home | History | Annotate | Download | only in media_galleries
      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.
      4 
      5 var filePassingModule = null;
      6 var testFilesystem;
      7 var gotReady = false;
      8 
      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;
     19           }
     20           testFilesystem = filesystems[0];
     21           var message = {
     22             'filesystem': testFilesystem,
     23             'fullPath': '/test.jpg',
     24             'testType': 'read_test'
     25           };
     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'
     33     };
     34     filePassingModule.postMessage(message);
     35   } else if (message.data == 'write_success'){
     36     chrome.test.succeed();
     37   } else {
     38     chrome.test.fail(message.data);
     39   }
     40 }
     41 
     42 window.onload = function() {
     43   filePassingModule = document.getElementById('nacl_module');
     44   filePassingModule.addEventListener('message', handleMessage, false);
     45 };
     46 
     47