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
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
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
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.
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
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
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.
6. What will the file_get_contents() return?
a) Server’s response
b) Errors
c) Exception
d) Client’s response
View Answer
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.
7. How will you convert the returned API into an XML object?
a) SimpleElement()
b) SimpleXMLElement()
c) XMLElement()
d) CovertXML()
View Answer
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
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
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
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.
- Practice Information Science MCQs
- Check Programming Books
- Apply for Computer Science Internship
- Practice Programming MCQs
- Check JavaScript Books