diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/page-visibility/resources | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/page-visibility/resources')
-rw-r--r-- | testing/web-platform/tests/page-visibility/resources/blank_page_green.html | 10 | ||||
-rw-r--r-- | testing/web-platform/tests/page-visibility/resources/pagevistestharness.js | 121 |
2 files changed, 131 insertions, 0 deletions
diff --git a/testing/web-platform/tests/page-visibility/resources/blank_page_green.html b/testing/web-platform/tests/page-visibility/resources/blank_page_green.html new file mode 100644 index 000000000..b8a1947b7 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/blank_page_green.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML> +<html> + <head> + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> + <title>Green Test Page</title> + </head> + <body style="background-color:#00FF00;"> + <h1>Placeholder</h1> + </body> +</html> diff --git a/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js b/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js new file mode 100644 index 000000000..d53d73b42 --- /dev/null +++ b/testing/web-platform/tests/page-visibility/resources/pagevistestharness.js @@ -0,0 +1,121 @@ +/* +Distributed under both the W3C Test Suite License [1] and the W3C +3-clause BSD License [2]. To contribute to a W3C Test Suite, see the +policies and contribution forms [3]. + +[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license +[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license +[3] http://www.w3.org/2004/10/27-testcases +*/ + +// +// Helper Functions for PageVisibility W3C tests +// +var VISIBILITY_STATES = +{ + HIDDEN: "hidden", + VISIBLE: "visible" +}; + +var feature_check = false; + +// +// All test() functions in the WebPerf PageVis test suite should use pv_test() instead. +// +// pv_test() validates the document.hidden and document.visibilityState attributes +// exist prior to running tests and immediately shows a failure if they do not. +// + +function pv_test(func, msg, doc) +{ + if (!doc) + { + doc = document; + } + + // only run the feature check once, unless func == null, in which case, + // this call is intended as a feature check + if (!feature_check) + { + feature_check = true; + + var hiddenVal = doc.hidden; + var visStateVal = doc.visibilityState; + + // show a single error that the Page Visibility feature is undefined + test(function() + { + assert_true(hiddenVal !== undefined && hiddenVal != null, + "document.hidden is defined and not null.");}, + "document.hidden is defined and not null."); + + test(function() + { + assert_true(visStateVal !== undefined && hiddenVal != null, + "document.visibilityState is defined and not null.");}, + "document.visibilityState is defined and not null."); + + } + + if (func) + { + test(func, msg); + } +} + + +function test_feature_exists(doc, msg) +{ + if (!msg) + { + msg = ""; + } + var hiddenMsg = "document.hidden is defined" + msg + "."; + var stateMsg = "document.visibilityState is defined" + msg + "."; + pv_test(function(){assert_true(document.hidden !== undefined, hiddenMsg);}, hiddenMsg, doc); + pv_test(function(){assert_true(document.visibilityState !== undefined, stateMsg);}, stateMsg, doc); +} + +// +// Common helper functions +// + +function test_true(value, msg) +{ + pv_test(function() { assert_true(value, msg); }, msg); +} + +function test_equals(value, equals, msg) +{ + pv_test(function() { assert_equals(value, equals, msg); }, msg); +} + +// +// asynchronous test helper functions +// + +function add_async_result(test_obj, pass_state) +{ + // add assertion to manual test for the pass state + test_obj.step(function() { assert_true(pass_state) }); + + // end manual test + test_obj.done(); +} + +function add_async_result_assert(test_obj, func) +{ + // add assertion to manual test for the pass state + test_obj.step(func); + + // end manual test + test_obj.done(); +} + +var open_link; +function TabSwitch() +{ + //var open_link = window.open("http://www.bing.com"); + open_link = window.open('', '_blank'); + setTimeout(function() { open_link.close(); }, 2000); +} |