title: Chrome App - webview.cleardata, reload and periodic refresh
body: <p>I'm working on a kiosk app with a webview to display a Google Slides presentation. Basic mechanics are all working fine, but I need for the webview to refresh periodically to reflect changes made to the Slides.</p>
  
  <p>Watched Chromium bug <a href="http://code.google.com/p/chromium/issues/detail?id=406437" rel="nofollow">406437</a> to clear webview cache (yay!), and am attempting to implement the webview.cleardata and webview.reload, but doesn't seem to work. Console log shows "Cannot read property 'reload' of null"</p>
  
  <p>Am I on the right track? Is there something simple I'm overlooking, or is there a design flaw in my logic?</p>
  
  <p>Contents of my <strong>browser.js</strong> (at least the first part)...</p>
  
  <pre><code>// NOTE: Refresh timing is on line 26 - in milliseconds
  // 5 min: 5 x 60 (sec) x 1000 (ms)
  
  window.onresize = doLayout;
  var isLoading = false;
  
  // Define the function
  function refreshWebView() {
    var webview = document.querySelector('webview');
  
    // https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/webview-samples/browser/browser.js
    // Set up the clear data variable
    var clearDataType = { 
    appcache: true, 
    cookies: true, 
    fileSystems: true, 
    indexedDB: true, 
    localStorage: true, 
    webSQL: true, 
    cache: true
    } 
  
    webview.clearData({since: 0}, clearDataType, function() { webview.reload(true); }); 
    webview.reload(true);
    setTimeout(function() { refreshWebView(); }, 60*1000);
  }
  
  // Kick off the refresh (with the delay defined above)
  console.log('starting refreshWebView...');
  
  refreshWebView();
  
  onload = function() {
    var webview = document.querySelector('webview');
    doLayout();
  
    document.querySelector('#back').onclick = function() {
      webview.back();
    };
  
  ... remaining code removed for brevity...
  </code></pre>