1 // Copyright 2015 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 // TODO(xunjieli): When URLSearchParams is stable and implemented, switch this
6 // (and a lot of other test code) to it. https://crbug.com/303152
7 var url
= decodeURIComponent(/url=([^&]*)/.exec(location
.search
)[1]);
8 var filter
= {urls
: ['http://www.example.com/*'], types
: ['xmlhttprequest']};
11 chrome
.webRequest
.onCompleted
.addListener(function(details
) {
12 chrome
.test
.assertEq(503, details
.statusCode
);
14 chrome
.runtime
.sendMessage({type
: 'xhr', method
: 'GET', url
: url
});
17 chrome
.webRequest
.onErrorOccurred
.addListener(function(details
) {
18 // Should thottle the third request, which is one request after
20 chrome
.test
.assertEq(3, numRequests
);
21 chrome
.test
.assertEq('net::ERR_TEMPORARILY_THROTTLED', details
.error
);
22 chrome
.test
.notifyPass();
26 chrome
.runtime
.sendMessage({type
: 'xhr', method
: 'GET', url
: url
});