Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: chrome/test/data/extensions/api_test/web_socket_proxy_private/background.js

Issue 8762014: Move another set of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 hostname = '127.0.0.1';
6 var port = -1;
7
8 function testModernApi() {
9 function gotMessage(msg) {
10 chrome.test.assertEq(msg.data, window.btoa("aloha\n"));
11 }
12
13 function gotUrl(url) {
14 var url_regex = /^ws:\/\//
15 chrome.test.assertEq(0, url.search(url_regex));
16 ws = new WebSocket(url);
17
18 function gotMessage(msg) {
19 // chrome.test.callbackPass envelope works only once, remove it.
20 ws.onmessage = gotMessage;
21 }
22
23 // We should get response from HTTP test server.
24 ws.onmessage = chrome.test.callbackPass(gotMessage);
25
26 ws.onopen = function() {
27 var request = ["GET / HTTP/1.1",
28 "Host: 127.0.0.1:" + port,
29 "Connection: keep-alive",
30 "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 5.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2",
31 "Accept: text/html,application/xhtml+xml,application/xml;q= 0.9,*/*;q=0.8",
32 "", ""].join("\r\n");
33 ws.send(window.btoa(request));
34 };
35 }
36
37 chrome.webSocketProxyPrivate.getURLForTCP(
38 hostname, port, { "tls": false }, chrome.test.callbackPass(gotUrl));
39 }
40
41 function testObsoleteApi() {
42 function gotPassport(passport) {
43 chrome.test.assertEq('string', typeof(passport));
44 chrome.test.assertTrue(passport.length > 5); // Short one is insecure.
45 }
46
47 chrome.webSocketProxyPrivate.getPassportForTCP(
48 hostname, port, chrome.test.callbackPass(gotPassport));
49 }
50
51 function setTestServerPortAndProceed(testConfig) {
52 port = testConfig.testServer.port;
53 chrome.test.runTests([testModernApi, testObsoleteApi]);
54 }
55
56 chrome.test.getConfig(setTestServerPortAndProceed);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698