For Testers‎ > ‎Backend Testing‎ > ‎

Extensions HTTP Throttling Testing

The throttling feature for extension-originated requests has a bunch of automated tests in net/url_request/url_request_throttler_manager_unittest.cc and chrome/browser/net/chrome_network_delegate_unittest.cc, but for a true end-to-end test, a manual process gives slightly better coverage.

The setup for this test is straightforward, you run it all on one machine.  You need the copy of Chrome that is being tested, and you need to have a Chromium checkout.

There are two test scenarios; one where you start Chrome the normal way, and one where you start Chrome with the --disable-extensions-http-throttling flag.  In the former scenario, the expectation is that requests from a regular web page will never be throttled by the feature, but that requests originating from an extension will be.  In the latter, the expectation is that no requests will be throttled, not even requests originating from an extension.

Test case 1: Normal start-up of Chrome
  1. In a command prompt, run a command to get the local IP address of your machine.  E.g. on Windows, run [ ipconfig ], or on Linux run [ ifconfig ], and look for the address of your network adapter, likely to look something like 192.168.1.43 or 10.0.0.53. Make note of the IP address.
  2. In a command prompt, change directory to the Chromium checkout.  Run [ python net/tools/testserver/backoff_server.py xxx.xxx.xxx.xxx 1109 ] where xxx.xxx.xxx.xxx is your local IP address.  DO NOT USE 127.0.0.1 (the local loopback address) for this command; the reason is that the throttling feature will never throttle requests to localhost.  Leave the test server running.  Once all of your testing is over, you can kill the test server by navigating to http://xxx.xxx.xxx.xxx:1109/quitquitquit (where xxx.xxx.xxx.xxx is the IP address as before) and the server will exit.
  3. Copy the block of JavaScript at the bottom of this page into a text editor.  Search-and-replace xxx.xxx.xxx.xxx with the IP address you noted.  Keep this text (after the search-and-replace) around to use in steps below.  We'll call it "the edited JavaScript" in steps below.
  4. Install the version of Chrome you want to test.
  5. Install an extension that has a background page.  One example of such an extension is the Chat for Google extension.
  6. Start Chrome
  7. Type chrome://extensions/ into the address bar, press Enter, and make sure developer mode is enabled (checkbox at top right).
  8. Click the "background.html" or "bg.html" link after the text Inspect views: for the extension you installed (for Chat for Google, the link is "background.html").  This will open up the debugging tools for the background page.
  9. Paste the edited JavaScript into the console and press Enter.
  10. Do not interact with the computer for 6 seconds (do not move the mouse, click anywhere, or touch the keyboard).  In about 6 seconds you should see some messages appearing in the console.
  11. The first several of the error messages may say "503 (Service Unavailable)".  After the first few, most of the errors should say "Request throttled. Visit http://dev.chromium.org/throttling for more information."  It is possible that you may see "503 (Service Unavailable)" errors interleaved with those.
  12. Now, navigate to http://www.google.com/ or any other regular web page.
  13. Press F12 to open the debugging tools for the window that is showing the web page.
  14. Open the Console in the debugging tools.
  15. Paste the edited JavaScript into the console and press Enter.
  16. Do not interact with the computer for 6 seconds (do not move the mouse, click anywhere, or touch the keyboard).  In about 6 seconds you should see some messages appearing in the console.
  17. All of the error messages should say there was a 503 error.  None of them should mention throttling.
Test case 2:  Start Chrome with flag that disables throttling
  • This test case is exactly the same as above, except as follows:
    • In step 6, when you start Chrome, you must include the command-line flag --disable-extensions-http-throttling
    • Wait about one minute after step 6, before continuing.  This is to verify a bug that was timing-related where the command-line flag would be obeyed to begin with, but not after a short while.
    • In both steps 11 and 17, all of the error messages should say "503 (Service Unavailable)".  None of them should mention "Request throttled."
Here is the block of JavaScript you need to edit and then use in steps above.  Copy the entire contents of the next line; remember to replace xxx.xxx.xxx.xxx with the IP address from step 1:

for (i = 0; i < 10; i++) { window.setTimeout("new Image().src='http://xxx.xxx.xxx.xxx:1109/?code=503'", 4000+i*200); }

Comments