/*
 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

interface TestRunner {
    // The basics.
    void dumpAsText(in boolean dumpPixels);
    void dumpChildFramesAsText();
    void waitForPolicyDelegate();
    void waitUntilDone();
    void notifyDone();
    double preciseTime();

    // Other dumping.
    void dumpBackForwardList();
    void dumpChildFrameScrollPositions();
    void dumpEditingCallbacks();
    void dumpSelectionRect();
    void dumpStatusCallbacks();
    void dumpTitleChanges();
    void dumpFullScreenCallbacks();
    void dumpFrameLoadCallbacks();
    void dumpProgressFinishedCallback();
    void dumpResourceLoadCallbacks();
    void dumpResourceResponseMIMETypes();
    void dumpWillCacheResponse();
    void dumpApplicationCacheDelegateCallbacks();
    void dumpDatabaseCallbacks();

    // Special options.
    void keepWebHistory();
    void setAcceptsEditing(in boolean value);
    void setCanOpenWindows(in boolean value);
    void setCloseRemainingWindowsWhenComplete(in boolean value);
    void setXSSAuditorEnabled(in boolean value);
    void setAllowUniversalAccessFromFileURLs(in boolean value);
    void setAllowFileAccessFromFileURLs(in boolean value);
    void setPluginsEnabled(in boolean value);
    void setJavaScriptCanAccessClipboard(in boolean value);
    void setPrivateBrowsingEnabled(in boolean value);
    void setPopupBlockingEnabled(in boolean value);
    void setAuthorAndUserStylesEnabled(in boolean value);
    void setCustomPolicyDelegate(in boolean enabled, in boolean permissive);
    void addOriginAccessWhitelistEntry(in DOMString sourceOrigin, in DOMString destinationProtocol, in DOMString destinationHost, in boolean allowDestinationSubdomains);
    void removeOriginAccessWhitelistEntry(in DOMString sourceOrigin, in DOMString destinationProtocol, in DOMString destinationHost, in boolean allowDestinationSubdomains);
    void setUserStyleSheetEnabled(in boolean value);
    void setUserStyleSheetLocation(in DOMString location);
    void setSpatialNavigationEnabled(in boolean value);
    void setTabKeyCyclesThroughElements(in boolean enabled);
    void setSerializeHTTPLoads();
    void dispatchPendingLoadRequests();
    void setCacheModel(in int model);

    // Special DOM functions.
    void clearBackForwardList();
    object computedStyleIncludingVisitedInfo(in object element);
    void execCommand(in DOMString name, in DOMString argument);
    boolean isCommandEnabled(in DOMString name);
    DOMString markerTextForListItem(in object element);
    unsigned long windowCount();

    // Special DOM variables.
    attribute boolean globalFlag;

    // Repaint testing.
    void testRepaint();
    void repaintSweepHorizontally();
    void display();

    // Printing
    boolean isPageBoxVisible(in int pageIndex);

    [PassContext] void setValueForUser(in object element, in DOMString value);

    // UserContent testing.
    void addUserScript(in DOMString source, in boolean runAtStart, in boolean allFrames);
    void addUserStyleSheet(in DOMString source, in boolean allFrames);

    // Local storage API
    void clearAllDatabases();
    void setDatabaseQuota(in unsigned long long quota);
    DOMString pathToLocalResource(in DOMString url);

    // Application Cache API
    void clearAllApplicationCaches();
    void setAppCacheMaximumSize(in unsigned long long size);
    long long applicationCacheDiskUsageForOrigin(in DOMString origin);
    void clearApplicationCacheForOrigin(in DOMString name);
    void setApplicationCacheOriginQuota(in unsigned long long bytes);
    void disallowIncreaseForApplicationCacheQuota();
    object originsWithApplicationCache();

    // Text search testing.
    boolean findString(in DOMString target, in object optionsArray);

    // Evaluating script in a special context.
    [PassContext] void evaluateScriptInIsolatedWorld(in unsigned long worldID, in DOMString script);

    // For Web Inspector tests
    void showWebInspector();
    void closeWebInspector();
    void evaluateInWebInspector(in long callID, in DOMString script);

    void setPOSIXLocale(in DOMString locale);

    void setTextDirection(in DOMString direction);

    void setWillSendRequestReturnsNull(in boolean flag);
    void setWillSendRequestReturnsNullOnRedirect(in boolean flag);
    
    void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);

    void setDefersLoading(in boolean flag);
    void setStopProvisionalFrameLoads();

    // Focus testing.
    void addChromeInputField(in object callback);
    void removeChromeInputField(in object callback);
    void focusWebView(in object callback);

    void setBackingScaleFactor(in double backingScaleFactor, in object callback);

    void setWindowIsKey(in boolean isKey);

    // Cookies testing
    void setAlwaysAcceptCookies(in boolean accept);

    void overridePreference(in DOMString preference, in DOMString value);

    // Page Visibility API
    void setPageVisibility(in DOMString state);
    void resetPageVisibility();

    readonly attribute DOMString platformName;

    // Control full screen behavior.
    void setHasCustomFullScreenBehavior(in boolean value);
    void setViewModeMediaFeature(in DOMString mode);

    // Web notifications support
    void grantWebNotificationPermission(in DOMString origin);
    void denyWebNotificationPermission(in DOMString origin);
    void removeAllWebNotificationPermissions();
    void simulateWebNotificationClick(in object notification);

    // Geolocation
    void setGeolocationPermission(in boolean value);
    void setMockGeolocationPosition(in double latitude, in double longitude, in double accuracy, in [Optional=DefaultIsUndefined] object altitude, in [Optional] object altitudeAccuracy, in [Optional] object heading, in [Optional] object speed);
    void setMockGeolocationPositionUnavailableError(in DOMString errorMessage);

    // Audio testing.
    [PassContext] void setAudioData(in object data);

    boolean callShouldCloseOnWebView();

    // Work queue.
    void queueBackNavigation(in unsigned long howFarBackward);
    void queueForwardNavigation(in unsigned long howFarForward);
    void queueLoad(in DOMString url, in DOMString target);
    void queueLoadHTMLString(in DOMString content, in [Optional] DOMString baseURL, in [Optional] DOMString unreachableURL);
    void queueReload();
    void queueLoadingScript(in DOMString script);
    void queueNonLoadingScript(in DOMString script);

    // Authentication
    void setHandlesAuthenticationChallenges(in boolean value);
    void setAuthenticationUsername(in DOMString username);
    void setAuthenticationPassword(in DOMString password);
};

