Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: LayoutTests/imported/web-platform-tests/webstorage/eventTestHarness.js

Issue 1220543007: Import web-platform-tests/webstorage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 iframe = document.createElement("IFRAME");
2 iframe.src = "about:blank";
3 document.body.appendChild(iframe);
4 iframe.contentWindow.document.body.textContent = "Nothing to see here.";
5
6 storageEventList = new Array();
7 iframe.contentWindow.addEventListener("storage", function(e) {
8 window.parent.storageEventList.push(e);
9 });
10
11 function runAfterNStorageEvents(callback, expectedNumEvents)
12 {
13 countStorageEvents(callback, expectedNumEvents, 0)
14 }
15
16 function countStorageEvents(callback, expectedNumEvents, times)
17 {
18 function onTimeout()
19 {
20 var currentCount = storageEventList.length;
21 if (currentCount == expectedNumEvents) {
22 callback();
23 } else if (currentCount > expectedNumEvents) {
24 msg = "got at least " + currentCount + ", expected only " + expected NumEvents + " events";
25 callback(msg);
26 } else if (times > 50) {
27 msg = "Timeout: only got " + currentCount + ", expected " + expected NumEvents + " events";
28 callback(msg);
29 } else {
30 countStorageEvents(callback, expectedNumEvents, times+1);
31 }
32 }
33 setTimeout(onTimeout, 20);
34 }
35
36 function testStorages(testCallback)
37 {
38 testCallback("sessionStorage");
39 var hit = false;
40 add_result_callback(function() {
41 if (!hit) {
42 hit = true;
43 testCallback("localStorage");
44 }
45 });
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698