com.gargoylesoftware.htmlunit.javascript.host.Screen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of htmlunit Show documentation
Show all versions of htmlunit Show documentation
A headless browser intended for use in testing web-based applications.
/*
* Copyright (c) 2002-2015 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gargoylesoftware.htmlunit.javascript.host;
import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_SCREEN_SETTER_THROWS_ERROR;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF;
import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClasses;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser;
import net.sourceforge.htmlunit.corejs.javascript.Context;
/**
* A JavaScript object for a Screen. Combines properties from both Mozilla's DOM and IE's DOM.
*
* @version $Revision: 10780 $
* @author Mike Bowler
* @author Daniel Gredler
* @author Chris Erskine
* @author Ronald Brill
* @author Ahmed Ashour
*
* @see
* MSDN documentation
* @see Mozilla documentation
*/
@JsxClasses({
@JsxClass(browsers = { @WebBrowser(CHROME), @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 11) }),
@JsxClass(isJSObject = false, browsers = @WebBrowser(value = IE, maxVersion = 8))
})
public class Screen extends SimpleScriptable {
private int bufferDepth_;
/**
* Creates an instance.
*/
@JsxConstructor({ @WebBrowser(CHROME), @WebBrowser(FF) })
public Screen() {
bufferDepth_ = 0;
}
/**
* Returns the availHeight property.
* @return the availHeight property
*/
@JsxGetter
public int getAvailHeight() {
return 768;
}
/**
* Sets the availHeight property.
* @param availHeight the availHeight property
*/
@JsxSetter
public void setAvailHeight(final int availHeight) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.availHeight is read only");
}
// otherwise ignore
}
/**
* Returns the availLeft property.
* @return the availLeft property
*/
@JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME) })
public int getAvailLeft() {
return 0;
}
/**
* Sets the availLeft property.
* @param availLeft the availLeft property
*/
@JsxSetter({ @WebBrowser(FF), @WebBrowser(CHROME) })
public void setAvailLeft(final int availLeft) {
// otherwise ignore
}
/**
* Returns the availTop property.
* @return the availTop property
*/
@JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME) })
public int getAvailTop() {
return 0;
}
/**
* Sets the availTop property.
* @param availTop the availTop property
*/
@JsxSetter({ @WebBrowser(FF), @WebBrowser(CHROME) })
public void setAvailTop(final int availTop) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.availTop is read only");
}
// otherwise ignore
}
/**
* Returns the availWidth property.
* @return the availWidth property
*/
@JsxGetter
public int getAvailWidth() {
return 1024;
}
/**
* Sets the availWidth property.
* @param availWidth the availWidth property
*/
@JsxSetter
public void setAvailWidth(final int availWidth) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.availWidth is read only");
}
// otherwise ignore
}
/**
* Returns the bufferDepth property.
* @return the bufferDepth property
*/
@JsxGetter(@WebBrowser(IE))
public int getBufferDepth() {
return bufferDepth_;
}
/**
* Sets the bufferDepth property.
* @param bufferDepth the bufferDepth property
*/
@JsxSetter(@WebBrowser(IE))
public void setBufferDepth(final int bufferDepth) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
bufferDepth_ = -1;
}
// otherwise ignore
}
/**
* Returns the colorDepth property.
* @return the colorDepth property
*/
@JsxGetter
public int getColorDepth() {
return 24;
}
/**
* Sets the colorDepth property.
* @param colorDepth the colorDepth property
*/
@JsxSetter
public void setColorDepth(final int colorDepth) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.colorDepth is read only");
}
// otherwise ignore
}
/**
* Returns the deviceXDPI property.
* @return the deviceXDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getDeviceXDPI() {
return 96;
}
/**
* Sets the deviceXDPI property.
* @param deviceXDPI the deviceXDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setDeviceXDPI(final int deviceXDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.deviceXDPI is read only");
}
// otherwise ignore
}
/**
* Returns the deviceYDPI property.
* @return the deviceYDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getDeviceYDPI() {
return 96;
}
/**
* Sets the deviceYDPI property.
* @param deviceYDPI the deviceYDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setDeviceYDPI(final int deviceYDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.deviceYDPI is read only");
}
// otherwise ignore
}
/**
* Returns the fontSmoothingEnabled property.
* @return the fontSmoothingEnabled property
*/
@JsxGetter(@WebBrowser(IE))
public boolean getFontSmoothingEnabled() {
return true;
}
/**
* Sets the fontSmoothingEnabled property.
* @param fontSmoothingEnabled the fontSmoothingEnabled property
*/
@JsxSetter(@WebBrowser(IE))
public void setFontSmoothingEnabled(final boolean fontSmoothingEnabled) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.fontSmoothingEnabled is read only");
}
// otherwise ignore
}
/**
* Returns the height property.
* @return the height property
*/
@JsxGetter
public int getHeight() {
return 768;
}
/**
* Sets the height property.
* @param height the height property
*/
@JsxSetter
public void setHeight(final int height) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.height is read only");
}
// otherwise ignore
}
/**
* Returns the left property.
* @return the left property
*/
@JsxGetter(@WebBrowser(FF))
public int getLeft() {
return 0;
}
/**
* Sets the left property.
* @param left the left property
*/
@JsxSetter(@WebBrowser(FF))
public void setLeft(final int left) {
// ignore
}
/**
* Returns the logicalXDPI property.
* @return the logicalXDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getLogicalXDPI() {
return 96;
}
/**
* Sets the logicalXDPI property.
* @param logicalXDPI the logicalXDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setLogicalXDPI(final int logicalXDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.logicalXDPI is read only");
}
// otherwise ignore
}
/**
* Returns the logicalYDPI property.
* @return the logicalYDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getLogicalYDPI() {
return 96;
}
/**
* Sets the logicalYDPI property.
* @param logicalYDPI the logicalYDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setLogicalYDPI(final int logicalYDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.logicalYDPI is read only");
}
// otherwise ignore
}
/**
* Returns the pixelDepth property.
* @return the pixelDepth property
*/
@JsxGetter
public int getPixelDepth() {
return 24;
}
/**
* Sets the pixelDepth property.
* @param pixelDepth the pixelDepth property
*/
@JsxSetter
public void setPixelDepth(final int pixelDepth) {
// ignore
}
/**
* Returns the systemXDPI property.
* @return the systemXDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getSystemXDPI() {
return 96;
}
/**
* Sets the systemXDPI property.
* @param systemXDPI the systemXDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setSystemXDPI(final int systemXDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.systemYDPI is read only");
}
// otherwise ignore
}
/**
* Returns the systemYDPI property.
* @return the systemYDPI property
*/
@JsxGetter(@WebBrowser(IE))
public int getSystemYDPI() {
return 96;
}
/**
* Sets the systemYDPI property.
* @param systemYDPI the systemYDPI property
*/
@JsxSetter(@WebBrowser(IE))
public void setSystemYDPI(final int systemYDPI) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.systemYDPI is read only");
}
// otherwise ignore
}
/**
* Returns the top property.
* @return the top property
*/
@JsxGetter(@WebBrowser(FF))
public int getTop() {
return 0;
}
/**
* Sets the top property.
* @param top the top property
*/
@JsxSetter(@WebBrowser(FF))
public void setTop(final int top) {
// ignore
}
/**
* Returns the updateInterval property.
* @return the updateInterval property
*/
@JsxGetter(@WebBrowser(value = IE, maxVersion = 8))
public int getUpdateInterval() {
return 0;
}
/**
* Returns the width property.
* @return the width property
*/
@JsxGetter
public int getWidth() {
return 1024;
}
/**
* Sets the width property.
* @param width the width property
*/
@JsxSetter
public void setWidth(final int width) {
if (getBrowserVersion().hasFeature(JS_SCREEN_SETTER_THROWS_ERROR)) {
throw Context.reportRuntimeError("screen.width is read only");
}
// otherwise ignore
}
}