Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webrequest / test_post.js
blobdc8707b649475e1a1e512f53e9832ac5c1f273ec
1 // Copyright (c) 2012 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 // Common definitions for test_post?.js.
7 var dirName = "requestBody/";
9 function sendPost(formFile, parseableForm) {
10 // The following variables must be updated when files in |dirName| change.
11 var formData = {
12 "check": ["option_A"],
13 "password": ["password"],
14 "radio": ["Yes"],
15 "select": ["one"],
16 "text\"1\u011B\u0161\u00FD\u4EBA\r\n \r\n": ["TEST_TEXT_1"],
17 "text2": ["TEST_TEXT_2"],
18 "text3": ["TEST_TEXT_3"],
19 "txtarea": ["text\"1\u011B\u0161\u00FD\u4EBA\r\n \r\n"]
21 return function submitForm() {
22 expect(
23 [ // events
24 { label: "a-onBeforeRequest",
25 event: "onBeforeRequest",
26 details: {
27 method: "GET",
28 type: "main_frame",
29 url: getURL(dirName + formFile),
30 frameUrl: getURL(dirName + formFile)
33 { label: "a-onResponseStarted",
34 event: "onResponseStarted",
35 details: {
36 fromCache: false,
37 method: "GET",
38 statusCode: 200,
39 statusLine: "HTTP/1.1 200 OK",
40 type: "main_frame",
41 url: getURL(dirName + formFile)
44 { label: "a-onCompleted",
45 event: "onCompleted",
46 details: {
47 fromCache: false,
48 method: "GET",
49 statusCode: 200,
50 statusLine: "HTTP/1.1 200 OK",
51 type: "main_frame",
52 url: getURL(dirName + formFile)
55 { label: "s-onBeforeRequest",
56 event: "onBeforeRequest",
57 details: {
58 method: "GET",
59 type: "script",
60 url: getURL("requestBody/submit.js"),
61 frameUrl: getURL(dirName + formFile)
64 { label: "s-onResponseStarted",
65 event: "onResponseStarted",
66 details: {
67 fromCache: false,
68 method: "GET",
69 statusCode: 200,
70 statusLine: "HTTP/1.1 200 OK",
71 type: "script",
72 url: getURL("requestBody/submit.js")
75 { label: "s-onCompleted",
76 event: "onCompleted",
77 details: {
78 fromCache: false,
79 method: "GET",
80 statusCode: 200,
81 statusLine: "HTTP/1.1 200 OK",
82 type: "script",
83 url: getURL("requestBody/submit.js")
86 { label: "b-onBeforeRequest",
87 event: "onBeforeRequest",
88 details: {
89 method: "POST",
90 type: "main_frame",
91 url: getURL("simpleLoad/a.html"),
92 frameUrl: getURL("simpleLoad/a.html"),
93 requestBody: parseableForm ? {
94 formData: formData
95 } : {
96 raw: [{bytes: {}}] // ArrayBuffer
100 { label: "b-onResponseStarted",
101 event: "onResponseStarted",
102 details: {
103 fromCache: false,
104 method: "POST",
105 statusCode: 200,
106 statusLine: "HTTP/1.1 200 OK",
107 type: "main_frame",
108 url: getURL("simpleLoad/a.html")
111 { label: "b-onCompleted",
112 event: "onCompleted",
113 details: {
114 fromCache: false,
115 method: "POST",
116 statusCode: 200,
117 statusLine: "HTTP/1.1 200 OK",
118 type: "main_frame",
119 url: getURL("simpleLoad/a.html")
123 [ // event order
124 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted",
125 "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted",
126 "b-onBeforeRequest", "b-onResponseStarted", "b-onCompleted"]
128 {urls: ["<all_urls>"]}, // filter
129 ["requestBody"]);
130 navigateAndWait(getURL(dirName + formFile));