Commit cadece29 authored by tfarina@chromium.org's avatar tfarina@chromium.org

webkit: Remove all files from test_shell/.

BUG=338338
TEST=None
R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/401923005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284727 0039d316-1c4b-4281-b951-d872f2087c98
parent fbbdf4ba
<html><head></head><body>
<form method="post" enctype="multipart/form-data" action="http://fishy/cgi-bin/echo-all" target="blah">
<input name="f" type="text">
<input value="Submit" type="submit">
</form>
<iframe style="border: 1px solid black;" name="blah" src="javascript:'the submission should go here'"></iframe>
</body></html>
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Inline Frame Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="This document contains the text of several
UAAG checkpoints. It is intended to be displayed as an inline frame.">
<meta name="keywords" content="HTML, web accessibility, user agent, UA, UAWG, WCAG,
Web Content Accessibility Guidelines, World Wide Web Consortium, W3C, WWW,
disabilities, disabled, web access">
<meta name="author" content="Gregory J. Rosmaita">
<link rel="stylesheet" type="text/css" href="iframe1_files/test.txt">
<style type="text/css">
<!--
.source {
margin-right : 2%;
margin-left : 2%;
border-width : thin;
border-style : solid;
border-color : black;
color : black;
background : white;
padding : .5em;
font-size : 105%;
font-weight : bold;
}
.indented { margin-left : 5%; margin-right : 5%; }
-->
</style></head><body>
<h1>Pertinent <acronym title="User Agent Accessibility Guidelines">UAAG</acronym> Checkpoints</h1>
<p class="source">
The source of the checkpoints reproduced in this test document is the
<a href="http://www.w3.org/WAI/UA/WD-UAAG10-20010411/">11 May 2001
Working Draft of the User Agent Accessibility Guidelines</a>:
<br>
<span class="indented">&lt;http://www.w3.org/WAI/UA/WD-UAAG10-20010411/&gt;</span>
</p>
<dl class="checkpoint">
<dt class="checkpoint"><span class="checkpoint"><a id="tech-doc-content-access" name="tech-doc-content-access">2.1</a></span> For all format specifications
that the user agent <a href="http://www.w3.org/TR/UAAG10/#def-implement" rel="glossary" title="Definition of implement"><span class="dfn-instance">
implements</span></a>, make <a href="http://www.w3.org/TR/UAAG10/#def-content" rel="glossary" title="Definition of Content"><span class="dfn-instance">content</span></a>
available through the rendering processes described by those specifications.
<span class="priority1">[Priority&nbsp;1]</span> Content only.</dt>
<dd class="checkpoint"><strong>Note:</strong> This includes format-defined
interactions between author preferences and user preferences/capabilities
(e.g., when to render the "<code>alt</code>" <a href="http://www.w3.org/TR/UAAG10/#def-attribute" rel="glossary" title="Definition of Attribute"><span class="dfn-instance">
attribute</span></a> in HTML <cite><a href="http://www.w3.org/TR/UAAG10/#ref-HTML4" title="Link to reference HTML4">[HTML4]</a></cite>, the rendering order of
nested <code>OBJECT</code> elements in HTML, test attributes in SMIL <cite><a href="http://www.w3.org/TR/UAAG10/#ref-SMIL" title="Link to reference SMIL">[SMIL]</a></cite>, and the
cascade in CSS2 <cite><a href="http://www.w3.org/TR/UAAG10/#ref-CSS2" title="Link to reference CSS2">
[CSS2]</a></cite>). If a conforming user agent does not render a content type,
it should allow the user to choose a way to handle that content (e.g., by
launching another application, by saving it to disk, etc.). This checkpoint
does not require that all content be available through each <a href="http://www.w3.org/TR/UAAG10/#def-viewport" rel="glossary" title="Definition of viewports"><span class="dfn-instance">viewport</span></a>.</dd>
<dd><span class="noprint"><a href="http://www.w3.org/WAI/UA/UAAG10-TECHS/guidelines.html#tech-doc-content-access">
Techniques for checkpoint 2.1</a></span></dd>
<dt class="checkpoint"><span class="checkpoint"><a id="tech-nav-viewports" name="tech-nav-viewports">9.1</a></span> Allow the user to make the <a href="http://www.w3.org/TR/UAAG10/#def-selection" rel="glossary" title="Definition of Selection"><span class="dfn-instance">selection</span></a> and <a href="http://www.w3.org/TR/UAAG10/#def-focus" rel="glossary" title="Definition of Focus"><span class="dfn-instance">
focus</span></a> of each <a href="http://www.w3.org/TR/UAAG10/#def-viewport" rel="glossary" title="Definition of viewports"><span class="dfn-instance">viewport</span></a>
(including frames) the <a href="http://www.w3.org/TR/UAAG10/#def-current-selection" rel="glossary" title="Definition of current selection"><span class="dfn-instance">current
selection</span></a> and <a href="http://www.w3.org/TR/UAAG10/#def-current-focus" rel="glossary" title="Definition of current focus"><span class="dfn-instance">current
focus</span></a>, respectively. <span class="priority1">
[Priority&nbsp;1]</span> User agent only.</dt>
<dd class="checkpoint"><strong>Note:</strong> For example, when all frames of a
frameset are displayed side-by-side, allow the user (via the keyboard) to move
the <a href="http://www.w3.org/TR/UAAG10/#def-focus" rel="glossary" title="Definition of Focus"><span class="dfn-instance">focus</span></a> among them.</dd>
<dd><span class="noprint"><a href="http://www.w3.org/WAI/UA/UAAG10-TECHS/guidelines.html#tech-nav-viewports">
Techniques for checkpoint 9.1</a></span></dd>
</dl>
<hr title="Validation Information">
<p class="validation">
<a href="http://validator.w3.org/check/referer"><img src="foo1_data/vxhtml10.png" alt="W3C&nbsp;Validated&nbsp;XHTML&nbsp;1.0!" style="border: 0pt none ; width: 88px; height: 31px;"></a>
&nbsp;&nbsp;&nbsp;
<a href="http://jigsaw.w3.org/css-validator/validator-uri.html" title="Validate this page's stylesheet, courtesy of the W3C CSS Validation Service"><img style="border: 0pt none ; width: 88px; height: 31px;" src="foo1_data/vcss.gif" alt="W3C&nbsp;Validated&nbsp;CSS!"></a>
</p>
</body></html>
\ No newline at end of file
@media screen {
body {
color : black;
background : white;
font-family : sans-serif;
}
.chk-summary { font-weight: bold }
.dfn-instance { color: #00513D;
background: white;
font-style: italic ;
}
.indent { margin-left : 5%; }
.introduction {
font-size : 105%;
margin-right : 2%;
margin-left : 2%;
border-width : thin;
border-style : solid;
border-color : black;
color : black;
background : white;
padding : .5em;
}
.markup-example { margin-left : 5%; }
.nav {
margin-right : 10%;
margin-left : 10%;
font-weight : bold;
text-align : center;
}
.nav-bar-title {
text-align : center;
font-size : 110%;
font-family : sans-serif;
font-weight: normal;
color: #0050B2;
background : white;
}
.policyfooter { font-size : 80%; }
.new { color:white; background:red; font-weight:bold; font-size:90%; }
.priority1 { color:red; background:white; }
.return1 { font-size : 105%; font-weight : bold; }
.separator { display: none }
.sub-navigation-bar { font-size:90%; font-weight:bold; margin-left:5%; }
.test {
border-width : thin;
border-style : solid;
border-color : black;
color : black;
background : white;
padding : .75em;
}
.under-construction {
font-family : arial, sans-serif;
font-weight : bold;
font-size : 115%;
background : yellow;
color : inherit;
display : inline;
border-width: 2px;
border-style: solid;
width : 100%;
text-align : center;
}
.valid { font-size:105%; text-align:center; }
a.link { color : #00008B; background : inherit; }
a:active { color : red; background : inherit; }
a:visited { color : purple; background : inherit; }
a:hover { color : inherit; background : #FFA ; }
dl.checkpoints { margin-left: 2em; margin-right: 2em; }
dt.checkpoint { font-weight: normal; }
dt.toc-intro { font-size : 1.25em; font-family : arial, sans-serif; font-weight : bold; }
em { font-style : italic; }
h1 {
text-align : center;
font-family : sans-serif;
font-weight: normal;
color: #0050B2;
background : white;
}
h2,h3 {
text-align : left;
font-family : sans-serif;
font-weight: normal;
color: #0050B2;
background : white;
}
h4,h5,h6 { color: #0050B2; background: white; font-weight: normal; }
hr { color : black; background : white; }
ol { counter-reset : item; }
ol.li { display : block; }
ol.li:before { content : counters(item, ".") ; counter-increment: item; }
strong { font-weight : bold; }
span.checkpoint { font-weight: bold; margin-top: .75em; }
.checkpoint-nb { color: maroon; background: white; }
}
@media print {
.noprint { display: none }
}
@media aural {
.guideline { volume: loud ; pause-before: 20%; elevation: above }
.markup-example { speak-punctuation: code; }
span.checkpoint { richness: 75; }
.example { speak-punctuation: code; }
.off { speak: none; }
.priority1 { volume: loud; }
.dfn-instance { stress: 20; pitch: high; }
cite.normref { volume: loud }
h1 { stress: 25; richness: 90; }
h2 { stress: 20; richness: 90; }
h3 { stress: 15; richness: 90; }
h4 { stress: 10; richness: 90; }
h5 { stress: 7; richness: 90; }
h6 { stress: 5; richness: 90; }
}
<html>
<body>
<iframe style="margin: 2em;" width="650" height="550" src="http://www.hicom.net/~oedipus/wai/ua/tests/iframe1.html"></iframe>
</body>
</html>
<html>
<body>
<iframe style="margin: 2em;" width="650" height="550" src="https://bugzilla.mozilla.org/query.cgi"></iframe>
</body>
</html>
<HTML>
<HEAD>
<TITLE>IFRAME test</TITLE>
</HEAD>
<BODY bgcolor=green>
<iframe
style = 'margin: 100px;'
src = 'testiframe2.html'
width = '300'
height = '300'
marginwidth = '0'
marginheight = '0'
frameborder = '0'
scrolling = 'no'></iframe>
</iframe>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>IFRAME test</TITLE>
</HEAD>
<BODY bgcolor=red>
<h1>Inside the frame</h1>
</BODY>
</HTML>
<html>
<head>
<title>test_shell home</title>
<link rel="stylesheet" href="test.css" type="text/css"/>
</head>
<body>
<div id="title">
<img src="http://www.google.com/intl/en/images/logo.gif" alt="Face">
<div style="font-size: 24px; text-align: center; border: solid blue" contenteditable="true">Chrome Tests</div>
</div>
<div id="rightcol">
<div class="group">
<h1 style="background: blue;">Plugin Tests</h1>
<li><a href="plugins/embed.htm">Basic Flash Plugin test</a>
<li><a href="plugins/embed2.htm">Nested Frame Plugin Test</a>
<li><a href="plugins/embed3.htm">Many Windowed Plugins test</a>
<li><a href="plugins/embed4.htm">One Flash Plugin test</a>
<li><a href="plugins/embed5.htm">Flash using 100% CPU</a>
<li><a href="plugins/embedwindowless.htm">Windowless Plugin Test</a>
<li><a href="plugins/embedwindowless2.htm">Windowless Plugin Test 2</a>
<li><a href="plugins/embedwindowless3.htm">Many Windowless Plugins Test</a>
<li><a href="plugins/jsflash.htm">Javascript object</a>
<li><a href="plugins/js_call.html">Plugin calling Javascript functions</a>
<li><a href="plugins/wmp.html">Windows Media Player</a>
<li><a href="plugins/diamondx/index.htm">DiamondX (Linux-specific)</a>
</div>
<div class="group">
<h1 style="background: red;">Scrolling Tests</h1>
<li><a href="scrollbar/test.html">Overflow Div scrolling</a>
<li><a href="frames/nested_test.html">Nested frames</a>
</div>
<div class="group">
<h1 style="background: #cccc00;">WebKit Tests</h1>
<li><a href="../../../third_party/WebKit/LayoutTests">Layout Tests</a>
</div>
</div>
<div id="leftcol">
<div class="group">
<h1 style="background: green;">External Links</h1>
<li><a href="http://www.google.com/">Google</a>
</div>
<div class="group">
<h1>Form Tests</h1>
<li><a href="formsubmit/target_test.html">Posting to a target</a>
</div>
<div class="group">
<h1 style="background: purple;">JS Tests</h1>
<li><a href="js/timers.html">JS Timer speed</a>
<li><a href="sort/sort.html">Sorting in Action</a>
</div>
<div class="group">
<h1 style="background: #cccc00;">IFrame Tests</h1>
<li><a href="iframes/test1.html">IFrame containing w3c page</a>
<li><a href="iframes/test2.html">IFrame contining bugzilla</a>
</div>
<div id="footer">
<hr>
<b>What is this page?</b> This is just a collection of links to test cases.
If you ever find yourself creating a test webpage, add a test
here. It isn't an automated test, but may be useful later. Try to
keep the order logical.
</div>
</body>
</html>
<html>
<head>
<script language="javascript">
var last = new Date(); // The last time we sampled the timer
var total_value = 0; // The sum of the intervals measured
var total_count = 0; // The count of the intervals measured
var last_interval = 1;
function fire() {
var current = new Date();
var ms = current - last;
total_value += ms;
total_count++;
// Display the interval output.
var output = document.getElementById('output');
output.innerHTML = ms + "ms";
// Display the average output.
var average = document.getElementById('average');
average.innerHTML = total_value / total_count + "ms";
// Get the new interval from the input.
var input = document.getElementById('input');
// If the interval has changed, reset our averages.
if (input.value != last_interval) {
total_value = 0;
total_count = 0;
}
last_interval = input.value;
last = new Date();
setTimeout(fire, last_interval);
}
</script>
</head>
<body onload='setTimeout("fire()", 1)'>
<h1>Test JS setTimeout() speed</h1>
This page tests the frequency of setTimeout() in the browser.
Javascript applications use setTimeout() as a mechanism to 'yield'
to the browser so that the browser can repaint. Most browsers
implement a 15ms setTimeout() minimum. Use this to page to measure
setTimeout() lag and discover your browser's minimum interval.<P>
<hr>
Desired ms to delay: <input id="input" type="text" value="1"><P>
Measured delay:<br>
<ul>
instance: <div id="output"></div>
average: <div id="average"></div>
</ul>
</body>
</html>
// bubble sort
function sort_bubble(sort, x, y) {
if (arguments.length == 1) {
x = 1; y = 0;
}
var len = sort.bars.length;
if (x < len && y < len) {
if (sort.compare(x, y) < 0) {
sort.swap(x, y);
}
y++;
if (y == x) {
y = 0;
x++;
}
if (x < len) {
sort.add_work(function() { sort_bubble(sort, x, y); });
return;
}
}
}
// heapsort
function sort_heap(sort, end) {
if (arguments.length == 1) {
var mid = Math.floor(sort.size/2 - 1);
sort.add_work(function() { build_heap(sort, mid); }, "build_heap");
} else if (end > 0) {
sort.swap(end, 0);
end--;
sort.add_work(function() { sort_heap(sort, end); }, "sort_heap");
sort.add_work(function() { sift_down(sort, 0, end, 0); }, "sift_down");
}
}
function build_heap(sort, start) {
if (start >= 0) {
sort.add_work(function() { build_heap(sort, start-1); }, "build_heap");
sort.add_work(function() { sift_down(sort, start, sort.size-1, start); },
"sift_down");
} else {
sort.add_work(function() { sort_heap(sort, sort.size-1); },
"sort_heap");
}
}
function sift_down(sort, start, end, root) {
var child = root * 2 + 1;
if (child <= end) {
if (child < end && sort.compare(child, child + 1) < 0) {
child++;
}
if (sort.compare(root, child) < 0) {
sort.swap(root, child);
root = child;
sort.add_work(function() { sift_down(sort, start, end, root); },
"sift_down");
}
}
}
function validate_heap(sort) {
var i = Math.floor(sort.size/2 - 1);
while (i >= 0) {
child = i * 2 + 1;
if (sort.compare(i, child) < 0)
return 0;
if (child + 1 < sort.size)
if (sort.compare(i, child + 1) < 0)
return 0;
i--;
}
return 1;
}
// insertion sort
function sort_insertion(sort, x, y) {
if (arguments.length == 1 || x == undefined) {
x = 1; y = 1;
}
var len = sort.bars.length;
if (x < len && y > 0) {
if (sort.compare(y, y - 1) < 0) {
sort.swap(y, y - 1);
y--;
if (y == 0) {
x++;
y = x;
}
} else {
x++;
y = x;
}
if (x < len) {
sort.add_work(function () { sort_insertion(sort, x, y); });
return;
}
}
}
// quicksort
function sort_quick(sort, left, right) {
if (arguments.length == 1) {
left = 0;
right = sort.size - 1;
}
if (left < right) {
var pivot = left + Math.floor(Math.random()*(right-left));
//var pivot = Math.floor(left + (right-left)/2);
partition(sort, left, right, pivot);
}
}
function partition(sort, left, right, pivot) {
sort.swap(pivot, right);
sort.add_work(function(){partition_step(sort, left, right, pivot, left, left);});
}
function partition_step(sort, left, right, pivot, i, j) {
if (i < right) {
if (sort.compare(i, right) <= 0) {
sort.swap(i, j);
j++;
}
i++;
sort.add_work(function(){partition_step(sort, left, right, pivot, i, j)});
} else {
sort.swap(j, right);
sort.add_work(function(){sort_quick(sort, left, j-1)});
sort.add_work(function(){sort_quick(sort, j+1, right)});
}
}
body {
font-family: Consolas, monospace;
font-size: 12px;
}
ul.bar {
position: relative;
width: 900px;
height: 200px;
background: gray;
border: 2px solid silver;
}
ul.bar li {
position: absolute;
bottom: 0px;
width: 5px;
list-style: none;
margin: 0px;
padding: 0px;
z-index: 2;
border: 1px solid black;
border-bottom: 0px;
background: green;
}
ul.bar .label {
position: absolute;
top: 5px;
left: 5px;
background: none;
}
li.compare {
border: white;
width: 10px;
}
li.compare {
background-color: red;
}
.button {
border: 1px dashed silver;
padding: 2px;
margin: 2px;
display: inline;
}
.button:hover {
text-decoration:underline;
cursor: pointer;
background-color: silver;
}
<html>
<head>
<title>Sorting in action</title>
<link rel=stylesheet href="sort.css" type="text/css">
<script src="sort.js"></script>
<script src="sort-bubble.js"></script>
<script src="sort-insertion.js"></script>
<script src="sort-quick.js"></script>
<script src="sort-heap.js"></script>
<script>
var sorts = new Array();
sorts.push(new Sort("Bubble", sort_bubble));
sorts.push(new Sort("Insertion", sort_insertion));
sorts.push(new Sort("Quick", sort_quick));
sorts.push(new Sort("Heap", sort_heap));
function init() {
function starter(sort) {
return function(){sort.start();};
}
for (var i = 0; i < sorts.length; i++) {
var sort = sorts[i];
sort.init();
var graph = document.getElementById(sort.name);
graph.onclick = starter(sort);
}
var inner_loop = document.getElementById("inner_loop");
inner_loop.checked = inner_loop_enabled != 0;
}
function start_all() {
for (var i = 0; i < sorts.length; i++) {
sorts[i].start();
}
}
function reset_all() {
for (var i = 0; i < sorts.length; i++) {
sorts[i].reset();
}
}
function change_size(val) {
size = val;
reset_all();
}
function enable_inner_loop(enabled) {
if (enabled) {
inner_loop_enabled = 1;
} else {
inner_loop_enabled = 0;
}
}
</script>
</head>
<body onload="init();">
<div id="sort_container" style="border: 0px solid black; margin: 0px">
<div>
<div class="button" onclick="start_all();">Start All</div>
<div class="button" onclick="reset_all();">Reset All</div>
...or click on each algorithm to start separately
<div style="float:right">
<b>Size</b><input onchange="change_size(this.value);" id="size" value=300 size=3>
<b>Inner Loop</b><input id="inner_loop" type="checkbox" onchange="enable_inner_loop(this.checked);" id="inner loop">
</div>
</div>
<div>
<ul id="Heap" class="bar">
</ul>
</div>
<div>
<ul id="Quick" class="bar">
</ul>
</div>
<div>
<ul id="Bubble" class="bar">
</ul>
</div>
<div>
<ul id="Insertion" class="bar">
</ul>
</div>
</div>
</body>
</html>
// sort object
var manual = 0; // single stepping
var interval_time = 0; // setTimeout interval
var inner_loop_enabled = 1; // should the stepper iterate a little during each step
// number of elements
var size = 300;
var query = window.location.search.substring(1);
var params = query.split('&');
for (var i = 0; i < params.length; i++) {
var pos = params[i].indexOf('=');
var key = params[i].substring(0, pos);
var val = params[i].substring(pos+1);
if (key == "size") {
var sz = parseInt(val);
size = Math.max(sz, 3);
size = Math.min(1000, size);
}
}
var log;
function log(msg) {
if (window.console != undefined) {
window.console.log(msg);
}
}
function Sort(name, func) {
this.name = name;
this.func = func;
this.size = size;
this.compare_x = null;
this.compare_y = null;
this.compares = 0;
this.swap_x = null;
this.swap_y = null;
this.swaps = 0;
this.start_time = 0;
this.stop_time = 0;
this.work_queue = new Array();
this.timer = 0;
this.last_time = 0;
this.num_iterations = 0;
this.num_jobs = 0;
this.overhead_total = 0;
this.overhead_min = 1000000;
this.overhead_max = 0;
this.processing_total = 0;
this.processing_min = 1000000;
this.processing_max = 0;
this.step_min = 1000000;
this.step_max = 0;
this.setup();
}
Sort.prototype.setup = function() {
this.size = size;
this.bars = new Array(this.size);
this.numbers = new Array(this.size);
for (i = 0; i < this.size; i++) {
this.numbers[i] = i + 1;
}
for (i = 0; i < this.size; i++) {
var r = Math.floor(Math.random() * this.numbers.length);
if (i != r) {
var tmp = this.numbers[i];
this.numbers[i] = this.numbers[r];
this.numbers[r] = tmp;
}
}
}
Sort.prototype.status = function(str) {
var label = document.getElementById(this.name + "_label");
label.innerHTML = "<b>" + this.name + " Sort</b><br />" + str;
}
Sort.prototype.stepper = function() {
if (!manual) {
var sort = this;
this.timer = setTimeout(function(){sort.stepper();},interval_time);
}
var t = new Date();
var overhead = t - this.last_time;
this.overhead_total += overhead;
this.overhead_min = Math.min(this.overhead_min, overhead);
this.overhead_max = Math.max(this.overhead_max, overhead);
this.last_time = t;
var elapsed = t - this.start_time;
var avg =
Math.floor((elapsed - this.processing_total) / this.num_iterations);
this.status("Overhead: " + avg + "ms");
var ops = 0;
for (;;) {
var count = this.work_queue.length;
if (count > 0) {
var func = this.work_queue.pop();
if (func.status != undefined) {
//this.status(func.status);
}
ops++;
this.num_jobs++;
func();
} else {
break;
}
if (manual || inner_loop_enabled == 0) {
break;
}
t = new Date();
// If any measurable time has passed, we're good.
// Since the Date has a resolution of 15ms on Windows
// there's no way to differentiate accurately for anything
// less than that. We don't want to process for longer than
// the timer interval anyway (which is about 10ms), so this
// is fine.
// NOTE: on non-windows platforms, this actually does matter since
// their timer resolution is higher
// TODO(erikkay): make this a parameter
if (t - this.last_time > 10) {
break;
}
}
var processing = t - this.last_time;
this.processing_min = Math.min(this.processing_min, processing);
this.processing_max = Math.max(this.processing_max, processing);
this.processing_total += processing;
var step_time = processing + overhead;
this.step_min = Math.min(this.step_min, step_time);
this.step_max = Math.max(this.processing_max, step_time);
this.num_iterations++;
this.last_time = new Date();
if (ops == 0) {
this.finished();
}
}
Sort.prototype.add_work = function(work, name) {
if (name != undefined) {
work.status = name;
}
this.work_queue.push(work);
}
Sort.prototype.init = function() {
this.print();
this.status("");
}
Sort.prototype.reset = function() {
this.stop();
this.start_time = 0;
this.stop_time = 0;
this.setup();
this.print();
}
Sort.prototype.start = function() {
if (this.start_time > 0) {
if (this.stop_time > 0) {
this.shuffle();
this.start_time = 0;
this.stop_time = 0;
this.status("");
return;
} else if (manual) {
this.stepper();
return;
} else {
this.finished();
return;
}
}
if (!manual) {
var t = this;
this.timer = setTimeout(function(){t.stepper();},interval_time);
}
this.compares = 0;
this.swaps = 0;
this.start_time = (new Date()).getTime();
this.last_time = this.start_time;
this.num_jobs = 0;
this.stop_time = 0;
this.overhead_total = 0;
this.overhead_min = 1000000;
this.overhead_max = 0;
this.processing_total = 0;
this.processing_min = 1000000;
this.processing_max = 0;
this.num_iterations = 0;
this.func(this);
}
Sort.prototype.cleanup = function() {
if (this.compare_x) {
this.compare_x.style.borderColor = "black";
this.compare_y.style.borderColor = "black";
}
if (this.swap_x) {
this.swap_x.style.backgroundColor = "green";
this.swap_y.style.backgroundColor = "green";
}
this.work_queue = new Array();
}
Sort.prototype.stop = function() {
if (this.timer != 0) {
clearTimeout(this.timer);
this.timer = 0;
}
this.cleanup();
}
Sort.prototype.finished = function(err) {
this.stop();
this.stop_time = (new Date()).getTime();
var total = (this.stop_time - this.start_time);
if (err == null) {
var step_avg = Math.floor(total / this.num_iterations);
var overhead = total - this.processing_total;
var overhead_avg = Math.floor(overhead / this.num_iterations);
var processing_avg = Math.floor(this.processing_total / this.num_iterations);
var table = "<table><tr><td>Times(ms)</td><td>Total</td><td>Avg</td><td>Max</td></tr>"
+ "<tr><td>Total</td><td>" + total + "</td><td>" + step_avg + "</td><td>" + this.step_max + "</tr>"
+ "<tr><td>Work</td><td>" + this.processing_total + "</td><td>" + processing_avg + "</td><td>" + this.processing_max + "</tr>"
+ "<tr><td>Overhead</td><td>" + overhead + "</td><td>" + overhead_avg + "</td><td>" + this.overhead_max + "</tr>"
+ "</table>";
this.status(table);
} else {
this.status(err);
log("error: " + err);
}
log("finished in: " + total);
}
Sort.prototype.shuffle = function() {
for (i = 0; i < this.size; i++) {
var r = Math.floor(Math.random() * this.size);
if (i != r) {
this.swap(i,r);
}
}
this.cleanup();
}
Sort.prototype.print = function() {
var graph = document.getElementById(this.name);
if (graph == undefined) {
alert("can't find " + this.name);
}
var text = "<div id='" + this.name + "_label' class='label'>" + this.name + " Sort</div>";
var len = this.numbers.length;
var height_multiple = (graph.clientHeight-20) / len;
var width = Math.max(1,Math.floor((graph.clientWidth-10) / len));
if (width < 3) {
border = 0;
} else {
border = 1;
}
var left_offset = Math.round((graph.clientWidth - (width*len))/2);
for (i = 0; i < len; i++) {
var val = this.numbers[i];
var height = Math.max(1, Math.floor(val * height_multiple));
var left = left_offset + i * width;
text += "<li class='bar' style='border: " + border + "px solid black; height:" + height + "px; left:" + left + "; width:" + width + "' id='" + this.name + val + "' value='" + val + "'></li>";
}
graph.innerHTML = text;
var nodes = document.getElementsByTagName("li");
var j = 0;
for (i = 0; i < nodes.length; i++) {
var name = nodes[i].id;
if (name.indexOf(this.name) == 0) {
this.bars[j] = nodes[i];
j++;
}
}
}
Sort.prototype.compare = function(x, y) {
var bx = this.bars[x];
var by = this.bars[y];
//log("compare " + x + "(" + bx.value + ")," + y + "(" + by.value + ")");
if (this.compare_x != bx) {
if (this.compare_x) {
this.compare_x.style.borderColor="black";
}
bx.style.borderColor="yellow";
this.compare_x = bx;
}
if (this.compare_y != by) {
if (this.compare_y) {
this.compare_y.style.borderColor="black";
}
by.style.borderColor="white";
this.compare_y = by;
}
this.compares++;
return bx.value - by.value;
}
Sort.prototype.swap = function(x, y) {
var bx = this.bars[x];
var by = this.bars[y];
//log("swap " + x + "(" + bx.value + ")," + y + "(" + by.value + ")");
if (this.swap_x != x) {
if (this.swap_x) {
this.swap_x.style.backgroundColor="green";
}
bx.style.backgroundColor="blue";
this.swap_x = bx;
}
if (this.swap_y != y) {
if (this.swap_y) {
this.swap_y.style.backgroundColor="green";
}
by.style.backgroundColor="red";
this.swap_y = by;
}
var tmp = bx.style.left;
bx.style.left = by.style.left;
by.style.left = tmp;
this.bars[x] = by;
this.bars[y] = bx;
this.swaps++;
}
Sort.prototype.insert = function(from, to) {
var bf = this.bars[from];
if (from > to) {
for (i = from; i > to; i--) {
var b1 = this.bars[i];
var b2 = this.bars[i-1];
b2.style.left = b1.style.left;
this.bars[i] = b2;
}
bf.style.left = this.bars[to].style.left;
this.bars[to] = bf;
} else {
// TODO
}
}
div.group {
width : 250px;
}
div.group h1 {
font-family: sans-serif;
font-size : 16px;
color : white;
background : red;
}
div.title {
font-family: sans-serif;
font-size : 24px;
}
div.description {
font-family: sans-serif;
}
#title {
height: 160px;
}
#leftcol {
width:50%;
}
#rightcol {
float: right;
width:50%;
}
#footer {
font-size: 12px;
position: absolute;
bottom: 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment