• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/ruby
2# iExploder - Generates bad HTML files to perform QA for web browsers.
3# Developed for the Mozilla Foundation.
4#####################
5#
6# Copyright (c) 2006 Thomas Stromberg <thomas%stromberg.org>
7#
8# This software is provided 'as-is', without any express or implied warranty.
9# In no event will the authors be held liable for any damages arising from the
10# use of this software.
11#
12# Permission is granted to anyone to use this software for any purpose,
13# including commercial applications, and to alter it and redistribute it
14# freely, subject to the following restrictions:
15#
16# 1. The origin of this software must not be misrepresented; you must not
17# claim that you wrote the original software. If you use this software in a
18# product, an acknowledgment in the product documentation would be appreciated
19# but is not required.
20#
21# 2. Altered source versions must be plainly marked as such, and must not be
22# misrepresented as being the original software.
23#
24# 3. This notice may not be removed or altered from any source distribution.
25
26require 'webrick'
27require 'iexploder';
28require 'config';
29
30include WEBrick
31### THE INTERACTION ##################################
32$ie_preload = IExploder.new($HTML_MAX_TAGS, $HTML_MAX_ATTRS, $CSS_MAX_PROPS)
33$ie_preload.readTagFiles()
34$ie_preload.url='/iexploder.cgi'
35
36if ARGV[0]
37	port = ARGV[0].to_i
38else
39	port = 2000
40end
41
42puts "* iExploder #{$VERSION} will be available at http://localhost:#{port}"
43puts "* Max Tags: #$HTML_MAX_TAGS Max Attrs: #$HTML_MAX_ATTRS Max Props: #$CSS_MAX_PROPS"
44puts
45
46s = HTTPServer.new( :Port => port )
47class IEServlet < HTTPServlet::AbstractServlet
48    def do_GET(req, res)
49        ie = $ie_preload.dup
50        ie.test_num = req.query['test'].to_i
51        ie.subtest_num = req.query['subtest'].to_i || 0
52        ie.random_mode = req.query['random']
53        ie.lookup_mode = req.query['lookup']
54        ie.stop_num = req.query['stop'].to_i
55        ie.setRandomSeed
56
57        res['Content-Type'] = 'text/html'
58        res.body = ie.buildPage()
59    end
60end
61
62class IEForm < HTTPServlet::AbstractServlet
63    def do_GET(req, res)
64        res['Content-Type'] = 'text/html'
65        res.body = File.open("index.html").readlines.join("\n")
66    end
67end
68
69
70
71s.mount("/iexploder.cgi", IEServlet)
72s.mount("/", IEForm)
73trap("INT") { s.shutdown }
74
75s.start
76