2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
8 from distutils import version
21 import xml.dom.minidom
24 import pyauto_functional # Must be imported before pyauto.
30 class NaClSDKTest(pyauto.PyUITest):
31 """Tests for the NaCl SDK."""
32 _isExamplesTest = False
33 _extracted_sdk_path = None
35 _updated_pepper_versions = []
36 _latest_updated_pepper_versions = []
38 'post_sdk_download_url': 'http://code.google.com/chrome/nativeclient/'
40 'post_sdk_zip': 'http://storage.googleapis.com/'
41 'nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip',
42 'min_required_chrome_build': 14,
46 pyauto.PyUITest.tearDown(self)
47 if not self._isExamplesTest:
48 self._RemoveDownloadedTestFile()
50 def testNaClSDK(self):
51 """Verify that NaCl SDK is working properly."""
52 if not self._HasAllSystemRequirements():
53 logging.info('System does not meet the requirements.')
55 self._extracted_sdk_path = tempfile.mkdtemp()
56 self._VerifyDownloadLinks()
57 self._VerifyNaClSDKInstaller()
60 self._LaunchServerAndVerifyExamplesAllPepperVersions()
62 def NaClSDKExamples(self):
63 """Verify if NaCl SDK examples are working."""
64 self._isExamplesTest = True
65 nacl_sdk_root = os.environ.get('NACL_SDK_ROOT', None)
66 pepper_version = os.environ.get('PEPPER_VER', None)
67 if nacl_sdk_root and pepper_version:
68 self._LaunchServerAndVerifyExamples('pepper_' + pepper_version,
71 self.fail(msg='Missing pepper version to be checked or SDK path.')
73 def _VerifyDownloadLinks(self):
74 """Verify the download links.
76 Simply verify that NaCl download links exist in html page.
81 html = urllib2.urlopen(self._settings['post_sdk_download_url']).read()
86 msg='Cannot open URL: %s' %
87 self._settings['post_sdk_download_url'])
88 sdk_url = self._settings['post_sdk_zip']
89 self.assertTrue(sdk_url in html,
90 msg='Missing SDK download URL: %s' % sdk_url)
92 def _VerifyNaClSDKInstaller(self):
93 """Verify NaCl SDK installer."""
98 mac_lin_additional_search_items = [
101 win_additional_search_items = [
104 self._DownloadNaClSDK()
105 self._ExtractNaClSDK()
106 if pyauto.PyUITest.IsWin():
107 self._SearchNaClSDKFile(
108 search_list + win_additional_search_items)
109 elif pyauto.PyUITest.IsMac() or pyauto.PyUITest.IsLinux():
110 self._SearchNaClSDKFile(
111 search_list + mac_lin_additional_search_items)
113 self.fail(msg='NaCl SDK does not support this OS.')
115 def _VerifyInstall(self):
116 """Install NACL sdk."""
117 # Executing naclsdk(.bat) list
118 if pyauto.PyUITest.IsWin():
119 source_file = os.path.join(
120 self._extracted_sdk_path, 'nacl_sdk', 'naclsdk.bat')
121 elif pyauto.PyUITest.IsMac() or pyauto.PyUITest.IsLinux():
122 source_file = os.path.join(
123 self._extracted_sdk_path, 'nacl_sdk', 'naclsdk')
124 subprocess.call(['chmod', '-R', '755', self._extracted_sdk_path])
126 self.fail(msg='NaCl SDK does not support this OS.')
127 subprocess.Popen([source_file, 'list'],
128 stdout=subprocess.PIPE,
129 stderr=subprocess.PIPE).communicate()
131 def _VerifyUpdate(self):
132 """Update NACL sdk"""
133 # Executing naclsdk(.bat) update
134 if pyauto.PyUITest.IsWin():
135 source_file = os.path.join(self._extracted_sdk_path, 'nacl_sdk',
137 elif pyauto.PyUITest.IsMac() or pyauto.PyUITest.IsLinux():
138 source_file = os.path.join(self._extracted_sdk_path, 'nacl_sdk',
141 self.fail(msg='NaCl SDK does not support this OS.')
142 # Executing nacl_sdk(.bat) update to get the latest version.
143 updated_output = subprocess.Popen([source_file, 'update'],
144 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
145 self._updated_pepper_versions.extend(
146 re.findall('Updating bundle (pepper_[0-9]{2})', updated_output))
147 self._updated_pepper_versions = list(set(self._updated_pepper_versions))
148 self._updated_pepper_versions.sort(key=str.lower)
149 updated_pepper_versions_len = len(self._updated_pepper_versions)
150 self._latest_updated_pepper_versions = filter(
151 lambda x: x >= 'pepper_18', self._updated_pepper_versions)
153 def _GetURLForExampleName(self, name, toolchain):
154 return 'http://localhost:5103/%s/index_%s.html' % (name, toolchain)
156 def _GetExampleNamesAndURLs(self, examples_path):
157 """Get a list of all examples as (name, url) tuples.
160 examples_path: The path to the examples directory in the NaCl SDK.
162 toolchains = ['newlib', 'glibc', 'pnacl']
165 for toolchain in toolchains:
166 for example in os.listdir(examples_path):
167 html_path = os.path.join(examples_path, example,
168 'index_%s.html' % (toolchain,))
169 if os.path.exists(html_path):
170 example_url = self._GetURLForExampleName(example, toolchain)
171 examples.append((example, example_url))
174 def _LaunchServerAndVerifyExamplesAllPepperVersions(self):
175 for pepper_version in self._latest_updated_pepper_versions:
176 pepper_path = os.path.join(self._extracted_sdk_path,
177 'nacl_sdk', 'pepper_' + str(pepper_version))
178 self._LaunchServerAndVerifyExamples(pepper_version, pepper_path)
180 def _LaunchServerAndVerifyExamples(self, pepper_version, pepper_path):
181 """Start local HTTP server and verify examples."""
182 if self._ChromeAndPepperVersionMatch(pepper_version):
183 # Close server if it's already open.
184 if self._IsURLAlive('http://localhost:5103'):
185 self._CloseHTTPServer()
187 examples_path = os.path.join(pepper_path, 'examples')
189 # Launch local http server.
190 proc = subprocess.Popen(['make RUN'], shell=True, cwd=examples_path)
192 lambda: self._IsURLAlive('http://localhost:5103'),
193 timeout=150, retry_sleep=1)
195 examples = self._GetExampleNamesAndURLs(examples_path)
197 self._OpenExamplesAndStartTest(examples)
199 self._CloseHTTPServer(proc)
202 self.pprint('Pepper Version %s does not match the Chrome version %s.'
204 self.GetBrowserInfo()['properties']['ChromeVersion']))
206 def _ChromeAndPepperVersionMatch(self, pepper_version='pepper_18'):
207 """Determine if chrome and pepper version match"""
208 version_number = re.findall('pepper_([0-9]{2})', pepper_version)
209 browser_info = self.GetBrowserInfo()
210 chrome_version = browser_info['properties']['ChromeVersion']
211 chrome_build = int(chrome_version.split('.')[0])
212 return int(chrome_build) == int(version_number[0])
214 def _RemoveDownloadedTestFile(self):
215 """Delete downloaded files and dirs from downloads directory."""
216 if self._extracted_sdk_path and os.path.exists(self._extracted_sdk_path):
217 self._CloseHTTPServer()
220 shutil.rmtree(self._extracted_sdk_path, ignore_errors=True)
221 return os.path.exists(self._extracted_sdk_path)
223 success = self.WaitUntil(_RemoveFile, retry_sleep=2,
225 self.assertTrue(success,
226 msg='Cannot remove %s' % self._extracted_sdk_path)
229 pyauto_utils.RemovePath(self._temp_dir)
231 def _OpenExamplesAndStartTest(self, examples):
232 """Open each example and verify that it's working.
235 examples: A list of example (name, url) tuples.
237 example_verify_funcs = {
238 'dlopen': self._VerifyDynamicLibraryOpen,
239 'file_io': self._VerifyFileIoExample,
240 'geturl': self._VerifyGetURLExample,
241 'input_events': self._VerifyInputEventsExample,
242 'load_progress': self._VerifyLoadProgressExample,
243 'mt_input_events': self._VerifyMultithreadedInputEventsExample,
244 'pi_generator': self._VerifyPiGeneratorExample,
245 'sine_synth': self._VerifySineSynthExample,
246 'websocket': self._VerifyWebSocketExample,
249 # Remove examples that we don't yet verify
250 examples = [(name, url) for name, url in examples
251 if name in example_verify_funcs]
254 for name, url in examples:
255 self.AppendTab(pyauto.GURL(url))
256 self._CheckForCrashes()
258 # Verify all examples are working.
259 for name, url in examples:
260 self._VerifyAnExample(name, url, example_verify_funcs[name])
261 self._CheckForCrashes()
263 # Close each tab and check for crashes.
264 tab_count = self.GetTabCount()
265 for index in xrange(tab_count - 1, 0, -1):
266 self.CloseTab(tab_index=index)
267 self._CheckForCrashes()
269 def _VerifyAnExample(self, name, url, verify_func):
270 """Verify NaCl example is working.
273 name: A string name of the example.
274 url: A string url of the example.
275 verify_func: The function to verify the example.
276 Takes (tab_index, name, url) as parameters.
279 self.fail(msg='No test available for %s.' % name)
281 info = self.GetBrowserInfo()
282 tabs = info['windows'][0]['tabs']
285 if url == tab['url']:
286 self.ActivateTab(tab['index'])
287 tab_index = tab['index']
291 verify_func(tab_index, name, url)
293 def _VerifyElementPresent(self, element_id, expected_value, tab_index, msg,
294 attribute='innerHTML', timeout=150):
295 """Determine if dom element has the expected value.
298 element_id: Dom element's id.
299 expected_value: String to be matched against the Dom element.
300 tab_index: Tab index to work on.
301 attribute: Attribute to match |expected_value| against, if
302 given. Defaults to 'innerHTML'.
303 timeout: The max timeout (in secs) for which to wait.
306 var output = document.getElementById('%s').%s;
308 if (output.indexOf('%s') != -1)
312 window.domAutomationController.send(result);
313 """ % (element_id, attribute, expected_value)
314 success = self.WaitUntil(
315 lambda: self.ExecuteJavascript(js_code, tab_index),
316 timeout=timeout, expect_retval='pass')
317 self.assertTrue(success, msg=msg)
319 def _CreateJSToSimulateMouseclick(self):
320 """Create javascript to simulate mouse click event."""
322 var rightClick = document.createEvent('MouseEvents');
323 rightClick.initMouseEvent(
324 'mousedown', true, true, document,
326 false, false, false, false,
329 common.naclModule.dispatchEvent(rightClick);
330 window.domAutomationController.send('done');
334 def _VerifyInputEventsExample(self, tab_index, name, url):
335 """Verify Input Events Example.
338 tab_index: Tab index integer that the example is on.
339 name: A string name of the example.
340 url: A string url of the example.
342 success = self._VerifyElementPresent('eventString', 'DidChangeView',
343 tab_index, msg='Example %s failed. URL: %s' % (name, url))
345 # Simulate mouse click on event module.
346 js_code = self._CreateJSToSimulateMouseclick()
347 self.ExecuteJavascript(js_code, tab_index)
349 # Check if 'eventString' has handled above mouse click.
350 success = self.WaitUntil(
351 lambda: re.search('DidHandleInputEvent', self.GetDOMValue(
352 'document.getElementById("eventString").innerHTML',
353 tab_index)).group(), expect_retval='DidHandleInputEvent')
354 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
356 def _VerifyMultithreadedInputEventsExample(self, tab_index, name, url):
357 """Verify Input Events Example.
360 tab_index: Tab index integer that the example is on.
361 name: A string name of the example.
362 url: A string url of the example.
364 success = self.WaitUntil(
365 lambda: bool(self.GetDOMValue(
366 'document.getElementById("eventString").innerHTML',
367 tab_index).find('DidChangeView') + 1))
369 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
371 # Simulate mouse click on event module.
372 js_code = self._CreateJSToSimulateMouseclick()
373 self.ExecuteJavascript(js_code, tab_index)
375 # Check if above mouse click is handled.
376 success = self._VerifyElementPresent('eventString', 'Mouse event',
377 tab_index, msg='Example %s failed. URL: %s' % (name, url))
379 # Kill worker thread and queue
381 document.getElementsByTagName('button')[0].click();
382 window.domAutomationController.send('done');
384 self.ExecuteJavascript(js_code, tab_index)
386 # Check if main thread has cancelled queue.
387 success = self._VerifyElementPresent('eventString', 'Received cancel',
388 tab_index, msg='Example %s failed. URL: %s' % (name, url))
390 # Simulate mouse click on event module.
391 js_code = self._CreateJSToSimulateMouseclick()
392 self.ExecuteJavascript(js_code, tab_index)
394 # Check if above mouse click is not handled after killing worker thread.
395 def _CheckMouseClickEventStatus():
396 return self.GetDOMValue(
397 'document.getElementById("eventString").innerHTML',
398 tab_index).find('Mouse event', self.GetDOMValue(
399 'document.getElementById("eventString").innerHTML', tab_index).find(
402 success = self.WaitUntil(_CheckMouseClickEventStatus, expect_retval=-1)
403 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
405 def _VerifyFileIoExample(self, tab_index, name, url):
406 """Verify File IO Example.
409 tab_index: Tab index integer that the example is on.
410 name: A string name of the example.
411 url: A string url of the example.
413 def _CheckStatus(substring_expected, fail_msg):
416 lambda: self.GetDOMValue(
417 'document.getElementById("statusField").innerHTML', tab_index)\
418 .find(substring_expected) != -1, expect_retval=True),
419 msg='Example %s failed. URL: %s. Reason: %s' % (name, url, fail_msg))
421 # Give permission to use file system by clicking infobar OK
422 infobar_index = test_utils.WaitForInfobarTypeAndGetIndex(self,
423 'confirm_infobar', 0, tab_index)
424 self.PerformActionOnInfobar('accept', infobar_index, 0, tab_index)
425 _CheckStatus('Ready!', 'NaCl module load')
427 # Check that deleting non-existing files gives file not found
429 document.getElementById('file_name').value = '/abc';
430 document.getElementById('file_editor').value = 'test';
431 document.getElementById('delete_but').click();
432 window.domAutomationController.send('done');
434 self.ExecuteJavascript(js_code, tab_index)
435 _CheckStatus('File not found', 'Delete non-existing')
437 # Check that saving works
439 document.getElementById('save_but').click();
440 window.domAutomationController.send('done');
442 self.ExecuteJavascript(js_code, tab_index)
443 _CheckStatus('Save successful', 'Save test')
445 # Check that we load what we saved
447 document.getElementById('file_editor').value = 'different';
448 document.getElementById('load_but').click();
449 window.domAutomationController.send('done');
451 self.ExecuteJavascript(js_code, tab_index)
452 _CheckStatus('Load complete', 'Load test')
454 self.GetDOMValue('document.getElementById("file_editor").value',
455 tab_index).find('test') != -1, msg='Loaded wrong text or failed')
457 # Check that we delete files successfully
459 document.getElementById('delete_but').click();
460 window.domAutomationController.send('done');
462 self.ExecuteJavascript(js_code, tab_index)
463 _CheckStatus('File deleted', 'Delete test')
465 # Check that file is deleted and load produces not found
467 document.getElementById('load_but').click();
468 window.domAutomationController.send('done');
470 self.ExecuteJavascript(js_code, tab_index)
471 _CheckStatus('File not found', 'Load deleted test')
473 def _VerifyWebSocketExample(self, tab_index, name, url):
474 """Verify Web Socket Open Example.
477 tab_index: Tab index integer that the example is on.
478 name: A string name of the example.
479 url: A string url of the example.
481 # Check if example is loaded.
482 success = self.WaitUntil(
483 lambda: self.GetDOMValue(
484 'document.getElementById("statusField").innerHTML', tab_index),
485 expect_retval='SUCCESS')
486 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
488 # Simulate clicking on Connect button to establish a connection.
490 document.getElementsByTagName('input')[1].click();
491 window.domAutomationController.send('done');
493 self.ExecuteJavascript(js_code, tab_index)
496 success = self._VerifyElementPresent('log', 'connected', tab_index,
497 msg='Example %s failed. URL: %s' % (name, url))
499 # Simulate clicking on Send button to send text message in log.
501 document.getElementsByTagName('input')[3].click();
502 window.domAutomationController.send('done');
504 self.ExecuteJavascript(js_code, tab_index)
505 success = self.WaitUntil(
506 lambda: bool(re.search('send:', self.GetDOMValue(
507 'document.getElementById("log").textContent', tab_index))))
508 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
510 def _VerifyDynamicLibraryOpen(self, tab_index, name, url):
511 """Verify Dynamic Library Open Example.
514 tab_index: Tab index integer that the example is on.
515 name: A string name of the example.
516 url: A string url of the example.
518 # Check if example is loaded.
519 success = self._VerifyElementPresent('log', 'Eightball loaded!',
520 tab_index, msg='Example %s failed. URL: %s' % (name, url))
522 # Simulate clicking on ASK button and check answer log for desired answer.
524 document.getElementsByTagName('input')[1].click();
525 window.domAutomationController.send('done');
527 self.ExecuteJavascript(js_code, tab_index)
528 def _CheckAnswerLog():
529 return bool(re.search(r'NO|YES|42|MAYBE NOT|DEFINITELY|'
530 'ASK ME TOMORROW|MAYBE|PARTLY CLOUDY',
531 self.GetDOMValue('document.getElementById("log").innerHTML',
534 success = self.WaitUntil(_CheckAnswerLog)
535 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
537 def _VerifyLoadProgressExample(self, tab_index, name, url):
538 """Verify Dynamic Library Open Example.
541 tab_index: Tab index integer that the example is on.
542 name: A string name of the example.
543 url: A string url of the example.
545 # Check if example loads and displays loading progress.
546 success = self.WaitUntil(
547 lambda: self.GetDOMValue(
548 'document.getElementById("statusField").innerHTML', tab_index),
549 timeout=150, expect_retval='SUCCESS')
550 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
552 def _CheckLoadProgressStatus():
554 r'(loadstart).+(progress:).+(load).+(loadend).+(lastError:)',
556 'document.getElementById("log").innerHTML', tab_index))
557 success = self.WaitUntil(_CheckLoadProgressStatus)
558 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
560 def _VerifyPiGeneratorExample(self, tab_index, name, url):
561 """Verify Pi Generator Example.
564 tab_index: Tab index integer that the example is on.
565 name: A string name of the example.
566 url: A string url of the example.
568 success = self.WaitUntil(
569 lambda: self.GetDOMValue('document.getElementById("pi").value',
572 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
574 def _VerifySineSynthExample(self, tab_index, name, url):
575 """Verify Sine Wave Synthesizer Example.
578 tab_index: Tab index integer that the example is on.
579 name: A string name of the example.
580 url: A string url of the example.
582 success = self.WaitUntil(
583 lambda: self.GetDOMValue(
584 'document.getElementById("frequency_field").value',
585 tab_index), timeout=150, expect_retval='440')
586 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
587 self.ExecuteJavascript(
588 'document.body.getElementsByTagName("button")[0].click();'
589 'window.domAutomationController.send("done")',
592 def _VerifyGetURLExample(self, tab_index, name, url):
593 """Verify GetURL Example.
596 tab_index: Tab index integer that the example is on.
597 name: A string name of the example.
598 url: A string url of the example.
600 success = self.WaitUntil(
601 lambda: self.GetDOMValue(
602 'document.getElementById("statusField").innerHTML',
603 tab_index), timeout=150, expect_retval='SUCCESS')
604 self.assertTrue(success, msg='Example %s failed. URL: %s' % (name, url))
605 self.ExecuteJavascript(
606 'document.getElementById("button").click();'
607 'window.domAutomationController.send("done")',
609 success = self._VerifyElementPresent('general_output', 'test passed',
610 tab_index, msg='Example %s failed. URL: %s' % (name, url))
612 def _CheckForCrashes(self):
613 """Check for any browser/tab crashes and hangs."""
614 self.assertTrue(self.GetBrowserWindowCount(),
615 msg='Browser crashed, no window is open.')
617 info = self.GetBrowserInfo()
618 breakpad_folder = info['properties']['DIR_CRASH_DUMPS']
619 old_dmp_files = glob.glob(os.path.join(breakpad_folder, '*.dmp'))
621 # Verify there're no crash dump files.
622 for dmp_file in glob.glob(os.path.join(breakpad_folder, '*.dmp')):
623 self.assertTrue(dmp_file in old_dmp_files,
624 msg='Crash dump %s found' % dmp_file)
626 # Check for any crashed tabs.
627 tabs = info['windows'][0]['tabs']
629 if tab['url'] != 'about:blank':
630 if not self.GetDOMValue('document.body.innerHTML', tab['index']):
631 self.fail(msg='Tab crashed on %s' % tab['url'])
633 def _GetPlatformArchitecture(self):
634 """Get platform architecture.
637 A string representing the platform architecture.
639 if pyauto.PyUITest.IsWin():
640 if os.environ['PROGRAMFILES'] == 'C:\\Program Files (x86)':
644 elif pyauto.PyUITest.IsMac() or pyauto.PyUITest.IsLinux():
645 if platform.machine() == 'x86_64':
651 def _HasPathInTree(self, pattern, is_file, root=os.curdir):
652 """Recursively checks if a file/directory matching a pattern exists.
655 pattern: Pattern of file or directory name.
656 is_file: True if looking for file, or False if looking for directory.
657 root: Directory to start looking.
660 True, if root contains the directory name pattern, or
663 for path, dirs, files in os.walk(os.path.abspath(root)):
665 if len(fnmatch.filter(files, pattern)):
668 if len(fnmatch.filter(dirs, pattern)):
672 def _HasAllSystemRequirements(self):
673 """Verify NaCl SDK installation system requirements.
676 True, if system passed requirements, or
679 # Check python version.
680 if sys.version_info[0:2] < (2, 6):
683 # Check OS requirements.
684 if pyauto.PyUITest.IsMac():
685 mac_min_version = version.StrictVersion('10.6')
686 mac_version = version.StrictVersion(platform.mac_ver()[0])
687 if mac_version < mac_min_version:
689 elif pyauto.PyUITest.IsWin():
690 if not (self.IsWin7() or self.IsWinVista() or self.IsWinXP()):
692 elif pyauto.PyUITest.IsLinux():
693 pass # TODO(chrisphan): Check Lin requirements.
697 # Check for Chrome version compatibility.
698 # NaCl supports Chrome 10 and higher builds.
699 min_required_chrome_build = self._settings['min_required_chrome_build']
700 browser_info = self.GetBrowserInfo()
701 chrome_version = browser_info['properties']['ChromeVersion']
702 chrome_build = int(chrome_version.split('.')[0])
703 return chrome_build >= min_required_chrome_build
705 def _DownloadNaClSDK(self):
706 """Download NaCl SDK."""
707 self._temp_dir = tempfile.mkdtemp()
708 dl_file = urllib2.urlopen(self._settings['post_sdk_zip'])
709 file_path = os.path.join(self._temp_dir, 'nacl_sdk.zip')
712 f = open(file_path, 'wb')
713 f.write(dl_file.read())
715 self.fail(msg='Cannot open %s.' % file_path)
719 def _ExtractNaClSDK(self):
720 """Extract NaCl SDK."""
721 source_file = os.path.join(self._temp_dir, 'nacl_sdk.zip')
722 if zipfile.is_zipfile(source_file):
723 zip = zipfile.ZipFile(source_file, 'r')
724 zip.extractall(self._extracted_sdk_path)
726 self.fail(msg='%s is not a valid zip file' % source_file)
728 def _IsURLAlive(self, url):
729 """Test if URL is alive."""
736 def _CloseHTTPServer(self, proc=None):
737 """Close HTTP server.
740 proc: Process that opened the HTTP server.
741 proc is None when there is no pointer to HTTP server process.
743 if not self._IsURLAlive('http://localhost:5103'):
745 response = urllib2.urlopen('http://localhost:5103')
746 html = response.read()
747 if not 'Native Client' in html:
748 self.fail(msg='Port 5103 is in use.')
750 urllib2.urlopen('http://localhost:5103?quit=1')
751 success = self.WaitUntil(
752 lambda: self._IsURLAlive('http://localhost:5103'),
753 retry_sleep=1, expect_retval=False)
756 self.fail(msg='Failed to close HTTP server.')
758 if proc.poll() == None:
762 self.fail(msg='Failed to close HTTP server.')
764 def _SearchNaClSDKFile(self, search_list):
765 """Search NaCl SDK file for example files and directories in Windows.
768 search_list: A list of strings, representing file and
769 directory names for which to search.
772 for name in search_list:
773 is_file = name.find('/') < 0
775 name = name.replace('/', '')
776 if not self._HasPathInTree(name, is_file, self._extracted_sdk_path):
777 missing_items.append(name)
778 self.assertEqual(len(missing_items), 0,
779 msg='Missing files or directories: %s' %
780 ', '.join(map(str, missing_items)))
782 def ExtraChromeFlags(self):
783 """Ensures Nacl is enabled.
786 A list of extra flags to pass to Chrome when it is launched.
788 extra_chrome_flags = [
790 '--enable-nacl-exception-handling',
793 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_chrome_flags
795 if __name__ == '__main__':
796 pyauto_functional.Main()