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

Unified Diff: chrome/test/data/extensions/api_test/webrequest/test_simple.html

Issue 7607003: Split ExtensionWebRequestApiTest.WebRequestEvents into multiple tests to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/webrequest/test_simple.html
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_simple.html b/chrome/test/data/extensions/api_test/webrequest/test_simple.html
new file mode 100644
index 0000000000000000000000000000000000000000..1bb285ed289faf3723d29aff5203aca58d847713
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webrequest/test_simple.html
@@ -0,0 +1,179 @@
+<script src="framework.js">
+</script>
+<script>
+// Constants as functions, not to be called until after runTests.
+function getURLHttpSimpleLoad() {
+ return getServerURL('files/extensions/api_test/webrequest/simpleLoad/a.html');
+}
+
+function getURLHttpSimpleLoadRedirect() {
+ return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
+}
+
+runTests([
+ // Navigates to a blank page.
+ function simpleLoad() {
+ expect(
+ [ // events
+ { label: "a-onBeforeRequest",
+ event: "onBeforeRequest",
+ details: {
+ method: "GET",
+ tabId: tabId,
+ type: "main_frame",
+ url: getURL("simpleLoad/a.html"),
+ frameUrl: getURL("simpleLoad/a.html")
+ }
+ },
+ { label: "a-onResponseStarted",
+ event: "onResponseStarted",
+ details: {
+ url: getURL("simpleLoad/a.html"),
+ statusCode: 200,
+ fromCache: false
+ // Request to chrome-extension:// url has no IP.
+ }
+ },
+ { label: "a-onCompleted",
+ event: "onCompleted",
+ details: {
+ url: getURL("simpleLoad/a.html"),
+ statusCode: 200,
+ fromCache: false
+ // Request to chrome-extension:// url has no IP.
+ }
+ },
+ ],
+ [ // event order
+ ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
+ navigateAndWait(getURL("simpleLoad/a.html"));
+ },
+
+ // Navigates to a blank page via HTTP. Only HTTP requests get the
+ // onBeforeSendHeaders event.
+ function simpleLoadHttp() {
+ expect(
+ [ // events
+ { label: "onBeforeRequest-1",
+ event: "onBeforeRequest",
+ details: {
+ method: "GET",
+ tabId: tabId,
+ type: "main_frame",
+ url: getURLHttpSimpleLoadRedirect(),
+ frameUrl: getURLHttpSimpleLoadRedirect()
+ }
+ },
+ { label: "onBeforeSendHeaders-1",
+ event: "onBeforeSendHeaders",
+ details: {
+ url: getURLHttpSimpleLoadRedirect(),
+ requestHeadersValid: true
+ }
+ },
+ { label: "onSendHeaders-1",
+ event: "onSendHeaders",
+ details: {
+ url: getURLHttpSimpleLoadRedirect(),
+ requestHeadersValid: true
+ }
+ },
+ { label: "onBeforeRedirect",
+ event: "onBeforeRedirect",
+ details: {
+ url: getURLHttpSimpleLoadRedirect(),
+ redirectUrl: getURLHttpSimpleLoad(),
+ statusCode: 301,
+ responseHeadersExist: true,
+ ip: "127.0.0.1",
+ fromCache: false,
+ statusLine: "HTTP/1.0 301 Moved Permanently"
+ }
+ },
+ { label: "onBeforeRequest-2",
+ event: "onBeforeRequest",
+ details: {
+ method: "GET",
+ tabId: tabId,
+ type: "main_frame",
+ url: getURLHttpSimpleLoad(),
+ frameUrl: getURLHttpSimpleLoad()
+ }
+ },
+ { label: "onBeforeSendHeaders-2",
+ event: "onBeforeSendHeaders",
+ details: {
+ url: getURLHttpSimpleLoad(),
+ requestHeadersValid: true
+ }
+ },
+ { label: "onSendHeaders-2",
+ event: "onSendHeaders",
+ details: {
+ url: getURLHttpSimpleLoad(),
+ requestHeadersValid: true
+ }
+ },
+ { label: "onResponseStarted",
+ event: "onResponseStarted",
+ details: {
+ url: getURLHttpSimpleLoad(),
+ statusCode: 200,
+ responseHeadersExist: true,
+ ip: "127.0.0.1",
+ fromCache: false,
+ statusLine: "HTTP/1.0 200 OK",
+ }
+ },
+ { label: "onCompleted",
+ event: "onCompleted",
+ details: {
+ url: getURLHttpSimpleLoad(),
+ statusCode: 200,
+ ip: "127.0.0.1",
+ fromCache: false,
+ responseHeadersExist: true,
+ statusLine: "HTTP/1.0 200 OK"
+ }
+ }
+ ],
+ [ // event order
+ ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
+ "onBeforeRedirect",
+ "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
+ "onResponseStarted", "onCompleted"] ],
+ {}, // filter
+ ["requestHeaders", "responseHeaders", "statusLine"]);
+ navigateAndWait(getURLHttpSimpleLoadRedirect());
+ },
+
+ // Navigates to a non-existing page.
+ function nonExistingLoad() {
+ expect(
+ [ // events
+ { label: "onBeforeRequest",
+ event: "onBeforeRequest",
+ details: {
+ method: "GET",
+ tabId: tabId,
+ type: "main_frame",
+ url: getURL("does_not_exist.html"),
+ frameUrl: getURL("does_not_exist.html")
+ }
+ },
+ { label: "onErrorOccurred",
+ event: "onErrorOccurred",
+ details: {
+ url: getURL("does_not_exist.html"),
+ fromCache: false,
+ error: "net::ERR_FILE_NOT_FOUND",
+ // Request to chrome-extension:// url has no IP.
+ }
+ },
+ ],
+ [ // event order
+ ["onBeforeRequest", "onErrorOccurred"] ]);
+ navigateAndWait(getURL("does_not_exist.html"));
+ },
+]);
+</script>

Powered by Google App Engine
This is Rietveld 408576698