How to use fetch method in Puppeteer

Best JavaScript code snippet using puppeteer

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

__init__.py

Source: __init__.py Github

copy
1# coding:utf-8
2#
3# The MIT License (MIT)
4#
5# Copyright (c) 2016-2021 yutiansut/QUANTAXIS
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included in all
15# copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23# SOFTWARE.
24
25"""
26QA fetch module
27
28@yutiansut
29
30QAFetch is Under [QAStandard#[email protected]] Protocol
31
32
33"""
34from QUANTAXIS.QAFetch import QAWind as QAWind
35from QUANTAXIS.QAFetch import QATushare as QATushare
36from QUANTAXIS.QAFetch import QATdx as QATdx
37from QUANTAXIS.QAFetch import QAThs as QAThs
38from QUANTAXIS.QAFetch import QACrawler as QACL
39from QUANTAXIS.QAFetch import QAEastMoney as QAEM
40from QUANTAXIS.QAFetch import QAHexun as QAHexun
41from QUANTAXIS.QAFetch import QAfinancial
42from QUANTAXIS.QAFetch.base import get_stock_market
43from QUANTAXIS.QAFetch import QAQAWEB as QAWEB
44from QUANTAXIS.QAFetch import QAKQ as QAKQ
45
46def use(package):
47    if package in ['wind']:
48        try:
49            from WindPy import w
50            # w.start()
51            return QAWind
52        except ModuleNotFoundError:
53            print('NO WIND CLIENT FOUND')
54    elif package in ['tushare', 'ts']:
55        return QATushare
56    elif package in ['tdx', 'pytdx']:
57        return QATdx
58    elif package in ['ths', 'THS']:
59        return QAThs
60    elif package in ['HEXUN', 'Hexun', 'hexun']:
61        return QAHexun
62    elif package in ['QA']:
63        return QAWEB
64
65
66def QA_fetch_get_stock_day(package, code, start, end, if_fq='00', level='day', type_='pd'):
67    Engine = use(package)
68    if package in ['ths', 'THS', 'wind']:
69        return Engine.QA_fetch_get_stock_day(code, start, end, if_fq)
70    elif package in ['ts', 'tushare']:
71        return Engine.QA_fetch_get_stock_day(code, start, end, if_fq, type_)
72    elif package in ['tdx', 'pytdx']:
73        return Engine.QA_fetch_get_stock_day(code, start, end, if_fq, level)
74    else:
75        return Engine.QA_fetch_get_stock_day(code, start, end)
76
77
78def QA_fetch_get_stock_realtime(package, code):
79    Engine = use(package)
80    return Engine.QA_fetch_get_stock_realtime(code)
81
82
83def QA_fetch_get_stock_indicator(package, code, start, end):
84    Engine = use(package)
85    return Engine.QA_fetch_get_stock_indicator(code, start, end)
86
87
88def QA_fetch_get_trade_date(package, end, exchange):
89    Engine = use(package)
90    return Engine.QA_fetch_get_trade_date(end, exchange)
91
92
93def QA_fetch_get_stock_min(package, code, start, end, level='1min'):
94    Engine = use(package)
95    if package in ['tdx', 'pytdx']:
96        return Engine.QA_fetch_get_stock_min(code, start, end, level)
97    else:
98        return 'Unsupport packages'
99
100
101def QA_fetch_get_stock_transaction(package, code, start, end, retry=2):
102    Engine = use(package)
103    if package in ['tdx', 'pytdx']:
104        return Engine.QA_fetch_get_stock_transaction(code, start, end, retry)
105    else:
106        return 'Unsupport packages'
107
108
109def QA_fetch_get_index_transaction(package, code, start, end, retry=2):
110    Engine = use(package)
111    if package in ['tdx', 'pytdx']:
112        return Engine.QA_fetch_get_index_transaction(code, start, end, retry)
113    else:
114        return 'Unsupport packages'
115
116
117def QA_fetch_get_stock_transaction_realtime(package, code):
118    Engine = use(package)
119    if package in ['tdx', 'pytdx']:
120        return Engine.QA_fetch_get_stock_transaction_realtime(code)
121    else:
122        return 'Unsupport packages'
123
124
125def QA_fetch_get_stock_xdxr(package, code):
126    Engine = use(package)
127    if package in ['tdx', 'pytdx']:
128        return Engine.QA_fetch_get_stock_xdxr(code)
129    else:
130        return 'Unsupport packages'
131
132
133def QA_fetch_get_index_day(package, code, start, end, level='day'):
134    Engine = use(package)
135    if package in ['tdx', 'pytdx']:
136        return Engine.QA_fetch_get_index_day(code, start, end, level)
137    else:
138        return 'Unsupport packages'
139
140
141def QA_fetch_get_index_min(package, code, start, end, level='1min'):
142    Engine = use(package)
143    if package in ['tdx', 'pytdx']:
144        return Engine.QA_fetch_get_index_min(code, start, end, level)
145    else:
146        return 'Unsupport packages'
147
148
149def QA_fetch_get_index_realtime(package, code):
150    Engine = use(package)
151    return Engine.QA_fetch_get_index_realtime(code)
152
153
154def QA_fetch_get_bond_day(package, code, start, end, level='day'):
155    Engine = use(package)
156    if package in ['tdx', 'pytdx']:
157        return Engine.QA_fetch_get_bond_day(code, start, end, level)
158    else:
159        return 'Unsupport packages'
160
161
162def QA_fetch_get_bond_min(package, code, start, end, level='1min'):
163    Engine = use(package)
164    if package in ['tdx', 'pytdx']:
165        return Engine.QA_fetch_get_bond_min(code, start, end, level)
166    else:
167        return 'Unsupport packages'
168
169def QA_fetch_get_bond_realtime(package, code):
170    Engine = use(package)
171    return Engine.QA_fetch_get_bond_realtime(code)
172
173def QA_fetch_get_stock_block(package):
174    Engine = use(package)
175    if package in ['tdx', 'pytdx', 'ths', 'tushare', 'QA']:
176        return Engine.QA_fetch_get_stock_block()
177    else:
178        return 'Unsupport packages'
179
180
181def QA_fetch_get_stock_info(package, code):
182    Engine = use(package)
183    if package in ['tdx', 'pytdx']:
184        return Engine.QA_fetch_get_stock_info(code)
185    else:
186        return 'Unsupport packages'
187
188# LIST
189
190
191def QA_fetch_get_stock_list(package, type_='stock'):
192    Engine = use(package)
193    if package in ['tdx', 'pytdx']:
194        return Engine.QA_fetch_get_stock_list(type_)
195    else:
196        return 'Unsupport packages'
197
198
199def QA_fetch_get_bond_list(package):
200    Engine = use(package)
201    if package in ['tdx', 'pytdx']:
202        return Engine.QA_fetch_get_bond_list()
203    else:
204        return 'Unsupport packages'
205
206
207def QA_fetch_get_index_list(package):
208    Engine = use(package)
209    if package in ['tdx', 'pytdx']:
210        return Engine.QA_fetch_get_index_list()
211    else:
212        return 'Unsupport packages'
213
214
215def QA_fetch_get_future_list(package,):
216    Engine = use(package)
217    if package in ['tdx', 'pytdx']:
218        return Engine.QA_fetch_get_future_list()
219    else:
220        return 'Unsupport packages'
221
222
223def QA_fetch_get_option_list(package,):
224    Engine = use(package)
225    if package in ['tdx', 'pytdx']:
226        return Engine.QA_fetch_get_option_list()
227    else:
228        return 'Unsupport packages'
229
230
231def QA_fetch_get_globalfuture_list(package,):
232    Engine = use(package)
233    if package in ['tdx', 'pytdx']:
234        return Engine.QA_fetch_get_globalfuture_list()
235    else:
236        return 'Unsupport packages'
237
238
239def QA_fetch_get_hkstock_list(package,):
240    Engine = use(package)
241    if package in ['tdx', 'pytdx']:
242        return Engine.QA_fetch_get_hkstock_list()
243    else:
244        return 'Unsupport packages'
245
246
247def QA_fetch_get_hkfund_list(package,):
248    Engine = use(package)
249    if package in ['tdx', 'pytdx']:
250        return Engine.QA_fetch_get_hkfund_list()
251    else:
252        return 'Unsupport packages'
253
254
255def QA_fetch_get_hkindex_list(package,):
256    Engine = use(package)
257    if package in ['tdx', 'pytdx']:
258        return Engine.QA_fetch_get_hkindex_list()
259    else:
260        return 'Unsupport packages'
261
262
263def QA_fetch_get_usstock_list(package,):
264    Engine = use(package)
265    if package in ['tdx', 'pytdx']:
266        return Engine.QA_fetch_get_usstock_list()
267    else:
268        return 'Unsupport packages'
269
270
271def QA_fetch_get_macroindex_list(package,):
272    Engine = use(package)
273    if package in ['tdx', 'pytdx']:
274        return Engine.QA_fetch_get_macroindex_list()
275    else:
276        return 'Unsupport packages'
277
278
279def QA_fetch_get_globalindex_list(package,):
280    Engine = use(package)
281    if package in ['tdx', 'pytdx']:
282        return Engine.QA_fetch_get_globalindex_list()
283    else:
284        return 'Unsupport packages'
285
286
287def QA_fetch_get_exchangerate_list(package,):
288    Engine = use(package)
289    if package in ['tdx', 'pytdx']:
290        return Engine.QA_fetch_get_exchangerate_list()
291    else:
292        return 'Unsupport packages'
293
294
295#######################
296
297
298def QA_fetch_get_security_bars(code, _type, lens):
299    return QATdx.QA_fetch_get_security_bars(code, _type, lens)
300
301
302def QA_fetch_get_future_transaction(package, code, start, end):
303    Engine = use(package)
304    if package in ['tdx', 'pytdx']:
305        return Engine.QA_fetch_get_future_transaction(code, start, end)
306    else:
307        return 'Unsupport packages'
308
309
310def QA_fetch_get_future_transaction_realtime(package, code):
311    """
312    期货实时tick
313    """
314    Engine = use(package)
315    if package in ['tdx', 'pytdx']:
316        return Engine.QA_fetch_get_future_transaction_realtime(code)
317    else:
318        return 'Unsupport packages'
319
320
321def QA_fetch_get_future_domain():
322    return QAKQ.QA_fetch_get_future_domain()
323
324def QA_fetch_get_future_realtime(package, code):
325    Engine = use(package)
326    return Engine.QA_fetch_get_future_realtime(code)
327
328
329def QA_fetch_get_future_day(package, code, start, end, frequence='day'):
330    Engine = use(package)
331    if package in ['tdx', 'pytdx']:
332        return Engine.QA_fetch_get_future_day(code, start, end, frequence=frequence)
333    else:
334        return 'Unsupport packages'
335
336
337def QA_fetch_get_future_min(package, code, start, end, frequence='1min'):
338    Engine = use(package)
339    if package in ['tdx', 'pytdx']:
340        return Engine.QA_fetch_get_future_min(code, start, end, frequence=frequence)
341    else:
342        return 'Unsupport packages'
343
344
345def QA_fetch_get_chibor(package, frequence):
346    Engine = use(package)
347    if package in ['Hexun', 'hexun']:
348        return Engine.QA_fetch_get_chibor(frequence)
349    else:
350        return 'Unsupport packages'
351
352
353QA_fetch_get_option_day = QA_fetch_get_future_day
354QA_fetch_get_option_min = QA_fetch_get_future_min
355
356QA_fetch_get_hkstock_day = QA_fetch_get_future_day
357QA_fetch_get_hkstock_min = QA_fetch_get_future_min
358
359QA_fetch_get_hkfund_day = QA_fetch_get_future_day
360QA_fetch_get_hkfund_min = QA_fetch_get_future_min
361
362QA_fetch_get_hkindex_day = QA_fetch_get_future_day
363QA_fetch_get_hkindex_min = QA_fetch_get_future_min
364
365
366QA_fetch_get_usstock_day = QA_fetch_get_future_day
367QA_fetch_get_usstock_min = QA_fetch_get_future_min
368
369QA_fetch_get_option_day = QA_fetch_get_future_day
370QA_fetch_get_option_min = QA_fetch_get_future_min
371
372QA_fetch_get_globalfuture_day = QA_fetch_get_future_day
373QA_fetch_get_globalfuture_min = QA_fetch_get_future_min
374
375QA_fetch_get_exchangerate_day = QA_fetch_get_future_day
376QA_fetch_get_exchangerate_min = QA_fetch_get_future_min
377
378
379QA_fetch_get_macroindex_day = QA_fetch_get_future_day
380QA_fetch_get_macroindex_min = QA_fetch_get_future_min
381
382
383QA_fetch_get_globalindex_day = QA_fetch_get_future_day
384QA_fetch_get_globalindex_min = QA_fetch_get_future_min
385
Full Screen

edgetest.py

Source: edgetest.py Github

copy
1# stdlib
2import urlparse
3import hashlib
4import logging
5
6# local
7import const
8
9# external
10import requests
11from requests.packages.urllib3.exceptions import InsecureRequestWarning
12
13# Make requests stop logging so much. I love you but you need to shut
14# up.
15requests_log = logging.getLogger("requests")
16requests_log.setLevel(logging.WARNING)
17# Disable warning when making non-verified HTTPS requests
18requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
19
20USER_AGENT = "Edgemanage v2 (https://github.com/equalitie/edgemanage)"
21
22
23class FetchFailed(Exception):
24    def __init__(self, edgetest, fetch_host, fetch_object, reason):
25        message = "Failed to fetch %s/%s from %s: %s" % (fetch_host, fetch_object,
26                                                         edgetest.edgename, reason)
27        super(FetchFailed, self).__init__(message)
28
29        self.edgename = edgetest.edgename
30        self.local_sum = edgetest.local_sum
31        self.fetch_host = fetch_host
32        self.fetch_object = fetch_object
33
34
35class VerifyFailed(Exception):
36    def __init__(self, edgetest, fetch_host, fetch_object, reason):
37        message = "Failed to verify %s/%s from %s: %s != %s" % (
38            fetch_host, fetch_object, edgetest.edgename,
39            edgetest.local_sum, reason)
40        super(VerifyFailed, self).__init__(message)
41
42        self.edgename = edgetest.edgename
43        self.local_sum = edgetest.local_sum
44        self.fetch_host = fetch_host
45        self.fetch_object = fetch_object
46
47
48class EdgeTest(object):
49
50    def __init__(self, edgename, local_sum):
51        """
52         edgename: FQDN string of the edge to be tested
53         local_sum: the pre-computed known checksum of the object to be fetched
54        """
55
56        self.edgename = edgename
57        self.local_sum = local_sum
58
59    def make_request(self, fetch_host, fetch_object, proto, port, verify):
60        request_url = urlparse.urljoin(proto + "://" + self.edgename + ":" + str(port),
61                                       fetch_object)
62        return requests.get(request_url, verify=verify, timeout=const.FETCH_TIMEOUT,
63                            headers={"Host": fetch_host, "User-Agent": USER_AGENT})
64        pass
65
66    def fetch(self, fetch_host, fetch_object, proto="https", port=80, verify=False):
67        """
68         fetch_host: The Host header to use when fetching
69         fetch_object: The path to the object to be fetched
70        """
71        try:
72            response = self.make_request(fetch_host, fetch_object, proto, port, verify)
73        except requests.exceptions.Timeout as e:
74            # Just assume it took the maximum amount of time
75            return const.FETCH_TIMEOUT
76        except requests.exceptions.ConnectionError as e:
77            logging.error("Connection error when fetching from %s: %s", self.edgename, str(e))
78            for i in range(const.FETCH_RETRY-1):
79                logging.warning("Retrying connection to %s", self.edgename)
80                try:
81                    response = self.make_request(fetch_host, fetch_object, proto, port, verify)
82                    # Request was successful, stop retrying and
83                    # continue
84                    break
85                except requests.exceptions.ConnectionError as e:
86                    continue
87            else:
88                logging.error("Failed to connect to %s after retrying %d times",
89                              self.edgename, const.FETCH_RETRY)
90                # The loop finished without a break - we got more
91                # connection errors. Let's bail and return the maximum
92                # amount of time. for/else is weird.
93                return const.FETCH_TIMEOUT
94
95        if not response.ok:
96            logging.error("Object fetch failed on %s:%s", self.edgename, port)
97            raise FetchFailed(self, fetch_host, fetch_object, response.text)
98
99        remote_hash = hashlib.md5(response.content).hexdigest()
100
101        if remote_hash != self.local_sum:
102            logging.error("Failed to verify hash on %s!!", self.edgename)
103            raise VerifyFailed(self, fetch_host, fetch_object, remote_hash)
104
105        return response.elapsed.total_seconds()
106
Full Screen

employee.actions.js

Source: employee.actions.js Github

copy
1const EmployeeActionTypes = {
2  // For fetching single employee by id
3  FETCH_EMPLOYEE_START: 'FETCH_EMPLOYEE_START',
4  FETCH_EMPLOYEE_SUCCESS: 'FETCH_EMPLOYEE_SUCCESS',
5  FETCH_EMPLOYEE_FAILURE: 'FETCH_EMPLOYEE_FAILURE',
6  // For fetching latest employee
7  FETCH_NEWLY_HIRED_EMPLOYEE_START: 'FETCH_NEWLY_HIRED_EMPLOYEE_START',
8  FETCH_NEWLY_HIRED_EMPLOYEE_SUCCESS: 'FETCH_NEWLY_HIRED_EMPLOYEE_SUCCESS',
9  FETCH_NEWLY_HIRED_EMPLOYEE_FAILURE: 'FETCH_NEWLY_HIRED_EMPLOYEE_FAILURE',
10  // For searching
11  FETCH_EMPLOYEES_BY_KEYWORD_START: 'FETCH_EMPLOYEES_BY_KEYWORD_START',
12  FETCH_EMPLOYEES_BY_KEYWORD_SUCCESS: 'FETCH_EMPLOYEES_BY_KEYWORD_SUCCESS',
13  FETCH_EMPLOYEES_BY_KEYWORD_FALURE: 'FETCH_EMPLOYEES_BY_KEYWORD_FALURE',
14  FETCH_EMPLOYEES_BY_KEYWORD_CANCELLED: 'FETCH_EMPLOYEES_BY_KEYWORD_CANCELLED',
15  // For pagination
16  FETCH_INITIAL_PAGE_EMPLOYEES_START: 'FETCH_INITIAL_PAGE_EMPLOYEES_START',
17  FETCH_INITIAL_PAGE_EMPLOYEES_SUCCESS: 'FETCH_INITIAL_PAGE_EMPLOYEES_SUCCESS',
18  FETCH_PREVIOUS_PAGE_EMPLOYEES_START: 'FETCH_PREVIOUS_PAGE_EMPLOYEES_START',
19  FETCH_PREVIOUS_PAGE_EMPLOYEES_SUCCESS: 'FETCH_PREVIOUS_PAGE_EMPLOYEES_SUCCESS',
20  FETCH_NEXT_PAGE_EMPLOYEES_START: 'FETCH_NEXT_PAGE_EMPLOYEES_START',
21  FETCH_NEXT_PAGE_EMPLOYEES_SUCCESS: 'FETCH_NEXT_PAGE_EMPLOYEES_SUCCESS',
22  FETCH_PAGE_EMPLOYEES_FAILURE: 'FETCH_PAGE_EMPLOYEES_FAILURE'
23};
24
25const fetchEmployeeStart = (id) => ({
26  type: EmployeeActionTypes.FETCH_EMPLOYEE_START,
27  payload: id
28});
29
30const fetchNewlyHiredEmployeeStart = () => ({
31  type: EmployeeActionTypes.FETCH_NEWLY_HIRED_EMPLOYEE_START
32});
33
34const fetchEmployeesByKeywordStart = (keyword, pageKey, isActive, sortBy) => ({
35  type: EmployeeActionTypes.FETCH_EMPLOYEES_BY_KEYWORD_START,
36  payload: { keyword, pageKey, isActive, sortBy }
37});
38
39const fetchInitialPageEmployeesStart = (pageKey, isActive, sortBy) => ({
40  type: EmployeeActionTypes.FETCH_INITIAL_PAGE_EMPLOYEES_START,
41  payload: { pageKey, isActive, sortBy }
42});
43
44const fetchPreviousPageEmployeesStart = (pageKey, isActive, sortBy) => ({
45  type: EmployeeActionTypes.FETCH_PREVIOUS_PAGE_EMPLOYEES_START,
46  payload: { pageKey, isActive, sortBy }
47});
48
49const fetchNextPageEmployeesStart = (pageKey, isActive, sortBy) => ({
50  type: EmployeeActionTypes.FETCH_NEXT_PAGE_EMPLOYEES_START,
51  payload: { pageKey, isActive, sortBy }
52});
53
54const fetchEmployeeSuccess = (employee) => ({
55  type: EmployeeActionTypes.FETCH_EMPLOYEE_SUCCESS,
56  payload: employee
57});
58
59const fetchNewlyHiredEmployeeSuccess = (employee) => ({
60  type: EmployeeActionTypes.FETCH_NEWLY_HIRED_EMPLOYEE_SUCCESS,
61  payload: employee
62});
63
64const fetchEmployeesByKeywordSuccess = (employees) => ({
65  type: EmployeeActionTypes.FETCH_EMPLOYEES_BY_KEYWORD_SUCCESS,
66  payload: employees
67});
68
69const fetchInitialPageEmployeesSuccess = (employees, collectionSize) => ({
70  type: EmployeeActionTypes.FETCH_INITIAL_PAGE_EMPLOYEES_SUCCESS,
71  payload: { employees, collectionSize }
72});
73
74const fetchPreviousPageEmployeesSuccess = (employees, pageIndex) => ({
75  type: EmployeeActionTypes.FETCH_PREVIOUS_PAGE_EMPLOYEES_SUCCESS,
76  payload: { employees, pageIndex }
77});
78
79const fetchNextPageEmployeesSuccess = (employees, pageIndex) => ({
80  type: EmployeeActionTypes.FETCH_NEXT_PAGE_EMPLOYEES_SUCCESS,
81  payload: { employees, pageIndex }
82});
83
84const fetchEmployeeFailure = () => ({
85  type: EmployeeActionTypes.FETCH_EMPLOYEE_FAILURE
86});
87
88const fetchNewlyHiredEmployeeFailure = () => ({
89  type: EmployeeActionTypes.FETCH_NEWLY_HIRED_EMPLOYEE_FAILURE
90});
91
92const fetchEmployeesByKeywordFailure = () => ({
93  type: EmployeeActionTypes.FETCH_EMPLOYEES_BY_KEYWORD_FALURE
94});
95
96const fetchEmployeesByKeywordCancelled = () => ({
97  type: EmployeeActionTypes.FETCH_EMPLOYEES_BY_KEYWORD_CANCELLED
98});
99
100const fetchPageEmployeesFailure = () => ({
101  type: EmployeeActionTypes.FETCH_PAGE_EMPLOYEES_FAILURE
102});
103
104export {
105  EmployeeActionTypes,
106  fetchEmployeeStart,
107  fetchNewlyHiredEmployeeStart,
108  fetchEmployeesByKeywordStart,
109  fetchInitialPageEmployeesStart,
110  fetchPreviousPageEmployeesStart,
111  fetchNextPageEmployeesStart,
112  fetchEmployeeSuccess,
113  fetchNewlyHiredEmployeeSuccess,
114  fetchEmployeesByKeywordSuccess,
115  fetchInitialPageEmployeesSuccess,
116  fetchPreviousPageEmployeesSuccess,
117  fetchNextPageEmployeesSuccess,
118  fetchEmployeeFailure,
119  fetchNewlyHiredEmployeeFailure,
120  fetchEmployeesByKeywordFailure,
121  fetchEmployeesByKeywordCancelled,
122  fetchPageEmployeesFailure
123};
124
Full Screen

actionTypes.js

Source: actionTypes.js Github

copy
1// Fetch data
2
3// Races
4export const FETCH_RACES_REQUEST = 'FETCH_RACES_REQUEST';
5export const FETCH_RACES_SUCCESS = 'FETCH_RACES_SUCCESS';
6export const FETCH_RACES_ERROR = 'FETCH_RACES_ERROR';
7
8// Classes
9export const FETCH_CLASSES_REQUEST = 'FETCH_CLASSES_REQUEST';
10export const FETCH_CLASSES_SUCCESS = 'FETCH_CLASSES_SUCCESS';
11export const FETCH_CLASSES_ERROR = 'FETCH_CLASSES_ERROR';
12
13// Realms
14export const FETCH_REALMS_REQUEST = 'FETCH_REALMS_REQUEST';
15export const FETCH_REALMS_SUCCESS = 'FETCH_REALMS_SUCCESS';
16export const FETCH_REALMS_ERROR = 'FETCH_REALMS_ERROR';
17
18// Talents
19export const FETCH_TALENTS_REQUEST = 'FETCH_TALENTS_REQUEST';
20export const FETCH_TALENTS_SUCCESS = 'FETCH_TALENTS_SUCCESS';
21export const FETCH_TALENTS_ERROR = 'FETCH_TALENTS_ERROR';
22
23// Item Types
24export const FETCH_ITEM_TYPES_REQUEST = 'FETCH_ITEM_TYPES_REQUEST';
25export const FETCH_ITEM_TYPES_SUCCESS = 'FETCH_ITEM_TYPES_SUCCESS';
26export const FETCH_ITEM_TYPES_ERROR = 'FETCH_ITEM_TYPES_ERROR';
27
28// Character related
29export const FETCH_CHARACTER_REQUEST = 'FETCH_CHARACTER_REQUEST';
30export const FETCH_CHARACTER_SUCCESS = 'FETCH_CHARACTER_SUCCESS';
31export const FETCH_CHARACTER_ERROR = 'FETCH_CHARACTER_ERROR';
32
33export const SWITCH_CHARACTER = 'SWITCH_CHARACTER';
34export const MOVE_CHARACTER = 'MOVE_CHARACTER';
35export const REMOVE_CHARACTER = 'REMOVE_CHARACTER';
36
37// ITEMS
38export const FETCH_ITEM_REQUEST = 'FETCH_ITEM_REQUEST';
39export const FETCH_ITEM_SUCCESS = 'FETCH_ITEM_SUCCESS';
40export const FETCH_ITEM_FAILURE = 'FETCH_ITEM_FAILURE';
41export const FETCH_INFO_ITEM_REQUEST = 'FETCH_INFO_ITEM_REQUEST';
42export const FETCH_INFO_ITEM_SUCCESS = 'FETCH_INFO_ITEM_SUCCESS';
43export const FETCH_INFO_ITEM_FAILURE = 'FETCH_INFO_ITEM_FAILURE';
44export const FETCH_ITEMSET_ITEM_REQUEST = 'FETCH_ITEMSET_ITEM_REQUEST';
45export const FETCH_ITEMSET_ITEM_SUCCESS = 'FETCH_ITEMSET_ITEM_SUCCESS';
46export const FETCH_ITEMSET_ITEM_FAILURE = 'FETCH_ITEMSET_ITEM_FAILURE';
47export const UPDATE_ITEMSET_ITEM = 'UPDATE_ITEMSET_ITEM';
48export const FETCH_TRANSMOG_ITEM_REQUEST = 'FETCH_TRANSMOG_ITEM_REQUEST';
49export const FETCH_TRANSMOG_ITEM_SUCCESS = 'FETCH_TRANSMOG_ITEM_SUCCESS';
50export const FETCH_TRANSMOG_ITEM_FAILURE = 'FETCH_TRANSMOG_ITEM_FAILURE';
51export const UNSELECT_ITEM = 'UNSELECT_ITEM';
52
Full Screen

commonStoreForAll-VX.js

Source: commonStoreForAll-VX.js Github

copy
1(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["commonStoreForAll-VX"],{
2
3/***/ "./resources/js/store/commonStoreForAll.js":
4/*!*************************************************!*\
5  !*** ./resources/js/store/commonStoreForAll.js ***!
6  \*************************************************/
7/*! exports provided: default */
8/***/ (function(module, __webpack_exports__, __webpack_require__) {
9
10"use strict";
11__webpack_require__.r(__webpack_exports__);
12var commonStoreForAll = {
13  namespaced: true,
14  state: function state() {
15    return {
16      //accessable from any where 
17      authUser: {},
18      authPermissions: {},
19      systemSettings: {},
20      adminRoles: {},
21      branches: {},
22      chartOfAccountHeads: {},
23      allLanguages: {},
24      allCurrencies: {},
25      allDepertments: {},
26      autoSearchDepartments: {},
27      userStatus: {},
28      //get data from user_status table
29      AllStatus: {},
30      //get status for order, payment, purchase, porduct
31      jobTitles: {},
32      Countries: {},
33      Divisions: {},
34      Districts: {},
35      Dist_Zones: {},
36      AllAttributes: {},
37      AllAttributeValues: {},
38      AllBrands: {},
39      allBrandShops: {},
40      AllCategory: {},
41      autoSearchCategories: {},
42      autoSearchSuppliers: {},
43      AllSpecifications: {},
44      allCustomerGroups: {},
45      allCustomerMemberships: {},
46      allUnits: {}
47    };
48  },
49
50  /*end state*/
51  getters: {//userStatus: state => { return state.userStatus },
52  },
53
54  /*end getters*/
55  mutations: {
56    //commit from resources/js/components/admin/AdminWrapper.vue
57    AUTH_USER: function AUTH_USER(state, data) {
58      return state.authUser = data;
59    },
60    AUTH_PERMISSIONS: function AUTH_PERMISSIONS(state, data) {
61      return state.authPermissions = data;
62    },
63    SYSTEM_SETTINGS: function SYSTEM_SETTINGS(state, data) {
64      return state.systemSettings = data;
65    },
66    //End Commit
67    //get from action
68    FETCH_ROLES: function FETCH_ROLES(state, data) {
69      return state.adminRoles = data;
70    },
71    FETCH_BRANCHES: function FETCH_BRANCHES(state, data) {
72      return state.branches = data;
73    },
74    FETCH_CHART_OF_ACCOUNT_HEADS: function FETCH_CHART_OF_ACCOUNT_HEADS(state, data) {
75      return state.chartOfAccountHeads = data;
76    },
77    FETCH_LANGUAGES: function FETCH_LANGUAGES(state, data) {
78      return state.allLanguages = data;
79    },
80    FETCH_CURRENCIES: function FETCH_CURRENCIES(state, data) {
81      return state.allCurrencies = data;
82    },
83    FETCH_DEPARTMENTS: function FETCH_DEPARTMENTS(state, data) {
84      return state.allDepertments = data;
85    },
86    FETCH_JOB_TITLE: function FETCH_JOB_TITLE(state, data) {
87      return state.jobTitles = data;
88    },
89    FETCH_USER_STATUS: function FETCH_USER_STATUS(state, data) {
90      return state.userStatus = data;
91    },
92    FETCH_ALL_STATUS: function FETCH_ALL_STATUS(state, data) {
93      return state.AllStatus = data;
94    },
95    FETCH_COUNTRY_DATA: function FETCH_COUNTRY_DATA(state, Countries) {
96      return state.Countries = Countries;
97    },
98    FETCH_DIVISION_DATA: function FETCH_DIVISION_DATA(state, Divisions) {
99      return state.Divisions = Divisions;
100    },
101    FETCH_DISTRICT_DATA: function FETCH_DISTRICT_DATA(state, Districts) {
102      return state.Districts = Districts;
103    },
104    FETCH_DISTRICT_ZONE_DATA: function FETCH_DISTRICT_ZONE_DATA(state, Dist_Zones) {
105      return state.Dist_Zones = Dist_Zones;
106    },
107    FETCH_ATTRIBUTE_DATA: function FETCH_ATTRIBUTE_DATA(state, data) {
108      return state.AllAttributes = data;
109    },
110    FETCH_ATTRIBUTE_VALUE_DATA: function FETCH_ATTRIBUTE_VALUE_DATA(state, data) {
111      return state.AllAttributeValues = data;
112    },
113    FETCH_BRAND_DATA: function FETCH_BRAND_DATA(state, data) {
114      return state.AllBrands = data;
115    },
116    FETCH_BRAND_SHOP_DATA: function FETCH_BRAND_SHOP_DATA(state, data) {
117      return state.allBrandShops = data;
118    },
119    FETCH_CATEGORY_DATA: function FETCH_CATEGORY_DATA(state, data) {
120      return state.AllCategory = data;
121    },
122    FETCH_SPECIFICATION_DATA: function FETCH_SPECIFICATION_DATA(state, data) {
123      return state.AllSpecifications = data;
124    },
125    FETCH_CUSTOMER_GROUPS_DATA: function FETCH_CUSTOMER_GROUPS_DATA(state, data) {
126      return state.allCustomerGroups = data;
127    },
128    FETCH_CUSTOMER_MEMBERSHIP_DATA: function FETCH_CUSTOMER_MEMBERSHIP_DATA(state, data) {
129      return state.allCustomerMemberships = data;
130    },
131    FETCH_UNITS_DATA: function FETCH_UNITS_DATA(state, data) {
132      return state.allUnits = data;
133    },
134    //#####################################Search ###########################################
135    AUTO_COMPLETE_DATA_FOR_DEPARTMENTS: function AUTO_COMPLETE_DATA_FOR_DEPARTMENTS(state, data) {
136      return state.autoSearchDepartments = data;
137    },
138    AUTO_COMPLETE_DATA_FOR_CATEGORIES: function AUTO_COMPLETE_DATA_FOR_CATEGORIES(state, data) {
139      return state.autoSearchCategories = data;
140    },
141    AUTO_COMPLETE_DATA_FOR_SUPPLIERS: function AUTO_COMPLETE_DATA_FOR_SUPPLIERS(state, data) {
142      return state.autoSearchSuppliers = data;
143    }
144  },
145
146  /*end Mutations*/
147  actions: {
148    userStatus: function userStatus(context) {
149      axios.get('/spa/user-status-info').then(function (response) {
150        context.commit('FETCH_USER_STATUS', response.data);
151      })["catch"](function () {});
152    },
153    AllStatus: function AllStatus(context, payload) {
154      var query = payload;
155      axios.get('/spa/StatusMaster-Info/getAllStatus?&q=' + query).then(function (response) {
156        context.commit('FETCH_ALL_STATUS', response.data);
157      })["catch"](function () {});
158    },
159    fetchJobTitles: function fetchJobTitles(context) {
160      axios.get('/spa/JobTitle-Info/GetJobTitles').then(function (response) {
161        context.commit('FETCH_JOB_TITLE', response.data); //use for only show data
162      })["catch"](function () {});
163    },
164    fetchRoles: function fetchRoles(context) {
165      //return role 1 to 6
166      axios.get('/spa/Role-Info/GetRoles').then(function (response) {
167        context.commit('FETCH_ROLES', response.data); //use for only show data
168      })["catch"](function () {});
169    },
170    fetchBranches: function fetchBranches(context) {
171      axios.get('/spa/Branch-Info/getBranches').then(function (response) {
172        context.commit('FETCH_BRANCHES', response.data); //use for only show data
173      })["catch"](function () {});
174    },
175    fetchChartOfAccountHeads: function fetchChartOfAccountHeads(context) {
176      axios.get('/spa/AccountHeads-Info/getChartOfAccountHeads').then(function (response) {
177        context.commit('FETCH_CHART_OF_ACCOUNT_HEADS', response.data); //use for only show data
178      })["catch"](function () {});
179    },
180    fetchLanguages: function fetchLanguages(context) {
181      axios.get('/spa/Language-Info/getLanguages').then(function (response) {
182        context.commit('FETCH_LANGUAGES', response.data); //use for only show data
183      })["catch"](function () {});
184    },
185    fetchCurrencies: function fetchCurrencies(context) {
186      axios.get('/spa/Currency-Info/getCurrencies').then(function (response) {
187        context.commit('FETCH_CURRENCIES', response.data); //use for only show data
188      })["catch"](function () {});
189    },
190    fetchDepartments: function fetchDepartments(context) {
191      axios.get('/spa/Department-Info/getDetartments').then(function (response) {
192        context.commit('FETCH_DEPARTMENTS', response.data); //use for only show data
193      })["catch"](function () {});
194    },
195    fetchCountryList: function fetchCountryList(context) {
196      axios.get('/spa/Country-Info/GetCountry').then(function (response) {
197        context.commit('FETCH_COUNTRY_DATA', response.data); //use for only show data
198      })["catch"](function () {});
199    },
200    // fetchDivisionList(context){
201    //   axios.get('/spa/Division-Info/GetDivision')
202    //   .then( (response) => {
203    //     context.commit('FETCH_DIVISION_DATA', response.data); //use for only show data
204    //   }).catch( () => { })
205    // },
206    fetchDivisionList: function fetchDivisionList(context, payload) {
207      axios.get('/spa/Division-Info/GetDivision?&id=' + payload).then(function (response) {
208        context.commit('FETCH_DIVISION_DATA', response.data); //use for only show data
209      })["catch"](function () {});
210    },
211    fetchDistrictList: function fetchDistrictList(context, payload) {
212      axios.get('/spa/District-Info/GetDistrict?&id=' + payload).then(function (response) {
213        context.commit('FETCH_DISTRICT_DATA', response.data); //use for only show data
214      })["catch"](function () {});
215    },
216    fetchDistrictZoneList: function fetchDistrictZoneList(context, payload) {
217      axios.get('/spa/DistrictZone-Info/GetDistrictZone?&id=' + payload).then(function (response) {
218        context.commit('FETCH_DISTRICT_ZONE_DATA', response.data); //use for only show data
219      })["catch"](function () {});
220    },
221    fetchAttributeList: function fetchAttributeList(context) {
222      axios.get('/spa/Attribute-Info/GetAttributes').then(function (response) {
223        context.commit('FETCH_ATTRIBUTE_DATA', response.data);
224      })["catch"](function () {});
225    },
226    fetchAttributeValue: function fetchAttributeValue(context, payload) {
227      var query = payload;
228      axios.get('/spa/AttributeValue-Info/GetAttributeValue?&q=' + query).then(function (response) {
229        context.commit('FETCH_ATTRIBUTE_VALUE_DATA', response.data);
230      })["catch"](function () {});
231    },
232    fetchBrands: function fetchBrands(context) {
233      axios.get('/spa/Brand-Info/getBrands').then(function (response) {
234        context.commit('FETCH_BRAND_DATA', response.data);
235      })["catch"](function () {});
236    },
237    fetchBrandShops: function fetchBrandShops(context) {
238      axios.get('/spa/BrandShop-Info/getBrandShops').then(function (response) {
239        context.commit('FETCH_BRAND_SHOP_DATA', response.data);
240      })["catch"](function () {});
241    },
242    fetchCategory: function fetchCategory(context) {
243      axios.get('/spa/CategoryMaster-Info/getCategory').then(function (response) {
244        context.commit('FETCH_CATEGORY_DATA', response.data); //use for only show data
245      })["catch"](function () {});
246    },
247    fetchSpecifications: function fetchSpecifications(context) {
248      axios.get('/spa/Specification-Info/getSpecification').then(function (response) {
249        context.commit('FETCH_SPECIFICATION_DATA', response.data);
250      })["catch"](function () {});
251    },
252    fetchCustomerGroups: function fetchCustomerGroups(context) {
253      axios.get('/spa/customerGroup-Info/getCustomerGroup').then(function (response) {
254        context.commit('FETCH_CUSTOMER_GROUPS_DATA', response.data);
255      })["catch"](function () {});
256    },
257    fetchCustomerMemberships: function fetchCustomerMemberships(context) {
258      axios.get('/spa/customerMembership-Info/getCustomerMembership').then(function (response) {
259        context.commit('FETCH_CUSTOMER_MEMBERSHIP_DATA', response.data);
260      })["catch"](function () {});
261    },
262    fetchUnits: function fetchUnits(context) {
263      axios.get('/spa/UnitsMaster-Info/getAllUnits').then(function (response) {
264        context.commit('FETCH_UNITS_DATA', response.data);
265      })["catch"](function () {});
266    },
267    //############################################# Search ############################################
268    AutoCompleteSearchForDepartment: function AutoCompleteSearchForDepartment(context, payload) {
269      var query = payload;
270      axios.get('/spa/searchDepartmentData?&q=' + query).then(function (response) {
271        context.commit('AUTO_COMPLETE_DATA_FOR_DEPARTMENTS', response.data);
272      })["catch"](function () {});
273    },
274    AutoCompleteSearchForCategory: function AutoCompleteSearchForCategory(context, payload) {
275      var query = payload;
276      axios.get('/spa/AutoCompleteCategoryData?&q=' + query).then(function (response) {
277        context.commit('AUTO_COMPLETE_DATA_FOR_CATEGORIES', response.data);
278      })["catch"](function () {});
279    },
280    AutoCompleteSearchForSuppliers: function AutoCompleteSearchForSuppliers(context, payload) {
281      var query = payload;
282      axios.get('/spa/AutoCompleteSupplierData?&q=' + query).then(function (response) {
283        context.commit('AUTO_COMPLETE_DATA_FOR_SUPPLIERS', response.data);
284      })["catch"](function () {});
285    }
286  }
287  /*end actions*/
288
289};
290/* harmony default export */ __webpack_exports__["default"] = (commonStoreForAll);
291
292/***/ })
293
294}]);
Full Screen

Fetch.js

Source: Fetch.js Github

copy
1var Fetch = {
2  attr_t_offset_requestMethod: 0,
3  attr_t_offset_userData: 32,
4  attr_t_offset_onsuccess: 36,
5  attr_t_offset_onerror: 40,
6  attr_t_offset_onprogress: 44,
7  attr_t_offset_attributes: 48,
8  attr_t_offset_timeoutMSecs: 52,
9  attr_t_offset_withCredentials: 56,
10  attr_t_offset_destinationPath: 60,
11  attr_t_offset_userName: 64,
12  attr_t_offset_password: 68,
13  attr_t_offset_requestHeaders: 72,
14  attr_t_offset_overriddenMimeType: 76,
15  attr_t_offset_requestData: 80,
16  attr_t_offset_requestDataSize: 84,
17
18  fetch_t_offset_id: 0,
19  fetch_t_offset_userData: 4,
20  fetch_t_offset_url: 8,
21  fetch_t_offset_data: 12,
22  fetch_t_offset_numBytes: 16,
23  fetch_t_offset_dataOffset: 24,
24  fetch_t_offset_totalBytes: 32,
25  fetch_t_offset_readyState: 40,
26  fetch_t_offset_status: 42,
27  fetch_t_offset_statusText: 44,
28  fetch_t_offset___proxyState: 108,
29  fetch_t_offset___attributes: 112,
30
31  xhrs: [],
32  // The web worker that runs proxied file I/O requests.
33  worker: undefined,
34  // Specifies an instance to the IndexedDB database. The database is opened
35  // as a preload step before the Emscripten application starts.
36  dbInstance: undefined,
37
38  setu64: function(addr, val) {
39    HEAPU32[addr >> 2] = val;
40    HEAPU32[addr + 4 >> 2] = (val / 4294967296)|0;
41  },
42
43  openDatabase: function(dbname, dbversion, onsuccess, onerror) {
44    try {
45#if FETCH_DEBUG
46      console.log('fetch: indexedDB.open(dbname="' + dbname + '", dbversion="' + dbversion + '");');
47#endif
48      var openRequest = indexedDB.open(dbname, dbversion);
49    } catch (e) { return onerror(e); }
50
51    openRequest.onupgradeneeded = function(event) {
52#if FETCH_DEBUG
53      console.log('fetch: IndexedDB upgrade needed. Clearing database.');
54#endif
55      var db = event.target.result;
56      if (db.objectStoreNames.contains('FILES')) {
57        db.deleteObjectStore('FILES');
58      }
59      db.createObjectStore('FILES');
60    };
61    openRequest.onsuccess = function(event) { onsuccess(event.target.result); };
62    openRequest.onerror = function(error) { onerror(error); };
63  },
64
65  initFetchWorker: function() {
66    var stackSize = 128*1024;
67    var stack = allocate(stackSize>>2, "i32*", ALLOC_DYNAMIC);
68    Fetch.worker.postMessage({cmd: 'init', TOTAL_MEMORY: TOTAL_MEMORY, DYNAMICTOP_PTR: DYNAMICTOP_PTR, STACKTOP: stack, STACK_MAX: stack + stackSize, queuePtr: _fetch_work_queue, buffer: HEAPU8.buffer}, [HEAPU8.buffer]);
69  },
70
71  staticInit: function() {
72#if USE_PTHREADS
73    var isMainThread = (typeof ENVIRONMENT_IS_FETCH_WORKER === 'undefined' && !ENVIRONMENT_IS_PTHREAD);
74#else
75    var isMainThread = (typeof ENVIRONMENT_IS_FETCH_WORKER === 'undefined');
76#endif
77
78    var onsuccess = function(db) {
79#if FETCH_DEBUG
80      console.log('fetch: IndexedDB successfully opened.');
81#endif
82      Fetch.dbInstance = db;
83
84#if USE_PTHREADS
85      if (isMainThread) {
86        if (typeof SharedArrayBuffer !== 'undefined') Fetch.initFetchWorker();
87        removeRunDependency('library_fetch_init');
88      }
89#else
90      if (typeof ENVIRONMENT_IS_FETCH_WORKER === 'undefined' || !ENVIRONMENT_IS_FETCH_WORKER) removeRunDependency('library_fetch_init');
91#endif
92    };
93    var onerror = function() {
94#if FETCH_DEBUG
95      console.error('fetch: IndexedDB open failed.');
96#endif
97      Fetch.dbInstance = false;
98
99#if USE_PTHREADS
100      if (isMainThread) {
101        if (typeof SharedArrayBuffer !== 'undefined') Fetch.initFetchWorker();
102        removeRunDependency('library_fetch_init');
103      }
104#endif
105    };
106    Fetch.openDatabase('emscripten_filesystem', 1, onsuccess, onerror);
107
108#if USE_PTHREADS
109    if (isMainThread) {
110      addRunDependency('library_fetch_init');
111
112      var fetchJs = 'fetch-worker.js';
113      // Allow HTML module to configure the location where the 'pthread-main.js' file will be loaded from,
114      // either via Module.locateFile() function, or via Module.pthreadMainPrefixURL string. If neither
115      // of these are passed, then the default URL 'pthread-main.js' relative to the main html file is loaded.
116      if (typeof Module['locateFile'] === 'function') fetchJs = Module['locateFile'](fetchJs);
117      else if (Module['pthreadMainPrefixURL']) fetchJs = Module['pthreadMainPrefixURL'] + fetchJs;
118      Fetch.worker = new Worker(fetchJs);
119      Fetch.worker.onmessage = function(e) {
120        Module['print']('fetch-worker sent a message: ' + e.filename + ':' + e.lineno + ': ' + e.message);
121      };
122      Fetch.worker.onerror = function(e) {
123        Module['printErr']('fetch-worker sent an error! ' + e.filename + ':' + e.lineno + ': ' + e.message);
124      };
125    }
126#else
127    if (typeof ENVIRONMENT_IS_FETCH_WORKER === 'undefined' || !ENVIRONMENT_IS_FETCH_WORKER) addRunDependency('library_fetch_init');
128#endif
129  }
130}
131
132function __emscripten_fetch_delete_cached_data(db, fetch, onsuccess, onerror) {
133  if (!db) {
134#if FETCH_DEBUG
135    console.error('fetch: IndexedDB not available!');
136#endif
137    onerror(fetch, 0, 'IndexedDB not available!');
138    return;
139  }
140
141  var fetch_attr = fetch + Fetch.fetch_t_offset___attributes;
142  var path = HEAPU32[fetch_attr + Fetch.attr_t_offset_destinationPath >> 2];
143  if (!path) path = HEAPU32[fetch + Fetch.fetch_t_offset_url >> 2];
144  var pathStr = Pointer_stringify(path);
145
146  try {
147    var transaction = db.transaction(['FILES'], 'readwrite');
148    var packages = transaction.objectStore('FILES');
149    var request = packages.delete(pathStr);
150    request.onsuccess = function(event) {
151      var value = event.target.result;
152#if FETCH_DEBUG
153      console.log('fetch: Deleted file ' + pathStr + ' from IndexedDB');
154#endif
155      HEAPU32[fetch + Fetch.fetch_t_offset_data >> 2] = 0;
156      Fetch.setu64(fetch + Fetch.fetch_t_offset_numBytes, 0);
157      Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, 0);
158      Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, 0);
159      HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
160      HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 200; // Mimic XHR HTTP status code 200 "OK"
161
162      onsuccess(fetch, 0, value);
163    };
164    request.onerror = function(error) {
165#if FETCH_DEBUG
166      console.error('fetch: Failed to delete file ' + pathStr + ' from IndexedDB! error: ' + error);
167#endif
168      HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
169      HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 404; // Mimic XHR HTTP status code 404 "Not Found"
170      onerror(fetch, 0, error);
171    };
172  } catch(e) {
173#if FETCH_DEBUG
174    console.error('fetch: Failed to load file ' + pathStr + ' from IndexedDB! Got exception ' + e);
175#endif
176    onerror(fetch, 0, e);
177  }
178}
179
180function __emscripten_fetch_load_cached_data(db, fetch, onsuccess, onerror) {
181  if (!db) {
182#if FETCH_DEBUG
183    console.error('fetch: IndexedDB not available!');
184#endif
185    onerror(fetch, 0, 'IndexedDB not available!');
186    return;
187  }
188
189  var fetch_attr = fetch + Fetch.fetch_t_offset___attributes;
190  var path = HEAPU32[fetch_attr + Fetch.attr_t_offset_destinationPath >> 2];
191  if (!path) path = HEAPU32[fetch + Fetch.fetch_t_offset_url >> 2];
192  var pathStr = Pointer_stringify(path);
193
194  try {
195    var transaction = db.transaction(['FILES'], 'readonly');
196    var packages = transaction.objectStore('FILES');
197    var getRequest = packages.get(pathStr);
198    getRequest.onsuccess = function(event) {
199      if (event.target.result) {
200        var value = event.target.result;
201        var len = value.byteLength || value.length;
202#if FETCH_DEBUG
203        console.log('fetch: Loaded file ' + pathStr + ' from IndexedDB, length: ' + len);
204#endif
205
206        // The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
207        // freed when emscripten_fetch_close() is called.
208        var ptr = _malloc(len);
209        HEAPU8.set(new Uint8Array(value), ptr);
210        HEAPU32[fetch + Fetch.fetch_t_offset_data >> 2] = ptr;
211        Fetch.setu64(fetch + Fetch.fetch_t_offset_numBytes, len);
212        Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, 0);
213        Fetch.setu64(fetch + Fetch.fetch_t_offset_totalBytes, len);
214        HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
215        HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 200; // Mimic XHR HTTP status code 200 "OK"
216
217        onsuccess(fetch, 0, value);
218      } else {
219        // Succeeded to load, but the load came back with the value of undefined, treat that as an error since we never store undefined in db.
220#if FETCH_DEBUG
221        console.error('fetch: File ' + pathStr + ' not found in IndexedDB');
222#endif
223        HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
224        HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 404; // Mimic XHR HTTP status code 404 "Not Found"
225        onerror(fetch, 0, 'no data');
226      }
227    };
228    getRequest.onerror = function(error) {
229#if FETCH_DEBUG
230      console.error('fetch: Failed to load file ' + pathStr + ' from IndexedDB!');
231#endif
232      HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
233      HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 404; // Mimic XHR HTTP status code 404 "Not Found"
234      onerror(fetch, 0, error);
235    };
236  } catch(e) {
237#if FETCH_DEBUG
238    console.error('fetch: Failed to load file ' + pathStr + ' from IndexedDB! Got exception ' + e);
239#endif
240    onerror(fetch, 0, e);
241  }
242}
243
244function __emscripten_fetch_cache_data(db, fetch, data, onsuccess, onerror) {
245  if (!db) {
246#if FETCH_DEBUG
247    console.error('fetch: IndexedDB not available!');
248#endif
249    onerror(fetch, 0, 'IndexedDB not available!');
250    return;
251  }
252
253  var fetch_attr = fetch + Fetch.fetch_t_offset___attributes;
254  var destinationPath = HEAPU32[fetch_attr + Fetch.attr_t_offset_destinationPath >> 2];
255  if (!destinationPath) destinationPath = HEAPU32[fetch + Fetch.fetch_t_offset_url >> 2];
256  var destinationPathStr = Pointer_stringify(destinationPath);
257
258  try {
259    var transaction = db.transaction(['FILES'], 'readwrite');
260    var packages = transaction.objectStore('FILES');
261    var putRequest = packages.put(data, destinationPathStr);
262    putRequest.onsuccess = function(event) {
263#if FETCH_DEBUG
264      console.log('fetch: Stored file "' + destinationPathStr + '" to IndexedDB cache.');
265#endif
266      HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
267      HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 200; // Mimic XHR HTTP status code 200 "OK"
268      onsuccess(fetch, 0, destinationPathStr);
269    };
270    putRequest.onerror = function(error) {
271#if FETCH_DEBUG
272      console.error('fetch: Failed to store file "' + destinationPathStr + '" to IndexedDB cache!');
273#endif
274      // Most likely we got an error if IndexedDB is unwilling to store any more data for this page.
275      // TODO: Can we identify and break down different IndexedDB-provided errors and convert those
276      // to more HTTP status codes for more information?
277      HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = 4; // Mimic XHR readyState 4 === 'DONE: The operation is complete'
278      HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = 413; // Mimic XHR HTTP status code 413 "Payload Too Large"
279      onerror(fetch, 0, error);
280    };
281  } catch(e) {
282#if FETCH_DEBUG
283      console.error('fetch: Failed to store file "' + destinationPathStr + '" to IndexedDB cache! Exception: ' + e);
284#endif
285    onerror(fetch, 0, e);
286  }
287}
288
289function __emscripten_fetch_xhr(fetch, onsuccess, onerror, onprogress) {
290  var url = HEAPU32[fetch + Fetch.fetch_t_offset_url >> 2];
291  if (!url) {
292#if FETCH_DEBUG
293    console.error('fetch: XHR failed, no URL specified!');
294#endif
295    onerror(fetch, 0, 'no url specified!');
296    return;
297  }
298  var url_ = Pointer_stringify(url);
299
300  var fetch_attr = fetch + Fetch.fetch_t_offset___attributes;
301  var requestMethod = Pointer_stringify(fetch_attr);
302  if (!requestMethod) requestMethod = 'GET';
303  var userData = HEAPU32[fetch_attr + Fetch.attr_t_offset_userData >> 2];
304  var fetchAttributes = HEAPU32[fetch_attr + Fetch.attr_t_offset_attributes >> 2];
305  var timeoutMsecs = HEAPU32[fetch_attr + Fetch.attr_t_offset_timeoutMSecs >> 2];
306  var withCredentials = !!HEAPU32[fetch_attr + Fetch.attr_t_offset_withCredentials >> 2];
307  var destinationPath = HEAPU32[fetch_attr + Fetch.attr_t_offset_destinationPath >> 2];
308  var userName = HEAPU32[fetch_attr + Fetch.attr_t_offset_userName >> 2];
309  var password = HEAPU32[fetch_attr + Fetch.attr_t_offset_password >> 2];
310  var requestHeaders = HEAPU32[fetch_attr + Fetch.attr_t_offset_requestHeaders >> 2];
311  var overriddenMimeType = HEAPU32[fetch_attr + Fetch.attr_t_offset_overriddenMimeType >> 2];
312
313  var fetchAttrLoadToMemory = !!(fetchAttributes & 1/*EMSCRIPTEN_FETCH_LOAD_TO_MEMORY*/);
314  var fetchAttrStreamData = !!(fetchAttributes & 2/*EMSCRIPTEN_FETCH_STREAM_DATA*/);
315  var fetchAttrPersistFile = !!(fetchAttributes & 4/*EMSCRIPTEN_FETCH_PERSIST_FILE*/);
316  var fetchAttrAppend = !!(fetchAttributes & 8/*EMSCRIPTEN_FETCH_APPEND*/);
317  var fetchAttrReplace = !!(fetchAttributes & 16/*EMSCRIPTEN_FETCH_REPLACE*/);
318  var fetchAttrNoDownload = !!(fetchAttributes & 32/*EMSCRIPTEN_FETCH_NO_DOWNLOAD*/);
319  var fetchAttrSynchronous = !!(fetchAttributes & 64/*EMSCRIPTEN_FETCH_SYNCHRONOUS*/);
320  var fetchAttrWaitable = !!(fetchAttributes & 128/*EMSCRIPTEN_FETCH_WAITABLE*/);
321
322  var userNameStr = userName ? Pointer_stringify(userName) : undefined;
323  var passwordStr = password ? Pointer_stringify(password) : undefined;
324  var overriddenMimeTypeStr = overriddenMimeType ? Pointer_stringify(overriddenMimeType) : undefined;
325
326  var xhr = new XMLHttpRequest();
327  xhr.withCredentials = withCredentials;
328#if FETCH_DEBUG
329  console.log('fetch: xhr.timeout: ' + xhr.timeout + ', xhr.withCredentials: ' + xhr.withCredentials);
330  console.log('fetch: xhr.open(requestMethod="' + requestMethod + '", url: "' + url_ +'", userName: ' + userNameStr + ', password: ' + passwordStr + ');');
331#endif
332  xhr.open(requestMethod, url_, !fetchAttrSynchronous, userNameStr, passwordStr);
333  if (!fetchAttrSynchronous) xhr.timeout = timeoutMsecs; // XHR timeout field is only accessible in async XHRs, and must be set after .open() but before .send().
334  xhr.url_ = url_; // Save the url for debugging purposes (and for comparing to the responseURL that server side advertised)
335  xhr.responseType = fetchAttrStreamData ? 'moz-chunked-arraybuffer' : 'arraybuffer';
336
337  if (overriddenMimeType) {
338#if FETCH_DEBUG
339    console.log('fetch: xhr.overrideMimeType("' + overriddenMimeTypeStr + '");');
340#endif
341    xhr.overrideMimeType(overriddenMimeTypeStr);
342  }
343  if (requestHeaders) {
344    for(;;) {
345      var key = HEAPU32[requestHeaders >> 2];
346      if (!key) break;
347      var value = HEAPU32[requestHeaders + 4 >> 2];
348      if (!value) break;
349      requestHeaders += 8;
350      var keyStr = Pointer_stringify(key);
351      var valueStr = Pointer_stringify(value);
352#if FETCH_DEBUG
353      console.log('fetch: xhr.setRequestHeader("' + keyStr + '", "' + valueStr + '");');
354#endif
355      xhr.setRequestHeader(keyStr, valueStr);
356    }
357  }
358  Fetch.xhrs.push(xhr);
359  var id = Fetch.xhrs.length;
360  HEAPU32[fetch + Fetch.fetch_t_offset_id >> 2] = id;
361  var data = null; // TODO: Support user to pass data to request.
362  // TODO: Support specifying custom headers to the request.
363
364  xhr.onload = function(e) {
365    var len = xhr.response ? xhr.response.byteLength : 0;
366    var ptr = 0;
367    var ptrLen = 0;
368    if (fetchAttrLoadToMemory && !fetchAttrStreamData) {
369      ptrLen = len;
370#if FETCH_DEBUG
371      console.log('fetch: allocating ' + ptrLen + ' bytes in Emscripten heap for xhr data');
372#endif
373      // The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
374      // freed when emscripten_fetch_close() is called.
375      ptr = _malloc(ptrLen);
376      HEAPU8.set(new Uint8Array(xhr.response), ptr);
377    }
378    HEAPU32[fetch + Fetch.fetch_t_offset_data >> 2] = ptr;
379    Fetch.setu64(fetch + Fetch.fetch_t_offset_numBytes, ptrLen);
380    Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, 0);
381    if (len) {
382      // If the final XHR.onload handler receives the bytedata to compute total length, report that,
383      // otherwise don't write anything out here, which will retain the latest byte size reported in
384      // the most recent XHR.onprogress handler.
385      Fetch.setu64(fetch + Fetch.fetch_t_offset_totalBytes, len);
386    }
387    HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = xhr.readyState;
388    if (xhr.readyState === 4 && xhr.status === 0) {
389      if (len > 0) xhr.status = 200; // If loading files from a source that does not give HTTP status code, assume success if we got data bytes.
390      else xhr.status = 404; // Conversely, no data bytes is 404.
391    }
392    HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = xhr.status;
393//    if (xhr.statusText) stringToUTF8(fetch + Fetch.fetch_t_offset_statusText, xhr.statusText, 64);
394    if (xhr.status == 200) {
395#if FETCH_DEBUG
396      console.log('fetch: xhr of URL "' + xhr.url_ + '" / responseURL "' + xhr.responseURL + '" succeeded with status 200');
397#endif
398      if (onsuccess) onsuccess(fetch, xhr, e);
399    } else {
400#if FETCH_DEBUG
401      console.error('fetch: xhr of URL "' + xhr.url_ + '" / responseURL "' + xhr.responseURL + '" failed with status ' + xhr.status);
402#endif
403      if (onerror) onerror(fetch, xhr, e);
404    }
405  }
406  xhr.onerror = function(e) {
407    var status = xhr.status; // XXX TODO: Overwriting xhr.status doesn't work here, so don't override anywhere else either.
408    if (xhr.readyState == 4 && status == 0) status = 404; // If no error recorded, pretend it was 404 Not Found.
409#if FETCH_DEBUG
410    console.error('fetch: xhr of URL "' + xhr.url_ + '" / responseURL "' + xhr.responseURL + '" finished with error, readyState ' + xhr.readyState + ' and status ' + status);
411#endif
412    HEAPU32[fetch + Fetch.fetch_t_offset_data >> 2] = 0;
413    Fetch.setu64(fetch + Fetch.fetch_t_offset_numBytes, 0);
414    Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, 0);
415    Fetch.setu64(fetch + Fetch.fetch_t_offset_totalBytes, 0);
416    HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = xhr.readyState;
417    HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = status;
418    if (onerror) onerror(fetch, xhr, e);
419  }
420  xhr.ontimeout = function(e) {
421#if FETCH_DEBUG
422    console.error('fetch: xhr of URL "' + xhr.url_ + '" / responseURL "' + xhr.responseURL + '" timed out, readyState ' + xhr.readyState + ' and status ' + xhr.status);
423#endif
424    if (onerror) onerror(fetch, xhr, e);
425  }
426  xhr.onprogress = function(e) {
427    var ptrLen = (fetchAttrLoadToMemory && fetchAttrStreamData && xhr.response) ? xhr.response.byteLength : 0;
428    var ptr = 0;
429    if (fetchAttrLoadToMemory && fetchAttrStreamData) {
430#if FETCH_DEBUG
431      console.log('fetch: allocating ' + ptrLen + ' bytes in Emscripten heap for xhr data');
432#endif
433      // The data pointer malloc()ed here has the same lifetime as the emscripten_fetch_t structure itself has, and is
434      // freed when emscripten_fetch_close() is called.
435      ptr = _malloc(ptrLen);
436      HEAPU8.set(new Uint8Array(xhr.response), ptr);
437    }
438    HEAPU32[fetch + Fetch.fetch_t_offset_data >> 2] = ptr;
439    Fetch.setu64(fetch + Fetch.fetch_t_offset_numBytes, ptrLen);
440    Fetch.setu64(fetch + Fetch.fetch_t_offset_dataOffset, e.loaded - ptrLen);
441    Fetch.setu64(fetch + Fetch.fetch_t_offset_totalBytes, e.total);
442    HEAPU16[fetch + Fetch.fetch_t_offset_readyState >> 1] = xhr.readyState;
443    if (xhr.readyState >= 3 && xhr.status === 0 && e.loaded > 0) xhr.status = 200; // If loading files from a source that does not give HTTP status code, assume success if we get data bytes
444    HEAPU16[fetch + Fetch.fetch_t_offset_status >> 1] = xhr.status;
445    if (xhr.statusText) stringToUTF8(fetch + Fetch.fetch_t_offset_statusText, xhr.statusText, 64);
446    if (onprogress) onprogress(fetch, xhr, e);
447  }
448#if FETCH_DEBUG
449  console.log('fetch: xhr.send(data=' + data + ')');
450#endif
451  try {
452    xhr.send(data);
453  } catch(e) {
454#if FETCH_DEBUG
455    console.error('fetch: xhr failed with exception: ' + e);
456#endif
457    if (onerror) onerror(fetch, xhr, e);
458  }
459}
460
461function emscripten_start_fetch(fetch, successcb, errorcb, progresscb) {
462  if (typeof Module !== 'undefined') Module['noExitRuntime'] = true; // If we are the main Emscripten runtime, we should not be closing down.
463
464  var fetch_attr = fetch + Fetch.fetch_t_offset___attributes;
465  var requestMethod = Pointer_stringify(fetch_attr);
466  var onsuccess = HEAPU32[fetch_attr + Fetch.attr_t_offset_onsuccess >> 2];
467  var onerror = HEAPU32[fetch_attr + Fetch.attr_t_offset_onerror >> 2];
468  var onprogress = HEAPU32[fetch_attr + Fetch.attr_t_offset_onprogress >> 2];
469  var fetchAttributes = HEAPU32[fetch_attr + Fetch.attr_t_offset_attributes >> 2];
470  var fetchAttrLoadToMemory = !!(fetchAttributes & 1/*EMSCRIPTEN_FETCH_LOAD_TO_MEMORY*/);
471  var fetchAttrStreamData = !!(fetchAttributes & 2/*EMSCRIPTEN_FETCH_STREAM_DATA*/);
472  var fetchAttrPersistFile = !!(fetchAttributes & 4/*EMSCRIPTEN_FETCH_PERSIST_FILE*/);
473  var fetchAttrAppend = !!(fetchAttributes & 8/*EMSCRIPTEN_FETCH_APPEND*/);
474  var fetchAttrReplace = !!(fetchAttributes & 16/*EMSCRIPTEN_FETCH_REPLACE*/);
475  var fetchAttrNoDownload = !!(fetchAttributes & 32/*EMSCRIPTEN_FETCH_NO_DOWNLOAD*/);
476
477  var reportSuccess = function(fetch, xhr, e) {
478#if FETCH_DEBUG
479    console.log('fetch: operation success. e: ' + e);
480#endif
481    if (onsuccess && Runtime.dynCall) Module['dynCall_vi'](onsuccess, fetch);
482    else if (successcb) successcb(fetch);
483  };
484
485  var cacheResultAndReportSuccess = function(fetch, xhr, e) {
486#if FETCH_DEBUG
487    console.log('fetch: operation success. Caching result.. e: ' + e);
488#endif
489    var storeSuccess = function() {
490#if FETCH_DEBUG
491      console.log('fetch: IndexedDB store succeeded.');
492#endif
493    };
494    var storeError = function() {
495#if FETCH_DEBUG
496      console.error('fetch: IndexedDB store failed.');
497#endif
498    };
499    __emscripten_fetch_cache_data(Fetch.dbInstance, fetch, xhr.response, storeSuccess, storeError);
500    if (onsuccess && Runtime.dynCall) Module['dynCall_vi'](onsuccess, fetch);
501    else if (successcb) successcb(fetch);
502  };
503
504  var reportProgress = function(fetch, xhr, e) {
505    if (onprogress && Runtime.dynCall) Module['dynCall_vi'](onprogress, fetch);
506    else if (progresscb) progresscb(fetch);
507  };
508
509  var reportError = function(fetch, xhr, e) {
510#if FETCH_DEBUG
511    console.error('fetch: operation failed: ' + e);
512#endif
513    if (onerror && Runtime.dynCall) Module['dynCall_vi'](onerror, fetch);
514    else if (errorcb) errorcb(fetch);
515  };
516
517  var performUncachedXhr = function(fetch, xhr, e) {
518#if FETCH_DEBUG
519    console.error('fetch: starting (uncached) XHR: ' + e);
520#endif
521    __emscripten_fetch_xhr(fetch, reportSuccess, reportError, reportProgress);
522  };
523
524  var performCachedXhr = function(fetch, xhr, e) {
525#if FETCH_DEBUG
526    console.error('fetch: starting (cached) XHR: ' + e);
527#endif
528    __emscripten_fetch_xhr(fetch, cacheResultAndReportSuccess, reportError, reportProgress);
529  };
530
531  // Should we try IndexedDB first?
532  if (!fetchAttrReplace || requestMethod === 'EM_IDB_STORE' || requestMethod === 'EM_IDB_DELETE') {
533    if (!Fetch.dbInstance) {
534#if FETCH_DEBUG
535      console.error('fetch: failed to read IndexedDB! Database is not open.');
536#endif
537      reportError(fetch, 0, 'IndexedDB is not open');
538      return 0; // todo: free
539    }
540
541    if (requestMethod === 'EM_IDB_STORE') {
542      var dataPtr = HEAPU32[fetch_attr + Fetch.attr_t_offset_requestData >> 2];
543      var dataLength = HEAPU32[fetch_attr + Fetch.attr_t_offset_requestDataSize >> 2];
544      var data = HEAPU8.slice(dataPtr, dataPtr + dataLength); // TODO(?): Here we perform a clone of the data, because storing shared typed arrays to IndexedDB does not seem to be allowed.
545      __emscripten_fetch_cache_data(Fetch.dbInstance, fetch, data, reportSuccess, reportError);
546    } else if (requestMethod === 'EM_IDB_DELETE') {
547      __emscripten_fetch_delete_cached_data(Fetch.dbInstance, fetch, reportSuccess, reportError);
548    } else if (fetchAttrNoDownload) {
549      __emscripten_fetch_load_cached_data(Fetch.dbInstance, fetch, reportSuccess, reportError);
550    } else if (fetchAttrPersistFile) {
551      __emscripten_fetch_load_cached_data(Fetch.dbInstance, fetch, reportSuccess, performCachedXhr);        
552    } else {
553      __emscripten_fetch_load_cached_data(Fetch.dbInstance, fetch, reportSuccess, performUncachedXhr);        
554    }
555  } else if (!fetchAttrNoDownload) {
556    if (fetchAttrPersistFile) {
557      __emscripten_fetch_xhr(fetch, cacheResultAndReportSuccess, reportError, reportProgress);
558    } else {
559      __emscripten_fetch_xhr(fetch, reportSuccess, reportError, reportProgress);        
560    }
561  } else {
562#if FETCH_DEBUG
563    console.error('fetch: Invalid combination of flags passed.');
564#endif
565    return 0; // todo: free
566  }
567  return fetch;
568}
569
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Puppeteer on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)