Opera Presto supports both the W3C Widget family of specifications and the legacy Opera Widgets format. The formats are different and not compatible. Opera Presto supports the proprietary Opera Widgets format for legacy reasons:
network="public"
The Opera security model for widgets declares that widgets do not have network access on by default. In
order to enable network access for non-intranet sites, add a network attribute to the widget element
in the config.xml of your widget with the value "public". For example:
<widget network="public">
...
</widget>
This will make your widget work as intended in Opera 10, but will not affect previous versions. Older browsers will simply ignore the network attribute and give your widget access as per the existing security model.
network="private" and network="public private"
The widget element attributes network="private" and network="public private" can
enable network access for either private networks, public networks, or both. For example:
<widget network="private">
...
</widget>
<widget network="public private">
...
</widget>
Opera Presto supports the terms of the Opera Widgets Specification 1.0 fourth edition, as described in the following data table.
| Element | Attribute(s) | Value(s) | Description | Support |
|---|---|---|---|---|
<widget>
|
Root element of a Widget configuration document | Yes | ||
defaultmode
|
Represents the preferred Widget mode for a Widget. | Yes | ||
"widget"
|
Typically rendered by Opera without user chrome; the Widget has control over its own window size. | Yes | ||
"application"
|
The Widget is assumed to be rendered in a viewport size determined by Opera. | Yes | ||
"fullscreen"
|
The Widget is expected to be rendered using the entire available viewport. | Yes | ||
dockable
|
Specifies whether the Widget supports docking where a Web document is displayed. | Yes | ||
"yes"
|
All other values are interpreted by Opera as the value "false", meaning that the Widget does not provide a
docked mode.
|
Yes | ||
transparent
|
Employed to control the Widget's use of background transparency. | Yes | ||
"yes"
|
Opera interprets all other values as "false", meaning that Opera does not make the Widget's background transparent.
|
Yes | ||
network
|
Optional. Allows an author to declare their intention to access the public network and/or private networks. It takes a space-separated list of values. | Yes | ||
"private"
|
|
Yes | ||
<widgetname>
|
|
Contains a string whose purpose is to provide a human-readable title for the Widget. | Yes | |
<width>
|
|
A value in CSS pixels, as per section 4.3.2 of CSS2.1, that represents a Widget's drawable area along the horizontal axis. | Yes | |
"integer" (0-9)
|
After whitespace normalization, a Opera interprets the resulting value as an integer (a string that only contains the characters
[0-9]). If the attribute is missing, or its value is invalid, then Opera uses the value "300". |
Yes | ||
<height>
|
|
A value in CSS pixels, as per section 4.3.2 of CSS2.1, that represents a Widget's drawable area along the vertical axis | Yes | |
"integer" (0-9)
|
After whitespace normalization, a Opera interprets the resulting value as an integer (a string that only contains the characters
[0-9]). If the attribute is missing, or its value is invalid, then Opera uses the value "300". |
Yes | ||
<widgetfile>
|
|
Points the Widget to a start file for the Widget. | Yes | |
<author>
|
|
Optional. A container element for metadata about the Widget's author. This element can contain the following child
elements:
|
Yes | |
<description>
|
|
A short plain-text description of the Widget. | Yes | |
<icon>
|
|
A path to an icon file contained within the Opera Widget package that Opera can display to the end user in appropriate contexts. | Yes | |
widthheight
|
"integer"
|
Optional. The value of width is an unsigned integer, representing the desired width of the icon in device pixels.Optional. The value of height is an unsigned integer, representing the desired height of the icon in device
pixels.
|
Yes | |
<feature>
|
|
Optional. A runtime component or functionality beyond the default set of functionality that Opera provides to a Widget at runtime (e.g., the file IO API). | Yes | |
name |
"feature"
|
The name of a feature, as represented by a URI.
Optional. Indicates to Opera if the feature is required for correct operation of the Widget. |
Yes | |
<param>
|
|
Optional. Allows declaration of parameters, which may be associated and used by <feature>.
|
Yes | |
namevalue
|
A string representing the parameter name. A string representing the parameter value. |
Yes | ||
<id>
|
|
Optional. Establishes an identity for a Widget. When used, must contain one of each of the following child elements, in any order:
|
Yes | |
<security>
|
|
Optional. A Widget's configuration document can contain a "security declaration": a declaration of the protocols, hosts,
ports, and paths that the Widget will attempt to access. When used, an author must use one of the following child elements:
|
Yes | |
<access>
|
A container element whose child elements declare which protocols, hosts, ports, and paths the Widget can use. Child elements
are:
|
Yes | ||
<content>
|
Allows authors to disable support for plug-ins within their Widgets. | Yes | ||
plugin
|
Enables the Widget to use plugin as embedded content (e.g., a Flash file).
|
Yes | ||
"yes"
|
All other values, included disallowed values, means that the Widget will not use plugin as embedded content.
|
Yes |
Opera supports the default Widgets security model. The following points are a summary of the Opera default security model for Widgets.
http and https protocols.There are two classes of networks: a private network, and a public network.
A private network, or local network is by default defined as the user's local machine, including any IP address that resolves to the local machine. Further, the IP ranges as defined by [RFC 1918], are considered to be private. These addresses are primarily being used in systems set up behind a NAT translation device, and provides machines with unique addresses where there is only one public IP address for several machines. These addresses are:
10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
In addition, when a user is within an ad-hoc network, networking equipment (including software components in operating systems), typically use the IPv4 Link-Local addresses as defined by [RFC 3927], which is also considered to be part of the local network.
169.254.0.0 - 169.254.255.255 (169.254/16 prefix)
A public network is any IP range outside the definition of a private network.
The following code example indicates that the Widget should be allowed to contact the domains example.com and example.org, but only to the path "/good" on ports 80,1337 and ports in the range 2048-4096. In addition, the Widget does not want access to plug-ins.
<widget ...>
<security>
<access>
<host>example.com</host>
<host>example.org</host>
<path>/good</path>
<port>2048-4906</port>
<port>80,1337</port>
</access>
<content plugins="no"/>
</security>
</widget>
Opera supports the widget:// protocol URL. This is defined in the following code example.
widget_protocol_url = "widget://" widget_identifier "/" [path] ["?" query] ["#" fragment]; widget_identifier = [a-z0-9]+
Opera supports the following access rules.
svg:foreignObjectand similar mechanisms are not
allowed to access resources[1] inside the Widget, or to utilize the widget:// URL space.widget: URI space from other browsing contexts than inside the Widget, or a
window that can be determined to be completely trusted and running with extended security privileges. This means that a
strict same-origin policy exists between different Widgets.widget://
protocol. This means that if a Widget includes an iframe to http://example.com/, the document on example.com is not able
to access URLs using the widget:// protocol.Opera specifies that separate Widget instances share no information at all.
The Opera Widgets security model defines the following behavior for forms and links, and ensures forms and links do not violate security policy:
The Opera Widgets security model defines the security context and behavior for embedded objects:
window.top should point to the embedding frame only.If a Widget package file contains symbolic links, leading either to a target in, or outside the Widget, the symbolic link must not be made available to the instantiated Widget: In other words, Opera does not follow the symlink.
Opera supports Widget modes. Widgets can be displayed in several different contexts or modes. An installed Widget may support several of following the modes.
Widget authors that wish to support styling Widgets separately for widgets in different modes, may use the -o-widget-mode
CSS media feature, using one of the four Widget modes as the value to specify the styling. Opera supports the following
examples.
@media all and (-o-widget-mode:application) {
/* We don't need to display fake user chrome controls, since
real chrome is provided */
.fakeChrome { display: none; }
}
@media all and (-o-widget-mode:docked) {
body { font-size: 80%; }
}
It is also possible to specifically style something in the case that the platform supports the -o-widget-mode
attribute, by not specifying a value.
@media all and (-o-widget-mode) {
div.friendlyMessage {
content: "I will be displayed if I am a modern Widget";
}
}
Opera supports the Widget scripting interfaces. The purpose of the widget object is to expose functionality
specific to Widgets.
interface Widget {
readonly attribute DOMString identifier;
readonly attribute DOMString originURL;
readonly attribute DOMString widgetMode;
void openURL(in DOMString URL);
String preferenceForKey(in DOMString key);
void setPreferenceForKey(in DOMString value,
in DOMString key);
/* Widget attention */
void getAttention();
void showNotification(in DOMString msg, in Function callback);
/* Widget window management; */
attribute Function onshow;
attribute Function onhide;
void show();
void hide();
}
identifier attributeoriginURL attributewidgetMode attributewidget, application,
fullscreen or docked.openURL() methodpreferenceForKey() methodsetPreferenceForKey
method, or undefined if the key does not exist.setPreferenceForKey() methodpreference and key. When called, Opera persistently stores the value
of preference and key. However, if called and the value of key is null and the key argument has been previously stored,
Opera deletes the key and preference from the storage area.getAttention() methodshowNotification() methodshowNotification() is called, the system is expected to display a notification containing the message
text. The message text is a DOMString and whitespace within the string, including new lines is significant. Upon the user
acknowledging the notification, the callback function is called without any arguments.
onshow attributeonshow callback, e.g. the value of the attribute is non-null and a valid
function reference, the callback will be called whenever the Widget's state changes from being hidden to being visible.
Note that the onshow callback should not be dispatched if a visible Widget gets focus.onhide attributeonhide callback, e.g. the value of the attribute is non-null
and a valid function reference, the callback will be called whenever the Widget's state changes from being visible to being
hidden. Note that the onshow callback should not be dispatched if a visible Widget loses focus.show() methodhide() methodwidgetWindow interface<width> and <height> elements
in the Widget configuration document. In addition to this, a Widget can be resized dynamically using JavaScript, with the
following extensions.
interface widgetWindow {
attribute DOMString status;
attribute DOMString defaultStatus;
void moveTo(in Integer pos_x, in Integer pos_y);
void moveBy(in Integer delta_pos_x, in Integer delta_pos_y);
void resizeTo(in Integer x_size, in Integer y_size);
void resizeBy(in Integer delta_x_size, in Integer delta_y_size);
}
status attribute: Used to display a status message in a Widget overview/managment page,
or similar. It is used to display a short piece of textual information to the user. An example could be a stock ticker that
changes to show the value of the last updated stock, to then revert to displaying a default status message. When set, the
status message is kept until it is either cancelled by clicking in the Widget document that set the status, or the value
of the attribute is set to the empty string.defaultStatus attribute: When set provides a default status message which is to be displayed
in a Widget management page, or other Widget overview mechanism. When the value of this attribute is non-null,
an action that cancels the window.status should bring up the contents of the defaultStatus attribute
in place of the original/system-provided status message. If the value is null or an empty string, the Widget
runtime should fall back to a system-provided message.moveTo() method: When the Widget is rendering in a context where the position of the Widget
may be changed, the moveTo() method sets the position of the Widget. The method accepts two arguments,
pos_x and pos_y, both Integer values, which are x and y coordinates defined by a coordinate system:
the flat cartesian surface whose origin (0,0) is at the top left corner of the available viewport, with the coordinate space
having x values increasing when going right, and y values increasing when going down.moveBy() method: When the Widget is rendering in a context where the position of the Widget
may be changed, the moveBy() method moves the Widget in the x and/or y direction using the arguments, with
the integer values delta_pos_x and delta_pos_y being defined by a coordinate system: the flat
cartesian surface whose origin (0,0) is at the top left corner of the available viewport, with the coordinate space having
x values increasing when going right, and y values increasing when going down. Negative values for both arguments are accepted,
and a negative value for either argument means that the Widget should move towards respectively the top or the left of the
viewport.resizeTo() method: When the Widget is rendering in a context where the size of the Widget
may be changed, the resizeTo() method sets the new size of the Widget, using the Integer arguments size_x
and size_y, respectively. Setting the size using resizeTo() must produce exactly the same dimensions
for the Widget, as if they appeared in the Widget configuration document values for the <width> and
<height> elements. Both the size_x and size_y arguments value must be larger than
1.resizeBy() method: The resizeBy() method should resize the Widget by adding
the values of the argument delta_x_size to the current value for the Widget width, and add the
delta_y_size to the current height of the Widget, measured in pixels. The resulting dimensions
gathered from such additions must produce exactly the same dimensions for the Widget, as if the calculated dimensions appeared
in the Widget configuration document values for the <width> and <height> elements.
Negative values for both arguments are accepted, as long as the resulting calculated size remains larger than 1x1 pixel,
in which case the resizeBy() method should result in no change to the Widget size.WidgetModeChangeEvent interface-o-widget-mode CSS attribute changes, the widgetmodechange is dispatched
on the Widget object. When the event is dispatched, the event object must have a widgetMode attribute that
corresponds to the current rendering mode. The value must be one of those mentioned for the widgetMode attribute
on the Widget interface. The WidgetModeChangeEvent must not bubble, must not be cancelable and must implement
the Event interface [DOM3Events]. The event has no namespace (Event.namespaceURI
is null).
interface WidgetModeChangeEvent : Event {
readonly attribute DOMString widgetMode;
void initMediaTypeChangeEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in DOMString widgetModeArg);
// For DOM Level 3 support
void initMediaTypeChangeEventNS(in DOMString namespaceURI,
in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
}
ResolutionEvent interfacewidget object when the width or height values
of the attached display object changes. It must not bubble, must not be cancelable and must implement the Event interface
[DOM3Events]. The event has no namespace (Event.namespaceURI
is null). When dispatched, the event object must have two attributes, width and
height corresponding to the newly available width and height attributes for the Widget.
These two values should correspond to the values availWidth and availHeight on the Screen interface.
interface ResolutionEvent : Event {
readonly attribute int width;
readonly attribute int height;
void initMediaTypeChangeEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in int widthArg,
in int heightArg);
// For DOM Level 3 support
void WidgetModeChangeEventNS(in DOMString namespaceURI,
in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in int widthArg,
in int heightArg);
}
Opera supports Widget autodiscovery.
The purpose of Widget autodiscovery is to enable clients who know a URI of a Web page to identify and find the location of a Widget associated with said Web page. Opera, as a Widget-aware Web client offers a mechanism that exposes the presence of the Widget to the user, and offers a mechanism for installing the Widget.
A Widget autodiscovery element is a <link> element, as defined in
section 12.3. of [HTML401]. As with other <link> elements, an autodiscovery element may appear
in the <head></head> element of an HTML or XHTML document, but it must not appear inside the
<body> element. An example <autodiscovery> element looks like this:
<link type="application/x-opera-widgets" rel="alternate" href="http://widgets.example.com/example.zip" title="An Example Widget" >
<autodiscovery> element appears in a [HTML401] or [XHTML10] document, the element shares
all the syntax rules and restrictions of other markup elements.<autodiscovery> elements. Opera presents an installation option for all
auto discovered Widgets to the user, listed in the order of appearance in the source code. If Opera only presents one auto
discovered Widget to the user, Opera chooses the first auto discovered Widget for installation whenever the user opts to
install the Widget.type attribute<autodiscovery> element. The value of the type attribute must
be an Internet Media type, and the media type must be application/x-opera-widgets.rel attribute<autodiscovery> element. As defined in section 6.12 of [HTML401], the value
of the rel attribute is a space-sparated list of keywords. The list of keywords must include the keyword alternate
in uppercase, lowercase, or mixed case.href attribute<autodiscovery> element, and its value must be the URI of the Widget. The
value may be a relative URI, and if so, clients must resolve it to a full URI, using the document's base URI. The URIs must
conform to [RFC3987].title attribute<autodiscovery> element. Opera treats the value of the title
attribute as a human-readable title for the Widget, and Opera presents this title to the user.Need help? Hit F1 anytime while using Opera to access our online help files, or go here.