883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
397 lines
24 KiB
Lua
397 lines
24 KiB
Lua
local root = assert(arg[1])
|
|
SlashCmdList = {}
|
|
local diagnosticMessages = {}
|
|
DEFAULT_CHAT_FRAME = { AddMessage = function(_, text) diagnosticMessages[#diagnosticMessages + 1] = text end }
|
|
local calls, actions, wrapped = {}, {}, {}
|
|
local combat, class, currentForm, page, pickup = false, "WARRIOR", 1, 1, false
|
|
local ownedForms = {2457, 71, 2458}
|
|
local learned = { [2457]=true, [71]=true, [2458]=true, [11578]=true, [20617]=true }
|
|
local frames = {}
|
|
local keyBindings, effectiveBindings, overrides = {}, {}, {}
|
|
function GetBindingKey(command) return unpack(keyBindings[command] or {}) end
|
|
function GetBindingAction(key) return effectiveBindings[key] end
|
|
function SetOverrideBindingClick(owner, priority, key, name, button) overrides[key] = {owner=owner,name=name,button=button,priority=priority} end
|
|
function ClearOverrideBindings(owner) for key, binding in pairs(overrides) do if binding.owner == owner then overrides[key] = nil end end end
|
|
function SetBinding() error("persistent user binding changed") end
|
|
function SaveBindings() error("persistent user binding saved") end
|
|
function SecureHandlerSetFrameRef(button, name, target) button.refs = button.refs or {}; button.refs[name] = target end
|
|
local restrictedHandleContext = false
|
|
local function restrictedCall(callback, ...)
|
|
local previous = restrictedHandleContext
|
|
restrictedHandleContext = true
|
|
local first, second = callback(...)
|
|
restrictedHandleContext = previous
|
|
return first, second
|
|
end
|
|
function SecureButton_GetModifiedAttribute(button, name)
|
|
local value = button:GetAttribute(name)
|
|
if not value and button.parent and button:GetAttribute("useparent*") then
|
|
return SecureButton_GetModifiedAttribute(button.parent, name)
|
|
end
|
|
return value
|
|
end
|
|
local function frame(name)
|
|
local f = { attrs={}, name=name, id=0 }
|
|
function f:SetAttribute(k,v) self.attrs[k]=v end
|
|
function f:GetAttribute(k) return self.attrs[k] end
|
|
-- Only restricted frame handles expose this method in the original UI.
|
|
setmetatable(f, {__index=function(_, key)
|
|
if key == "GetEffectiveAttribute" and restrictedHandleContext then
|
|
return function(self, k, button) return SecureButton_GetModifiedAttribute(self, k, button) end
|
|
end
|
|
end})
|
|
function f:GetID() return self.id end
|
|
function f:SetID(id) self.id=id end
|
|
function f:GetName() return self.name end
|
|
function f:GetFrameRef(key) return self.refs and self.refs[key] end
|
|
function f:RegisterForClicks(...) end
|
|
function f:EnableMouse(v) end
|
|
function f:SetSize(...) end
|
|
function f:SetPoint(...) end
|
|
function f:RegisterEvent(...) end
|
|
function f:SetScript(k,v) self[k]=v end
|
|
function f:IsProtected() return true end
|
|
function f:IsForbidden() return false end
|
|
frames[#frames+1]=f
|
|
return f
|
|
end
|
|
_G.UIParent=frame("UIParent")
|
|
function CreateFrame(kind,name,parent,template)
|
|
local f=frame(name)
|
|
f.parent=parent
|
|
if name then _G[name]=f end
|
|
return f
|
|
end
|
|
function InCombatLockdown() return combat end
|
|
function UnitClass() return "Warrior",class end
|
|
function IsPlayerSpell(id) return learned[id] end
|
|
function GetNumShapeshiftForms() return #ownedForms end
|
|
function GetShapeshiftFormInfo(i) return 1,false,true,ownedForms[i] end
|
|
function GetShapeshiftForm() return currentForm end
|
|
function GetActionBarPage() return page end
|
|
function GetActionInfo(slot) local a=actions[slot] or {};return a[1],a[2] end
|
|
function IsModifiedClick() return pickup end
|
|
function SecureHandlerWrapScript(button,script,owner,before,after)
|
|
wrapped[button]={owner=owner,before=before,after=after}
|
|
end
|
|
local actionButton=frame("ActionButton1")
|
|
actionButton.id=1;actionButton.attrs.type="action"
|
|
ActionBarButtonEventsFrame={ ForEachFrame=function(self,callback)callback(actionButton)end }
|
|
dofile(root.."/client_addons/WoWHybridWarriorStance/SourcePolicies.lua")
|
|
dofile(root.."/client_addons/WoWHybridWarriorStance/WarriorStance.lua")
|
|
local api=WoWHybridWarriorStance
|
|
local assertions=0
|
|
local function check(value,msg) assertions=assertions+1;assert(value,msg) end
|
|
local function eq(a,b,msg)check(a==b,msg or tostring(a).." ~= "..tostring(b))end
|
|
check(actionButton.GetEffectiveAttribute == nil,
|
|
"ordinary action buttons must not expose restricted handle methods")
|
|
if arg[2] == "--action-slot-only" or arg[2] == "--action-fallback-only" or arg[2] == "--action-slot-branches-only" then
|
|
-- New integration only: execute the pinned original parent-attribute,
|
|
-- unit, paging and UseAction handlers around the changed secure wrapper.
|
|
-- Frame:GetAttribute and hardware/macro delivery remain explicit mocks;
|
|
-- no native rank alias, source stance ACK or runtime acceptance is claimed.
|
|
local file = assert(io.open(root .. "/runtime/warrior-stance-ui-assessment-20261021/original-secure-ui/interface/addons/blizzard_framexml/securetemplates.lua", "rb"))
|
|
local original = file:read("*a"); file:close()
|
|
local function originalFunction(first, last)
|
|
local a = assert(original:find(first, 1, true))
|
|
local b = assert(original:find(last, a + #first, true))
|
|
return original:sub(a, b - 1)
|
|
end
|
|
local prefix, keyDown, modified, mouseover, vehicle = "", true, {}, false, false
|
|
LOCAL_CHECK_Frame = {
|
|
GetAttribute = function(button, first, name, suffix)
|
|
if not name then return button:GetAttribute(first) end
|
|
for _, key in ipairs({first .. name .. suffix, "*" .. name .. suffix,
|
|
first .. name .. "*", "*" .. name .. "*", name}) do
|
|
if button.attrs[key] ~= nil then return button.attrs[key] end
|
|
end
|
|
end,
|
|
GetParent = function(button) return button.parent end,
|
|
}
|
|
ATTRIBUTE_NOOP = {}
|
|
SecureButton_GetModifierPrefix = function() return prefix end
|
|
assert(loadstring(originalFunction("-- Build lookup table for less common buttons", "function SecureButton_GetModifiedUnit")))()
|
|
assert(loadstring(originalFunction("function SecureButton_GetModifiedUnit", "function SecureButton_GetUnit")))()
|
|
SecureActionButtonMixin = {}
|
|
assert(loadstring(originalFunction("function SecureActionButtonMixin:CalculateAction", "local PRESS_TYPE_DOWN")))()
|
|
SECURE_ACTIONS = {}
|
|
assert(loadstring(originalFunction("SECURE_ACTIONS.action =", "SECURE_ACTIONS.actionrelease =")))()
|
|
local resolver = originalFunction("local PRESS_TYPE_DOWN", "local function PerformAction")
|
|
local resolve = assert(loadstring(resolver .. "\nreturn GetConvertedButtonUnitAndActionType"))()
|
|
C_ActionBar = {GetActionBarPage=function() return page end,
|
|
IsHelpfulAction=function() return true end,
|
|
IsHarmfulAction=function() return true end}
|
|
NUM_ACTIONBAR_BUTTONS, gsub = 12, string.gsub
|
|
GetCVarBool = function(name) return name == "ActionButtonUseKeyDown" and keyDown or name == "enableMouseoverCast" and mouseover end
|
|
GetModifiedClick = function() return "NONE" end
|
|
IsModifiedClick = function(name) return name == "PICKUPACTION" and pickup or modified[name] end
|
|
UnitExists = function() return true end
|
|
UnitHasVehicleUI = function() return vehicle end
|
|
UnitIsFriend = function() return true end
|
|
UnitCanAssist = function() return true end
|
|
UnitCanAttack = function() return false end
|
|
SpellIsTargeting = function() return false end
|
|
SpellStopTargeting = function() error("unexpected targeting mutation") end
|
|
SaveMacro = function() end
|
|
securecallfunction = function(callback, ...) return callback(...) end
|
|
GetCursorInfo = function() end
|
|
SpellFlyout = {Hide=function() end,Toggle=function() error("not a spell action") end}
|
|
local used, macroRuns = {}, 0
|
|
UseAction = function(action, unit, button)
|
|
used[#used+1] = {action=action,unit=unit,button=button}
|
|
end
|
|
OnActionButtonClick = function(button, input, down, isKeyPress)
|
|
local actualButton, unit, kind = resolve(button, input, down and 1 or 2)
|
|
if kind == "macro" then
|
|
macroRuns = macroRuns + 1
|
|
local text = SecureButton_GetModifiedAttribute(button, "macrotext", input)
|
|
check(text:match("\n/click GWWarriorStanceOriginalAction$"), "ability must remain an action, not a numeric spell")
|
|
-- Existing conditional stance-child delivery is not simulated:
|
|
-- this check owns only the new second-action continuation.
|
|
SecureActionButton_OnClick(GWWarriorStanceOriginalAction, "LeftButton", false, true, false)
|
|
elseif kind == "action" then
|
|
SECURE_ACTIONS.action(button, unit, actualButton, isKeyPress)
|
|
end
|
|
end
|
|
local releases=0
|
|
OnActionButtonPressAndHoldRelease = function() releases=releases+1 end
|
|
assert(loadstring(originalFunction("function SecureActionButton_ShouldUseOnKeyDown", "function SecureUnitButton_OnLoad")))()
|
|
actionButton.bindingAction = "ACTIONBUTTON1"
|
|
actions[1] = {"spell",100} -- Exact action ID, intentionally not IsPlayerSpell-known.
|
|
keyBindings.ACTIONBUTTON1 = {"1","SHIFT-1"}
|
|
effectiveBindings["1"], effectiveBindings["SHIFT-1"] = "ACTIONBUTTON1","FOREIGN-OVERRIDE"
|
|
IsPlayerSpell = function() error("action rank must not be selected by a learned-ID callback") end
|
|
IsSpellKnown = IsPlayerSpell
|
|
api.Refresh()
|
|
eq(api.status.configured,78);eq(overrides["SHIFT-1"],nil)
|
|
local proxy = _G[assert(overrides["1"]).name]
|
|
eq(proxy.parent,actionButton);eq(proxy:GetID(),actionButton:GetID())
|
|
eq(proxy:GetAttribute("useparent*"),true);eq(proxy:GetAttribute("type"),nil)
|
|
for _, button in ipairs(frames) do button.CalculateAction=SecureActionButtonMixin.CalculateAction end
|
|
local function press(button, input, down)
|
|
local w=wrapped[button];local before=assert(loadstring(w.before))
|
|
setfenv(before,setmetatable({self=button,control=w.owner,button=input,down=down},{__index=_G}))
|
|
local allow,message=restrictedCall(before)
|
|
if allow ~= false then SecureActionButton_OnClick(button,input,down,true,false) end
|
|
local after=assert(loadstring(w.after));setfenv(after,{self=button,message=message});restrictedCall(after)
|
|
end
|
|
local targets = {
|
|
{attrs={},unit=nil},
|
|
{attrs={["shift-unit1"]="focus"},prefix="shift-",unit="focus"},
|
|
{attrs={unit="raid1",unitsuffix="pet"},unit="raidpet1"},
|
|
{attrs={checkselfcast=true},modified={SELFCAST=true},unit="player"},
|
|
{attrs={checkfocuscast=true},modified={FOCUSCAST=true},unit="focus"},
|
|
{attrs={checkmouseovercast=true},mouseover=true,unit="mouseover"},
|
|
{attrs={unit="player",toggleForVehicle=true},vehicle=true,unit="pet"},
|
|
{attrs={unit="playertarget",toggleForVehicle=true,allowVehicleTarget=true},vehicle=true,unit="pettarget"},
|
|
}
|
|
local ids={};for id in pairs(WoWHybridWarriorStancePolicies) do ids[#ids+1]=id end;table.sort(ids)
|
|
combat=true
|
|
if arg[2] == "--action-slot-only" then for _, id in ipairs(ids) do
|
|
for form=1,3 do
|
|
currentForm=form
|
|
for _, via in ipairs({actionButton,proxy}) do
|
|
for _, onDown in ipairs({false,true}) do
|
|
keyDown=onDown
|
|
for _, target in ipairs(targets) do
|
|
actionButton.attrs={type="action"};for k,v in pairs(target.attrs)do actionButton.attrs[k]=v end
|
|
prefix,modified,mouseover,vehicle=target.prefix or "",target.modified or {},target.mouseover or false,target.vehicle or false
|
|
page=2;actions[13]={"spell",id};local first=#used;local macros=macroRuns
|
|
press(via,"LeftButton",true);press(via,"LeftButton",false)
|
|
eq(#used,first+1,"one original action across both hardware phases")
|
|
eq(used[#used].action,13,"combat page must use actual slot, no spell-ID replacement")
|
|
eq(used[#used].unit,target.unit,"original unit/modifier semantics must survive stance macro")
|
|
eq(macroRuns,macros+1)
|
|
if via==proxy then eq(via:GetAttribute("type"),nil) else eq(via:GetAttribute("type"),"action") end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end end
|
|
-- Native fallback uses the same inherited original rules, including a
|
|
-- help/down remap, an unknown policy ID, pickup, and an unknown form.
|
|
for _, via in ipairs({actionButton,proxy}) do
|
|
for _, variant in ipairs(arg[2]=="--action-fallback-only" and {"held"} or arg[2]=="--action-slot-only" and {"help","down","unknown","pickup","form","right"} or {}) do
|
|
actionButton.attrs={type="action",unit="focus"};prefix,modified,mouseover,vehicle="",{},false,false
|
|
page,keyDown,currentForm,pickup=1,false,1,false;actions[1]={"spell",100};actions[13]={"spell",100}
|
|
if variant=="help" then actionButton.attrs.helpbutton="Help";actionButton.attrs["actionpage-Help"]=2 end
|
|
if variant=="down" then actionButton.attrs.downbutton="Help";actionButton.attrs["actionpage-Help"]=2;keyDown=true end
|
|
if variant=="unknown" then actions[1]={"spell",999999} end
|
|
if variant=="pickup" then pickup=true end
|
|
if variant=="form" then currentForm=4 end
|
|
if variant=="held" then actionButton.attrs.pressAndHoldAction=true end
|
|
local first,macros,priorReleases=#used,macroRuns,releases;press(via,variant=="right"and"RightButton"or"LeftButton",true);press(via,variant=="right"and"RightButton"or"LeftButton",false)
|
|
eq(#used,first+1);eq(macroRuns,macros,"ineligible action remains native")
|
|
eq(used[#used].action,(variant=="help" or variant=="down") and 13 or 1)
|
|
eq(releases,priorReleases+(variant=="held" and 1 or 0),"native hold-release phase must remain original")
|
|
end
|
|
end
|
|
if arg[2] == "--action-slot-branches-only" then
|
|
actionButton:SetID(0);combat=false;page=4;currentForm=3
|
|
actionButton.attrs={type="action",action=245,["shift-action1"]=287,unit="focus"}
|
|
actions[245],actions[287]={"spell",100},{"spell",20617}
|
|
api.Refresh();eq(proxy:GetID(),0);eq(proxy.parent,actionButton)
|
|
combat=true
|
|
for _, via in ipairs({actionButton,proxy}) do
|
|
for _, mod in ipairs({"","shift-"}) do
|
|
prefix,modified,mouseover,vehicle,pickup=mod,{},false,false,false
|
|
keyDown=false;local first,macros=#used,macroRuns
|
|
press(via,"LeftButton",true);press(via,"LeftButton",false)
|
|
eq(#used,first+1);eq(macroRuns,macros+1)
|
|
eq(used[#used].action,mod=="" and 245 or 287,"ID0 uses the original modified explicit action")
|
|
eq(used[#used].unit,"focus")
|
|
end
|
|
end
|
|
eq(overrides["SHIFT-1"],nil,"foreign override still owns its key")
|
|
end
|
|
print("New original action-slot/unit/parent integration assertions: "..assertions.."; scope="..arg[2].."; native runtime unverified")
|
|
return
|
|
end
|
|
if arg[2] == "--status-only" then
|
|
-- A normal slash status read must work while all gameplay/protected paths
|
|
-- are unavailable, and must leave the cached state untouched.
|
|
local function forbidden() error("status dispatched gameplay or a live getter") end
|
|
api.Refresh = forbidden
|
|
InCombatLockdown, UnitClass, GetShapeshiftForm = forbidden, forbidden, forbidden
|
|
SecureHandlerWrapScript, CreateFrame = forbidden, forbidden
|
|
api.status.class, api.status.configured, api.status.wrapped = "WARRIOR", 42, 3
|
|
api.status.refresh = "deferred-combat"
|
|
api.status.owned_forms = {[2457]=1, [71]=2, [2458]=3}
|
|
api.status.action_spells = {[4]=100}
|
|
eq(SLASH_WOWHYBRIDWARRIORSTANCE1, "/gwstance")
|
|
SlashCmdList.WOWHYBRIDWARRIORSTANCE(" status ")
|
|
local text = diagnosticMessages[1]
|
|
check(text:find("loaded=true", 1, true))
|
|
check(text:find("class=WARRIOR", 1, true))
|
|
check(text:find("configured=42", 1, true))
|
|
check(text:find("wrapped=3", 1, true))
|
|
check(text:find("reason=deferred-combat", 1, true))
|
|
check(diagnosticMessages[2]:find("Battle=1 Defensive=2 Berserker=3", 1, true))
|
|
check(diagnosticMessages[3]:find("4:100?", 1, true),
|
|
"cached base-rank action must remain visible even when unconfigured")
|
|
eq(api.status.configured, 42); eq(api.status.wrapped, 3)
|
|
SlashCmdList.WOWHYBRIDWARRIORSTANCE("refresh")
|
|
eq(diagnosticMessages[4], "Usage: /gwstance status")
|
|
print("Warrior autostance cached-status assertions: " .. assertions)
|
|
return
|
|
end
|
|
if arg[2] == "--phase-only" or arg[2] == "--keyboard-phase-only" then
|
|
if arg[2] == "--keyboard-phase-only" then
|
|
actionButton.bindingAction = "ACTIONBUTTON1"
|
|
actions[1] = {"spell", 11578}
|
|
keyBindings.ACTIONBUTTON1 = {"1", "SHIFT-1"}
|
|
effectiveBindings["1"], effectiveBindings["SHIFT-1"] = "ACTIONBUTTON1", "FOREIGN-OVERRIDE"
|
|
end
|
|
api.Refresh()
|
|
local path = root .. "/runtime/warrior-stance-ui-assessment-20261021/original-secure-ui/interface/addons/blizzard_framexml/securetemplates.lua"
|
|
local file = assert(io.open(path, "rb"))
|
|
local original = file:read("*a"); file:close()
|
|
local first = assert(original:find("function SecureActionButton_ShouldUseOnKeyDown", 1, true))
|
|
local last = assert(original:find("function SecureUnitButton_OnLoad", first, true))
|
|
local dispatch = assert(loadstring(original:sub(first, last - 1)))
|
|
local presses = 0
|
|
SecureButton_GetAttribute = function(button, name) return button:GetAttribute(name) end
|
|
GetCVarBool = function(name) return name == "ActionButtonUseKeyDown" end
|
|
OnActionButtonClick = function() presses = presses + 1 end
|
|
OnActionButtonPressAndHoldRelease = function() error("unexpected held-spell path") end
|
|
dispatch()
|
|
-- Reproduce the omitted child attribute using the actual pinned gate.
|
|
local child = GWWarriorStanceSpell2457
|
|
eq(child:GetAttribute("useOnKeyDown"), false)
|
|
child:SetAttribute("useOnKeyDown", nil)
|
|
SecureActionButton_OnClick(child, "LeftButton", false)
|
|
eq(presses, 0, "old AnyUp child is ignored when CVar inherits keydown")
|
|
child:SetAttribute("useOnKeyDown", false)
|
|
SecureActionButton_OnClick(child, "LeftButton", false)
|
|
eq(presses, 1, "explicit AnyUp child reaches exactly one original action")
|
|
SecureActionButton_OnClick(child, "LeftButton", true)
|
|
eq(presses, 1, "keydown must not double-dispatch this AnyUp-only child")
|
|
if arg[2] == "--keyboard-phase-only" then
|
|
local binding = assert(overrides["1"])
|
|
eq(binding.priority, false); eq(overrides["SHIFT-1"], nil, "foreign override preserved")
|
|
eq(api.status.keyboard, 1)
|
|
local proxy = _G[binding.name]
|
|
eq(proxy:GetAttribute("useOnKeyDown"), nil, "native key-phase CVar inherited")
|
|
local dispatched = {}
|
|
OnActionButtonClick = function(button)
|
|
dispatched[#dispatched+1] = {kind=SecureButton_GetModifiedAttribute(button,"type"), action=button:GetID()>0 and (button:GetID()+((GetActionBarPage()-1)*12)) or SecureButton_GetModifiedAttribute(button,"action"), macro=button:GetAttribute("macrotext")}
|
|
end
|
|
local function keypress(down)
|
|
local w = wrapped[proxy]
|
|
local before = assert(loadstring(w.before))
|
|
setfenv(before, {self=proxy, control=w.owner, button="LeftButton", down=down,
|
|
GetShapeshiftForm=GetShapeshiftForm, GetActionBarPage=GetActionBarPage,
|
|
GetActionInfo=GetActionInfo, IsModifiedClick=IsModifiedClick})
|
|
local allow, message = restrictedCall(before)
|
|
if allow ~= false then SecureActionButton_OnClick(proxy, "LeftButton", down) end
|
|
local after = assert(loadstring(w.after))
|
|
setfenv(after, {self=proxy,message=message}); restrictedCall(after)
|
|
end
|
|
keypress(true)
|
|
eq(#dispatched, 1); eq(dispatched[1].kind, "macro")
|
|
check(dispatched[1].macro:find("GWWarriorStanceOriginalAction", 1, true))
|
|
eq(proxy:GetAttribute("type"), nil, "proxy restores native parent inheritance"); eq(actionButton:GetAttribute("type"), "action")
|
|
keypress(false); eq(#dispatched, 1, "keyup does not double cast")
|
|
-- A combat page change preserves native action dispatch for non-owned slots.
|
|
combat, page = true, 2
|
|
for _, kind in ipairs({"item", "macro", "spell"}) do
|
|
actions[13] = {kind, 999999}; keypress(true)
|
|
eq(dispatched[#dispatched].kind, "action"); eq(dispatched[#dispatched].action, 13)
|
|
end
|
|
local prior = overrides["1"]; api.Refresh(); eq(overrides["1"], prior, "combat leaves own bindings untouched")
|
|
combat, class = false, "DRUID"; api.Refresh(); eq(overrides["1"], nil, "class exit clears only owned overrides")
|
|
eq(effectiveBindings["SHIFT-1"], "FOREIGN-OVERRIDE")
|
|
end
|
|
print("Warrior autostance original click-phase assertions: " .. assertions)
|
|
return
|
|
end
|
|
local owned={ [2457]=1,[71]=2,[2458]=3 }
|
|
local condition,stance=api.Plan(327680,0,owned)
|
|
eq(condition,"nostance:1/3");eq(stance,2457)
|
|
condition,stance=api.Plan(65536,65536,owned);eq(condition,nil)
|
|
condition,stance=api.Plan(196608,65536,owned);eq(condition,"nostance:2");eq(stance,71)
|
|
eq(api.Plan(65536,1,owned),nil,"unknown excluded source bit")
|
|
eq(api.Plan(65537,0,owned),nil,"unknown required source bit")
|
|
eq(api.Plan(262144,0,{[2457]=1}),nil,"unowned stance not invented")
|
|
condition,stance=api.Plan(0,65536,owned);eq(condition,"stance:1");eq(stance,71)
|
|
local macro=api.Macro(20617,"nostance:3",2458)
|
|
eq(macro,"/click [nostance:3] GWWarriorStanceSpell2458\n/click GWWarriorStanceOriginalAction")
|
|
eq(api.Macro(20617,"nostance:3]\n/run bad",2458),nil,"no injected macro text")
|
|
eq(api.Macro(20617,"nstance:3",2458),nil,"unknown conditional")
|
|
learned[2458]=nil -- Original owned form list is the stance authority, not spellbook rows.
|
|
api.Refresh();eq(api.status.configured,78);eq(api.status.wrapped,1)
|
|
local control=GWWarriorStanceControl
|
|
check(control:GetAttribute("gw-macro-11578"),"known Charge configured")
|
|
check(not control:GetAttribute("gw-macro-26651"),"unknown source form held")
|
|
eq(GWWarriorStanceOriginalAction:GetAttribute("type"),"action","native action owns ability rank")
|
|
eq(GWWarriorStanceSpell2457:GetAttribute("spell"),2457,"exact numeric stance")
|
|
-- Run the actual restricted source snippet against its whitelisted environment.
|
|
local function before(button)
|
|
local w=wrapped[actionButton];local f=assert(loadstring(w.before))
|
|
setfenv(f,setmetatable({self=actionButton,control=w.owner,button=button or "LeftButton",down=true},{__index=_G}))
|
|
local _,message=restrictedCall(f);return message
|
|
end
|
|
local function after(message)
|
|
local w=wrapped[actionButton];local f=assert(loadstring(w.after))
|
|
setfenv(f,{self=actionButton,message=message});restrictedCall(f)
|
|
end
|
|
actions[1]={"spell",11578}
|
|
local message=before();eq(actionButton.attrs.type,"macro");check(actionButton.attrs.macrotext:find("GWWarriorStanceOriginalAction",1,true));after(message)
|
|
eq(actionButton.attrs.type,"action");eq(actionButton.attrs.macrotext,nil)
|
|
-- Combat page/slot changes are resolved at click time, never from cached spell IDs.
|
|
combat=true;page=2;actions[13]={"spell",20617}
|
|
message=before();check(actionButton.attrs.macrotext:find("GWWarriorStanceOriginalAction",1,true));after(message)
|
|
actions[13]={"item",11578};eq(before(),nil);eq(actionButton.attrs.type,"action")
|
|
actions[13]={"macro",123};eq(before(),nil)
|
|
actions[13]={"spell",999999};eq(before(),nil)
|
|
actions[13]={"spell",20617};currentForm=4;eq(before(),nil,"unknown form stays original")
|
|
currentForm=1;pickup=true;eq(before(),nil,"drag modifier stays original");pickup=false
|
|
eq(before("RightButton"),nil,"right click stays original")
|
|
-- Refresh never mutates protected attributes in combat.
|
|
local count=api.status.configured;learned[20617]=nil;api.Refresh();eq(api.status.configured,count)
|
|
combat=false;api.Refresh();check(control:GetAttribute("gw-macro-20617"),"policy remains available; native action owns learned-rank resolution")
|
|
-- A different class does not receive Warrior mappings/wrappers.
|
|
class="DRUID";local wraps=api.status.wrapped;api.Refresh();eq(api.status.wrapped,wraps);eq(control:GetAttribute("gw-warrior-enabled"),nil)
|
|
eq(before(),nil,"different class preserves original action")
|
|
print("Warrior autostance secure mock assertions: "..assertions)
|