mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-16 04:07:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
3
testing/web-platform/tests/page-visibility/OWNERS
Normal file
3
testing/web-platform/tests/page-visibility/OWNERS
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@plehegar
|
||||
@igrigorik
|
||||
@toddreifsteck
|
||||
48
testing/web-platform/tests/page-visibility/idlharness.html
Normal file
48
testing/web-platform/tests/page-visibility/idlharness.html
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Page Visibility IDL tests</title>
|
||||
<link rel="author" title="W3C" href="http://www.w3.org/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/page-visibility/#sec-document-interface"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
<script src="/resources/idlharness.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page Visibility IDL tests</h1>
|
||||
|
||||
<pre id='untested_idl' style='display:none'>
|
||||
interface Document {
|
||||
};
|
||||
</pre>
|
||||
|
||||
<pre id='idl'>
|
||||
enum VisibilityState { "hidden", "visible", "prerender", "unloaded" };
|
||||
|
||||
partial interface Document {
|
||||
readonly attribute boolean hidden;
|
||||
readonly attribute VisibilityState visibilityState;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
var idl_array = new IdlArray();
|
||||
|
||||
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
|
||||
idl_array.add_idls(document.getElementById("idl").textContent);
|
||||
|
||||
idl_array.add_objects({Document: ["window.document"]});
|
||||
|
||||
idl_array.test();
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
</body>
|
||||
</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>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility API Definition</title>
|
||||
|
||||
<script type="text/javascript" src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that all of the attributes associated with the Page Visibility feature exist
|
||||
(but does not validate that their values are correct).</p>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script type="text/javascript" >
|
||||
test_feature_exists();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility API Child Document Test</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
iframe
|
||||
{
|
||||
width:250px;
|
||||
height:250px;
|
||||
margin-left:5px;
|
||||
}
|
||||
|
||||
div.docs
|
||||
{
|
||||
position:relative;
|
||||
float:left;
|
||||
text-align:center;
|
||||
margin:10px;
|
||||
border:solid 1px black;
|
||||
padding:3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" >
|
||||
setup({explicit_done: true});
|
||||
|
||||
function onload_test()
|
||||
{
|
||||
pv_test();
|
||||
|
||||
var frames = document.getElementsByTagName("iframe");
|
||||
var doc, doc_name;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
doc = frames[i].contentDocument;
|
||||
doc_name = "IFrame with " + frames[i].id;
|
||||
|
||||
pv_test(function()
|
||||
{
|
||||
test_feature_exists(doc, " for frame with " + frames[i].id);
|
||||
});
|
||||
|
||||
test_equals(doc.visibilityState, VISIBILITY_STATES.VISIBLE,
|
||||
"document.visibilityState for frame with " +
|
||||
frames[i].id + " == " +
|
||||
VISIBILITY_STATES.VISIBLE);
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="onload_test()">
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that, within child documents, all of the Page Visibility API attributes exist,
|
||||
are read-only, and match the value of the attributes within the parent document.</p>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="docs">
|
||||
IFrame with no style attribute
|
||||
<br/>
|
||||
<iframe id="no style attribute" src="resources/blank_page_green.html">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<div class="docs">
|
||||
IFrame with "display:none" style<br/>
|
||||
<iframe id="'display:none' style" style="display:none"
|
||||
src="resources/blank_page_green.html">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<div class="docs">
|
||||
IFrame with "visibility:hidden" style
|
||||
<br/>
|
||||
<iframe id="'visibility:hidden' style" style="visibility:hidden"
|
||||
src="resources/blank_page_green.html">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility Null Default View Test</title>
|
||||
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
|
||||
<script type="text/javascript" >
|
||||
setup({explicit_done: true});
|
||||
|
||||
function onload_test()
|
||||
{
|
||||
// inject a windowless subdocument as a child of the root document <html> element
|
||||
var subDoc = document.implementation.createDocument('resources/blank_page_green.html', 'html', null);
|
||||
|
||||
// Test precondition: ensure subdocument has a null default view
|
||||
test_true(subDoc.defaultView == null, "windowless subdocument generated for test has a null default view");
|
||||
|
||||
// check that feature exists within subdocument
|
||||
test_feature_exists(subDoc, 'windowless subdocument');
|
||||
|
||||
// check that the subdocument has a hidden visibility state
|
||||
test_true(subDoc.hidden,
|
||||
"hidden == true for windowless subdocuments with a null default view");
|
||||
test_equals(subDoc.visibilityState, VISIBILITY_STATES.HIDDEN,
|
||||
"visibilityState == " + VISIBILITY_STATES.HIDDEN +
|
||||
" for windowless subdocuments with a null default view");
|
||||
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="onload_test()">
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that document.hidden == false and
|
||||
document.visibilityState == "visible" for windowless subdocuments.</p>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility API Operation While Minimizing Browser Window</title>
|
||||
<meta name="flags" content="interact" />
|
||||
<script type="text/javascript" src="/resources/testharness.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that the page properly becomes hidden and visible due to minimizing, maximizing, and
|
||||
restoring the browser window.</p>
|
||||
|
||||
<h1>Manual Test Steps:</h1>
|
||||
<p>
|
||||
<ol>
|
||||
<li> Ensure this page is the foreground and click the "Start Test"</li>
|
||||
<li> Minimize the browser</li>
|
||||
<li> Restore or maximize the browser</li>
|
||||
</ol>
|
||||
Note: This test will automatically timeout and fail if not completed within 60 seconds.
|
||||
</p>
|
||||
|
||||
<button onclick="start_test();">Start Test</button>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<br />
|
||||
IFrame with default style:
|
||||
<br />
|
||||
<iframe id="childDocShown" src="resources/blank_page_green.html">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
<hr />
|
||||
IFrame with "display:none" style:
|
||||
<br />
|
||||
<iframe id="childDocHidden" src="resources/blank_page_green.html" style="display:none">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
|
||||
<script type="text/javascript" >
|
||||
var child_doc_shown = null;
|
||||
var child_doc_hidden = null;
|
||||
var transition_mode;
|
||||
var manual_test = null;
|
||||
|
||||
var expected_notification_count = 2;
|
||||
var notification_count = new Array();
|
||||
var page_docs = new Array();
|
||||
var notification_handlers = new Array();
|
||||
var two_notifications = false;
|
||||
|
||||
var PAGE_HIDDEN_VAL = "hidden";
|
||||
var PAGE_VISIBLE_VAL = "visible";
|
||||
|
||||
setup({ explicit_done: true });
|
||||
|
||||
function test_transition_init()
|
||||
{
|
||||
child_doc_shown = document.getElementById("childDocShown").contentDocument;
|
||||
child_doc_hidden = document.getElementById("childDocHidden").contentDocument;
|
||||
|
||||
// fill in data for page documents
|
||||
page_docs.push([document, "document"]);
|
||||
page_docs.push([child_doc_shown, "document.getElementById(\"childDocShown\").contentDocument"]);
|
||||
page_docs.push([child_doc_hidden, "document.getElementById(\"childDocHidden\").contentDocument"]);
|
||||
|
||||
notification_handlers[0] = function(){ VerifyNotification(0); };
|
||||
notification_handlers[1] = function(){ VerifyNotification(1); };
|
||||
notification_handlers[2] = function(){ VerifyNotification(2); };
|
||||
|
||||
for (var i in page_docs)
|
||||
{
|
||||
notification_count[i] = 0;
|
||||
page_docs[i][0].addEventListener("visibilitychange", notification_handlers[i]);
|
||||
}
|
||||
|
||||
test_true(!document.hidden, "Page is visible on load.");
|
||||
test_true((!child_doc_shown.hidden) && (!child_doc_hidden.hidden),
|
||||
"All IFrame child documents are visible on load.");
|
||||
|
||||
document.addEventListener("visibilitychange", notification_handlers[0]);
|
||||
document.addEventListener("visibilitychange", VerifyTwoNotifications);
|
||||
|
||||
manual_test = AddManual("Browser minimization has occurred.");
|
||||
}
|
||||
|
||||
function VerifyNotification(doc_index)
|
||||
{
|
||||
doc = page_docs[doc_index][0];
|
||||
docName = page_docs[doc_index][1];
|
||||
|
||||
notification_count[doc_index]++;
|
||||
switch (notification_count[doc_index])
|
||||
{
|
||||
case 1:
|
||||
// First step, check page visibility after tab deselection / minimization.
|
||||
// hidden should change to true; visibilityState should change to "hidden"
|
||||
test_true(doc.hidden, docName + ".hidden == true (after browser frame minimization)");
|
||||
test_true(doc.visibilityState == PAGE_HIDDEN_VAL,
|
||||
docName + ".visibilityState == \"hidden\" (after browser frame minimization)");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//Second step, check page visibility after tab reselection / maximization / restoration.
|
||||
// hidden should change to false; visibilityState should change to "visible"
|
||||
test_true(!doc.hidden,
|
||||
docName + ".hidden == false (after browser frame maximization / restoration)");
|
||||
test_true(doc.visibilityState == PAGE_VISIBLE_VAL,
|
||||
docName + ".visibilityState == \"visible\" (after browser frame maximization / " +
|
||||
"restoration)");
|
||||
|
||||
// perform tests specific to the main document
|
||||
if (doc == document)
|
||||
{
|
||||
//Verify that a second registration to a different callback also occurred
|
||||
test_true(two_notifications, "Two registrations (different callbacks) occurred.");
|
||||
|
||||
//Verify that a second registration to the same callback did not occur
|
||||
test_equals(notification_count[doc_index],
|
||||
expected_notification_count,
|
||||
"Two registrations (same callback) did not occur.");
|
||||
|
||||
// pass the manual item associated with these tests
|
||||
AddManualResult(manual_test, true);
|
||||
|
||||
document.removeEventListener("visibilitychange", VerifyTwoNotifications);
|
||||
|
||||
// schedule the rollup
|
||||
setTimeout(VerifyAllNotifications, 200);
|
||||
}
|
||||
|
||||
//Remove all event listeners and verify that the event does not fire
|
||||
doc.removeEventListener("visibilitychange", notification_handlers[doc_index]);
|
||||
break;
|
||||
case 3:
|
||||
//This step should not have occurred since the event handlers were cleared
|
||||
test_true(false, "Event did not fire when event listener is removed.");
|
||||
|
||||
//On final step, schedule the rollup
|
||||
setTimeout(done, 2000);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function VerifyAllNotifications()
|
||||
{
|
||||
//On final step, schedule the rollup
|
||||
setTimeout(done, 1000);
|
||||
}
|
||||
|
||||
function VerifyTwoNotifications()
|
||||
{
|
||||
//This is a duplicate registration on visibilitychange and
|
||||
//should never get fired. Check that duplicate_notification
|
||||
//is false to verify that this never occurred.
|
||||
two_notifications = true;
|
||||
}
|
||||
|
||||
// Manual Test helper functions
|
||||
function AddManual(test)
|
||||
{
|
||||
// add asynchronous test for manual tests
|
||||
return async_test(test);
|
||||
}
|
||||
|
||||
function AddManualResult(oManualTest, passState)
|
||||
{
|
||||
// add assertion to manual test for the pass state
|
||||
oManualTest.step(function() {assert_true(passState)});
|
||||
|
||||
// end manual test
|
||||
oManualTest.done();
|
||||
}
|
||||
|
||||
function start_test()
|
||||
{
|
||||
test_transition_init();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility API is Read Only</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
setup({ explicit_done: true });
|
||||
function onload_test()
|
||||
{
|
||||
//check for feature definition first before attempting to overwrite
|
||||
pv_test();
|
||||
|
||||
//Check document.hidden
|
||||
document.hidden = "new value";
|
||||
test_true(document.hidden !== "new value", 'document.hidden is read only.');
|
||||
|
||||
//Check document.visibilityState
|
||||
document.visibilityState = "new value";
|
||||
test_true(document.visibilityState !== "new value",
|
||||
"document.visibilityState is read only.");
|
||||
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="onload_test();">
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that the Page Visibility attributes are read only.</p>
|
||||
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Page Visibility API Operation While Changing Tabs</title>
|
||||
<meta name="flags" content="interact" />
|
||||
<script type="text/javascript" src="/resources/testharness.js"></script>
|
||||
<script type="text/javascript" src="resources/pagevistestharness.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that the page properly becomes hidden and visible due to switching tabs.</p>
|
||||
|
||||
<h1>Manual Test Steps:</h1>
|
||||
<p>
|
||||
<ol>
|
||||
<li> Ensure this page is the foreground and click the "Start Test"</li>
|
||||
<li> Switch to another tab</li>
|
||||
<li> Return to the current tab containing this test page</li>
|
||||
</ol>
|
||||
Note: This test will automatically timeout and fail if not completed within 60 seconds.
|
||||
</p>
|
||||
|
||||
<button onclick="start_test();">Start Test</button>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<br />
|
||||
IFrame with default style:
|
||||
<br />
|
||||
<iframe id="childDocShown" src="resources/blank_page_green.html">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
<hr />
|
||||
IFrame with "display:none" style:
|
||||
<br />
|
||||
<iframe id="childDocHidden" src="resources/blank_page_green.html" style="display:none">
|
||||
iframes unsupported
|
||||
</iframe>
|
||||
|
||||
<script type="text/javascript" >
|
||||
var child_doc_shown = null;
|
||||
var child_doc_hidden = null;
|
||||
var transition_mode;
|
||||
var manual_test = null;
|
||||
|
||||
var expected_notification_count = 2;
|
||||
var notification_count = new Array();
|
||||
var page_docs = new Array();
|
||||
var notification_handlers = new Array();
|
||||
var two_notifications = false;
|
||||
|
||||
var PAGE_HIDDEN_VAL = "hidden";
|
||||
var PAGE_VISIBLE_VAL = "visible";
|
||||
|
||||
setup({ explicit_done: true });
|
||||
|
||||
function test_transition_init()
|
||||
{
|
||||
child_doc_shown = document.getElementById("childDocShown").contentDocument;
|
||||
child_doc_hidden = document.getElementById("childDocHidden").contentDocument;
|
||||
|
||||
// fill in data for page documents
|
||||
page_docs.push([document, "document"]);
|
||||
page_docs.push([child_doc_shown, "document.getElementById(\"childDocShown\").contentDocument"]);
|
||||
page_docs.push([child_doc_hidden, "document.getElementById(\"childDocHidden\").contentDocument"]);
|
||||
|
||||
notification_handlers[0] = function(){ VerifyNotification(0); };
|
||||
notification_handlers[1] = function(){ VerifyNotification(1); };
|
||||
notification_handlers[2] = function(){ VerifyNotification(2); };
|
||||
|
||||
for (var i in page_docs)
|
||||
{
|
||||
notification_count[i] = 0;
|
||||
page_docs[i][0].addEventListener("visibilitychange", notification_handlers[i]);
|
||||
}
|
||||
|
||||
test_true(!document.hidden, "Page is visible on load.");
|
||||
test_true((!child_doc_shown.hidden) && (!child_doc_hidden.hidden),
|
||||
"All IFrame child documents are visible on load.");
|
||||
|
||||
document.addEventListener("visibilitychange", notification_handlers[0]);
|
||||
document.addEventListener("visibilitychange", VerifyTwoNotifications);
|
||||
|
||||
manual_test = AddManual("Browser tab switch has occurred.");
|
||||
}
|
||||
|
||||
function VerifyNotification(doc_index)
|
||||
{
|
||||
doc = page_docs[doc_index][0];
|
||||
docName = page_docs[doc_index][1];
|
||||
|
||||
notification_count[doc_index]++;
|
||||
switch (notification_count[doc_index])
|
||||
{
|
||||
case 1:
|
||||
// First step, check page visibility after tab deselection / minimization.
|
||||
// hidden should change to true; visibilityState should change to "hidden"
|
||||
test_true(doc.hidden, docName + ".hidden == true (after tab switch)");
|
||||
test_true(doc.visibilityState == PAGE_HIDDEN_VAL,
|
||||
docName + ".visibilityState == \"hidden\" (after tab switch)");
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
//Second step, check page visibility after tab reselection / maximization / restoration.
|
||||
// hidden should change to false; visibilityState should change to "visible"
|
||||
test_true(!doc.hidden,
|
||||
docName + ".hidden == false (after return to original tab)");
|
||||
test_true(doc.visibilityState == PAGE_VISIBLE_VAL,
|
||||
docName + ".visibilityState == \"visible\" (after return to original tab)");
|
||||
|
||||
// perform tests specific to the main document
|
||||
if (doc == document)
|
||||
{
|
||||
//Verify that a second registration to a different callback also occurred
|
||||
test_true(two_notifications, "Two registrations (different callbacks) occurred.");
|
||||
|
||||
//Verify that a second registration to the same callback did not occur
|
||||
test_equals(notification_count[doc_index],
|
||||
expected_notification_count,
|
||||
"Two registrations (same callback) did not occur.");
|
||||
|
||||
// pass the manual item associated with these tests
|
||||
AddManualResult(manual_test, true);
|
||||
|
||||
document.removeEventListener("visibilitychange", VerifyTwoNotifications);
|
||||
|
||||
// schedule the rollup
|
||||
setTimeout(VerifyAllNotifications, 200);
|
||||
}
|
||||
|
||||
//Remove all event listeners and verify that the event does not fire
|
||||
doc.removeEventListener("visibilitychange", notification_handlers[doc_index]);
|
||||
break;
|
||||
case 3:
|
||||
//This step should not have occurred since the event handlers were cleared
|
||||
test_true(false, "Event did not fire when event listener is removed.");
|
||||
|
||||
//On final step, schedule the rollup
|
||||
setTimeout(done, 2000);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function VerifyAllNotifications()
|
||||
{
|
||||
//On final step, schedule the rollup
|
||||
setTimeout(done, 1000);
|
||||
}
|
||||
|
||||
function VerifyTwoNotifications()
|
||||
{
|
||||
//This is a duplicate registration on visibilitychange and
|
||||
//should never get fired. Check that duplicate_notification
|
||||
//is false to verify that this never occurred.
|
||||
two_notifications = true;
|
||||
}
|
||||
|
||||
// Manual Test helper functions
|
||||
function AddManual(test)
|
||||
{
|
||||
// add asynchronous test for manual tests
|
||||
return async_test(test);
|
||||
}
|
||||
|
||||
function AddManualResult(oManualTest, passState)
|
||||
{
|
||||
// add assertion to manual test for the pass state
|
||||
oManualTest.step(function() {assert_true(passState)});
|
||||
|
||||
// end manual test
|
||||
oManualTest.done();
|
||||
}
|
||||
|
||||
function start_test()
|
||||
{
|
||||
test_transition_init();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
17
testing/web-platform/tests/page-visibility/unload-1.html
Normal file
17
testing/web-platform/tests/page-visibility/unload-1.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head><title>Document</title></head>
|
||||
<body>
|
||||
<h1>Document</h1>
|
||||
<script>
|
||||
onload = function() {
|
||||
document.addEventListener("visibilitychange", onVisibilityChange, false);
|
||||
opener.postMessage("close", "*");
|
||||
}
|
||||
|
||||
function onVisibilityChange() {
|
||||
opener.postMessage(document.visibilityState, "*");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
18
testing/web-platform/tests/page-visibility/unload.html
Normal file
18
testing/web-platform/tests/page-visibility/unload.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!doctype html>
|
||||
<title>visibilitychange fires on unload</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var w = window.open("unload-1.html");
|
||||
window.onmessage = t.step_func(function(event) {
|
||||
if (event.data === "close") {
|
||||
w.close();
|
||||
return;
|
||||
}
|
||||
assert_equals(event.data, "hidden");
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue