Skip to content

Commit 4ac0ec3

Browse files
committed
Initial commit of files from Google Code project https://code.google.com/p/mraid-web-tester/ including new look and feel as default.
1 parent e47714b commit 4ac0ec3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+7249
-2
lines changed

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
1-
webtester
2-
=========
1+
# MRAID WebTester, a certified MRAID v2 container
2+
3+
MRAID WebTester is a community-driven tool to run MRAID ad units in a web environment. This provides a way to confirm that you are using the MRAID design specification correctly even if you don't have an SDK or app.
4+
5+
## Using the tool
6+
7+
The easiest way to use the tool is to navigate to http://webtester.mraid.org/. This site represents the master branch and you don't need to download any additional files.
8+
9+
PREPARE: One the first screen, provide the properties for your test environment
10+
* Geometry: These are the measurements for your default ad size, maximum ad size, and screen size. You can update these values either by dragging and resizing the preview boxes, or by entering values into the form.
11+
* API version: You may select between either version 1 of the API or version 2. Most SDKs are Version 2.
12+
* Placement: You may choose between Inline or Interstitial placement as defined by the MRAID specification.
13+
* Off-Screen: When you choose "Off-Screen", the tester provides pages and navigation to slide your ad into view
14+
* Native features to emulate: Choose the features that best mirror the type of device you are developing for
15+
* Click "Next" or the Flight tab when ready to continue
16+
17+
FLIGHT: On the second screen, provide the ad tag
18+
* Tag Source: This is the text box for your HTML tag. This should be HTML and not a URL.
19+
* Click "Render" to continue
20+
21+
TEST: The last screen allows you to see the MRAID interactions in your ad unit
22+
* A pop-up attempts to display your ad unit in a web-based MRAID container
23+
* Console: Output from the container is logged to this text area in reverse-chronological order...use Error, Info, and Clear to limit the output to the screen.
24+
* Controls: A landscape control button allows you to simulate device orientation changes...click on the clock icon to toggle this control on a regular timing.
25+
26+
You can then use web developer tools to see additional console logging on the pop-up container.
27+
28+
29+
## Integrating with the Online WebTester
30+
31+
The online web tester provides one integration point: the querystring variable "adtag". Use this as a key-value pair for injecting your HTML into the Flight tab. For example, to inject an HTML tag like this <h1>hello world</h1> into the web tester when you start it, add an adtag query string with URL encoding like this:
32+
http://webtester.mraid.org/index.html?adtag=%3Ch1%3Ehello%20world%3C%2Fh1%3E
33+
34+
35+
## MRAID compliance ads
36+
37+
The MRAID Version 2 API requires that any certified container must run the compliance ads developed by the IAB. These ad units are included in this project for your convenience.
38+
39+
40+
## Reporting a bug
41+
42+
To report a bug simply create a new GitHub Issue and describe your problem or suggestion. However, you may want to join the MRAID WebTester forum to get some input from the coders supporting this project. https://groups.google.com/forum/#!forum/mraid-web-tester
43+
44+
## License
45+
46+
The MRAID WebTester is distributed under the BSD License.
47+
48+
## Thank you!
49+
50+
We really appreciate all kind of feedback and contributions. Thanks for using and supporting MRAID WebTester!
143 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script src="http://webtester.mraid.org/compliance/assets/expand-onepart.js"></script>
2+
<div id="aroniabtestad">
3+
4+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script src="mraid.js"></script>
2+
<script src="http://webtester.mraid.org/compliance/assets/expand-twopart.js"></script>
3+
4+
<div id="arontwopartwrap">
5+
6+
<a href="#" onclick="twopart(); return false;" id="twopart">Two Part Expand</a>
7+
8+
</div>

compliance/units/interstitial.htm

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
<!-- This IAB MRAID test creative was built by Adam Schuetz, currently Senior Director of Engineering at AdMarvel on 10/11/2013 -->
2+
3+
<script src="mraid.js"></script>
4+
5+
<div id="container" style="width:320px;height:480px;background-color:#000000;">
6+
<video id="adVideo" webkit-playsinline src="http://once.unicornmedia.com/now/od/auto/d8371d05-0b04-42fc-892f-b0e9ad6db2b5/6fd31a0f-775a-49ca-849b-228d70b5f9ac/87c56e71-2005-473c-a8da-2d45053413a9/578-1588-iab-video-small.mp4"></video>
7+
</div>
8+
9+
<style type="text/css">
10+
body
11+
{
12+
background-color:#000000;
13+
}
14+
</style>
15+
16+
<script language="javascript" type="text/javascript">
17+
document.getElementById("container").addEventListener('touchmove', function(event) { event.preventDefault(); }, false);
18+
</script>
19+
20+
<script>
21+
function mraidIsReady()
22+
{
23+
mraid.removeEventListener("ready", mraidIsReady);
24+
25+
prepareMyAd();
26+
}
27+
28+
function prepareMyAd()
29+
{
30+
// Right now it is assumed this SDK supports HTML5 video but may not support inline
31+
if (mraid.supports("inlineVideo"))
32+
{
33+
// Hide close button
34+
mraid.useCustomClose(true);
35+
}
36+
37+
// Force landscape orientation
38+
mraid.setOrientationProperties({"allowOrientationChange":false, "forceOrientation":"landscape"});
39+
40+
// Adjust dimensions for device using current orientation to find landscape values
41+
var screenSize = mraid.getScreenSize();
42+
var screenLandscapeWidth = screenSize.width;
43+
var screenLandscapeHeight = screenSize.height;
44+
if ( (window.orientation == 0) || (window.orientation == 180) )
45+
{
46+
// If device is in portrait swap dimensions
47+
screenLandscapeWidth = screenSize.height;
48+
screenLandscapeHeight = screenSize.width;
49+
}
50+
51+
document.getElementById("container").style.width = screenLandscapeWidth + "px";
52+
document.getElementById("container").style.height = screenLandscapeHeight + "px";
53+
54+
// First video to fit full width and and then scale height
55+
var videoWidth = 320;
56+
var videoHeight = 180;
57+
var videoRatio = videoWidth/videoHeight;
58+
var newWidth = videoWidth;
59+
var newHeight = videoHeight;
60+
if(videoWidth > screenLandscapeWidth)
61+
{
62+
newWidth = screenLandscapeWidth;
63+
newHeight = newWidth/videoRatio;
64+
}
65+
else
66+
{
67+
newWidth = Math.max(screenLandscapeWidth, videoWidth);
68+
newHeight = newWidth/videoRatio;
69+
}
70+
71+
// If scaled height too big then scale back until it fits
72+
if (newHeight > screenLandscapeHeight)
73+
{
74+
videoRatio = videoHeight/videoWidth;
75+
76+
newHeight = screenLandscapeHeight;
77+
newWidth = newHeight/videoRatio;
78+
}
79+
80+
// Calculate margins to center
81+
var topBottomMargins = (screenLandscapeHeight - newHeight)/2.0;
82+
var leftRightMargins = (screenLandscapeWidth - newWidth)/2.0;
83+
84+
// Update video dimensions
85+
var video = document.getElementById("adVideo");
86+
video.style.width = newWidth + "px";
87+
video.style.height = newHeight + "px";
88+
video.style.margin = topBottomMargins + "px " + leftRightMargins + "px";
89+
90+
// Add event listeners
91+
mraid.addEventListener("stateChange", handleStateChanged);
92+
mraid.addEventListener("error", errorHandler);
93+
94+
// See if ad is visible yet otherwise wait for it to be visible.
95+
if (!mraid.isViewable())
96+
{
97+
mraid.addEventListener("viewableChange", isInterstitialViewable);
98+
}
99+
else
100+
{
101+
showMyAd();
102+
}
103+
}
104+
105+
function handleStateChanged(state)
106+
{
107+
logMRAIDMessage("state change event fired!: state = " + state);
108+
109+
if (state == "hidden")
110+
{
111+
logMRAIDMessage("Interstitial has become hidden which means interstitial was closed.");
112+
}
113+
}
114+
115+
function errorHandler(message, action)
116+
{
117+
logMRAIDMessage("error event fired!: message = " + message + ", action = " + action);
118+
}
119+
120+
function logMRAIDMessage(message)
121+
{
122+
// Replace this method with whatever logging best works for your test environment
123+
console.log("MRAID: " + message);
124+
}
125+
126+
function isInterstitialViewable(displayed)
127+
{
128+
if (displayed)
129+
{
130+
mraid.removeEventListener("viewableChange", isInterstitialViewable);
131+
mraid.addEventListener("viewableChange", isInterstitialNotViewable);
132+
showMyAd();
133+
}
134+
}
135+
136+
function isInterstitialNotViewable(displayed)
137+
{
138+
if (!displayed)
139+
{
140+
logMRAIDMessage("Interstitial has become not viewable after having been displayed.");
141+
}
142+
}
143+
144+
function showMyAd()
145+
{
146+
// Count impressions at this point and play video ad
147+
document.getElementById("adVideo").load();
148+
document.getElementById("adVideo").play();
149+
150+
// If we can play inline then we can auto close the ad on finish
151+
if (mraid.supports("inlineVideo"))
152+
{
153+
// Close video on finish
154+
document.getElementById("adVideo").addEventListener('ended', function()
155+
{
156+
mraid.close();
157+
});
158+
}
159+
}
160+
161+
function setupViewport(width)
162+
{
163+
var element = document.querySelector("meta[name=viewport]");
164+
if (!element)
165+
{
166+
element = document.createElement("meta");
167+
element.name = "viewport";
168+
element.content = "width=" + width + ", user-scalable=no";
169+
document.getElementsByTagName('head')[0].appendChild(element);
170+
}
171+
else
172+
{
173+
element.content = "width=" + width + ", user-scalable=no";
174+
}
175+
}
176+
setupViewport(320);
177+
178+
function doReadyCheck()
179+
{
180+
if (mraid.getState() == 'loading')
181+
{
182+
mraid.addEventListener("ready", mraidIsReady);
183+
}
184+
else
185+
{
186+
prepareMyAd();
187+
}
188+
}
189+
190+
doReadyCheck();
191+
</script>

0 commit comments

Comments
 (0)