JavaScript Questions & Answers – Accessing the WebPagetest API

«
»

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Accessing the WebPagetest API”.

1. How many parameters does the WebPageTest API accept?
a) 5
b) 6
c) 7
d) 8
View Answer

Answer: d
Explanation: WebPageTest helps you run a free website speed test from multiple locations around the globe using real browsers (IE and Chrome) and at real consumer connection speeds. The WebPageTest API accepts totally 8 parameters, namely url, location, runs, fvonly, private, block, f, k.

2. What is the purpose of getting the parameter block?
a) Permission to block
b) Space separated block list
c) Comma separated block list
d) Underscore separated block list
View Answer

Answer: c
Explanation: A ParameterBlock encapsulates all the information about sources and parameters (Objects) required by a RenderableImageOp, or other classes that process images. This parameter allows you to set a comma separated list of block options.

3. What will happen if you set the private flag as 1?
a) Test will be run only by the administrator
b) Test will not be run
c) Test is public
d) Test is not displayed in public
View Answer

Answer: d
Explanation: The WebPageTest results provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks and suggestions for improvements which can be kept public or private. Setting the private flag to 1 will make sure that the test is not displayed in the public list of tests.
advertisement
advertisement

4. What is the purpose of getting the parameter fvonly?
a) To repeat the view test
b) To get the first view
c) To debug the code
d) To compile the code
View Answer

Answer: b
Explanation: fvonly is an optional parameter which is set to 1 to skip the Repeat View test. If you set fvonly to 1, you get results only for the first view and do not run the repeat view test.

5. What is the purpose of the file_get_contents()?
a) To get the errors and exceptions
b) To get the client’s response
c) To get the server’s response
d) To get the data
View Answer

Answer: c
Explanation: The file_get_contents() is a PHP’s native function used to hit the URL and read the server’s response into
a variable $wpt_response:

$wpt_response = file_get_contents($wpt_url . $urls_to_benchmark[$x]);

This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

advertisement

6. What will the file_get_contents() return?
a) Server’s response
b) Errors
c) Exception
d) Client’s response
View Answer

Answer: a
Explanation: The file_get_contents() is a PHP’s native function used to hit the URL and read the server’s response into
a variable $wpt_response:

$wpt_response = file_get_contents($wpt_url . $urls_to_benchmark[$x]);

This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

advertisement

7. How will you convert the returned API into an XML object?
a) SimpleElement()
b) SimpleXMLElement()
c) XMLElement()
d) CovertXML()
View Answer

Answer: b
Explanation: file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance. The API returned by the method file_get_contents() can be converted into an XML object using the method SimpleXMLElement().

8. Which tag can handle mouse events in Netscape?
a) img
b) a
c) br
d) src
View Answer

Answer: a
Explanation: Netscape is a brand name associated with the development of the Netscape web browser. The img element can handle mouse events in Netscape.

9. What is the tainted property of the window object?
a) Pathname
b) Protocol
c) Default status
d) Host
View Answer

Answer: c
Explanation: The Defaultstatus is the tainted property of the window object. The defaultStatus property sets or returns the default text in the status bar at the bottom of the browser (the text will be displayed when the page loads).

10. Which environment variable must the user enable in order to enable data tainting?
a) ENABLE_TAINT
b) MS_ENABLE_TAINT
c) NS_ENABLE_TAINT
d) ENABLE_TAINT_NS
View Answer

Answer: c
Explanation: Data Tainting (or Taint Checking) is a language feature wherein user-input data is flagged as tainted, a flag that propagates to all data derived from this input. The environment variable NS_ENABLE_TAINT must be enabled in order to enable data tainting.

Sanfoundry Global Education & Learning Series – Javascript Programming.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.