Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit of code to test Opera's security sandboxing of XMLHttp…

…Requests
  • Loading branch information...
commit f7297370d3d207e9520cb7b2b6edfcdf6e9cf1fc 0 parents
@pr1001 authored
62 ajaxtest.js
@@ -0,0 +1,62 @@
+var ajaxTestObject = Class.create({
+ logbox: new Element('div', {id: 'logbox'}),
+ initialize: function() {
+ /* Some helper vars */
+ this.isOpera = (typeof(opera) != 'undefined');
+
+ /* Abstract out Opera's special console logging method */
+ if (this.isOpera && typeof(opera.postError) != 'undefined') {
+ window.console = (window.console || {});
+ console.log = opera.postError;
+ }
+
+ /* Beginning Tests */
+ this.log('Starting testing...');
+
+ /* Get XML file */
+ this.log('test.xml');
+ this.request({path: 'test.xml'});
+
+ /* Get HTML file */
+ this.log('test.html');
+ this.request({path: 'test.html'});
+
+ /* Get JSON file */
+ this.log('test.json');
+ this.request({path: 'test.json'});
+
+ Element.observe(window, 'load', function() { ajaxTest.dumpLogs(); });
+ },
+ dumpLogs: function() {
+ document.body.appendChild(ajaxTest.logbox);
+ },
+ log: function(message) {
+ var d = new Date;
+ message = d + ': ' + message;
+ console.log(message);
+ this.logbox.insert({bottom: new Element('p').update(message)});
+ },
+ request: function(params) {
+ params.onSuccess = (params.onSuccess || this.onSuccess);
+ params.onFailure = (params.onFailure || this.onFailure);
+ params.isAsync = (params.isAsync || true);
+ new Ajax.Request(params.path, {
+ asynchronous: params.isAsync,
+ onSuccess: params.onSuccess,
+ onFailure: params.onFailure
+ });
+ },
+ onSuccess: function(transport) {
+ ajaxTest.log(transport.request.url + ' AJAX request succeeded. Status code: ' + transport.status);
+ ajaxTest.log(transport.request.url + ' headers exist: ' + (transport.getAllHeaders() ? true : false));
+ ajaxTest.log(transport.request.url + ' responseXML exists: ' + (transport.responseXML ? true : false));
+ ajaxTest.log(transport.request.url + ' responseText exists: ' + (transport.responseText ? true : false));
+ ajaxTest.log(transport.request.url + ' responseText length: ' + transport.responseText.length);
+ ajaxTest.log(transport.request.url + ' headerJSON exists: ' + (transport.headerJSON ? true : false));
+ },
+ onFailure: function(transport) {
+ ajaxTest.log('AJAX request failed. Status code: ' + transport.status);
+ }
+});
+
+var ajaxTest = new ajaxTestObject();
12 config.xml
@@ -0,0 +1,12 @@
+<widget id="com.bubblefoundry.operaajaxtest" dockable="no">
+ <widgetname>Opera AJAX Test</widgetname>
+ <description>A widget that tests whether Opera allows AJAX requests to local widget files.</description>
+ <width>320</width>
+ <height>240</height>
+ <author>
+ <name>Peter Robinett</name>
+ <organization>Bubble Foundry</organization>
+ <link>http://www.bubblefoundry.com</link>
+ <email>thefoundry@bubblefoundry.com</email>
+ </author>
+</widget>
13 index.html
@@ -0,0 +1,13 @@
+<html>
+
+<head>
+ <title>Opera AJAX Test</title>
+ <script type="text/javascript" src="prototype-1.6.0.3.js"></script>
+ <script type="text/javascript" src="ajaxtest.js"></script>
+</head>
+
+<body>
+ <h2 id="title">Opera AJAX Test</h2>
+</body>
+
+</html>
4,320 prototype-1.6.0.3.js
4,320 additions, 0 deletions not shown
12 test.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+
+<head>
+</head>
+
+
+<body>
+ A simple HTML document.
+</body>
+
+</html>
4 test.json
@@ -0,0 +1,4 @@
+{
+ simple: "JSON testing",
+ so: ['this', 'should', 'work']
+}
12 test.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<test>
+ <item>
+ <el some="attribute" />
+ <an>element</an>
+ </item>
+ <item>
+ <el some="attribute x2" />
+ <an>element x2</an>
+ </item>
+</test>
Please sign in to comment.
Something went wrong with that request. Please try again.